Monday, 16 December 2013

difference between partial submit and auto submit in adf

https://blogs.oracle.com/jdevotnharvest/entry/partial_submit_vs_auto_submit

partialSubmit

Default Value: false
whether the action should be done through a partial page submit or not. Default is false: no partial page submit; the full page will be refreshed. When set to true, the full page will not be refreshed. To re-render specific components on your page in response to the partial page submit, you have to tell ADF Faces. The easiest way to do this is with the partialTriggers attribute.

isPartialSubmit
public final boolean isPartialSubmit()
Gets whether the action should be done through a partial page submit or not. Default is false: no partial page submit; the full page will be refreshed. When set to true, the full page will not be refreshed. To re-render specific components on your page in response to the partial page submit, you have to tell ADF Faces. The easiest way to do this is with the partialTriggers attribute.
Returns:
the new partialSubmit value

setPartialSubmit

public final void setPartialSubmit(boolean partialSubmit)

Sets whether the action should be done through a partial page submit or not. Default is false: no partial page submit; the full page will be refreshed. When set to true, the full page will not be refreshed. To re-render specific components on your page in response to the partial page submit, you have to tell ADF Faces. The easiest way to do this is with the partialTriggers attribute.
Parameters:
partialSubmit - the new partialSubmit value

------------------------------------------------------------------------------------------------------------

autosubmit

Default Value: false
autosubmit="true"
an attribute which if set to TRUE on a form element, the component will automatically submit when an appropriate action takes place (a click, text change, etc.). 
Since autoSubmit is a partial submit, also submitted and re-rendered are any other components with partialTriggers pointing to this component.

isAutoSubmit

public final boolean isAutoSubmit()
Gets an attribute which if set to TRUE on a form element, the component will automatically submit when an appropriate action takes place (a click, text change, etc.). Since autoSubmit is a partial submit, also submitted and re-rendered are any other components with partialTriggers pointing to this component.
Returns:
the new autoSubmit value

setAutoSubmit

public final void setAutoSubmit(boolean autoSubmit)
Sets an attribute which if set to TRUE on a form element, the component will automatically submit when an appropriate action takes place (a click, text change, etc.). Since autoSubmit is a partial submit, also submitted and re-rendered are any other components with partialTriggers pointing to this component.
Parameters:
autoSubmit - the new autoSubmit value




Tuesday, 3 December 2013

javax.faces.component.UIComponent class hierarchy

http://docs.oracle.com/cd/E17802_01/j2ee/javaee/javaserverfaces/2.0/docs/api/javax/faces/component/UIComponent.html

Class Hierarchy

Interface Hierarchy

Annotation Type Hierarchy


Wednesday, 6 November 2013

21 Understanding the Fusion Page Lifecycle(fdg-11.1.1.6)

When a page is submitted and a new page requested, the application invokes both the
ADF Faces page lifecycle, which extends the standard JSF request lifecycle, and the
ADF page lifecycle
ADF Faces page lifecycle (extended JSF lifecycle)
The extended JSF lifecycle handles submitting the values on the page, validating component values, navigating pages, displaying components on the resulting page, and saving and restoring state.
The JSF lifecycle phases use a UI component tree to manage the display of the faces components. This tree is a runtime representation of a JSF page: each UI component tag in a page corresponds to a UI component instance in the tree.
The FacesServlet servlet manages the request processing lifecycle in JSF applications. FacesServlet creates an object called FacesContext, which contains the information necessary for request processing, and invokes an object that executes the lifecycle.
For more details about the extended JSF lifecycle, see the "Understanding the JSF and ADF Faces Lifecycles" chapter of the Oracle Fusion Middleware Web User Interface Developer's Guide for Oracle Application Development Framework.
ADF page lifecycle
The ADF page lifecycle handles preparing and updating the data model, validating
the data at the model layer, and executing methods on the business layer.
The ADF page lifecycle uses the binding container to make data available for easy referencing by the page during the current page request.
The combined JSF and ADF page lifecycle is only one sequence within a larger sequence of events that begins when an HTTP request arrives at the application server and continues until the page is returned to the client. This overall sequence of events can be called the web page lifecycle. It follows processing through the model, view, and controller layers as defined by the MVC architecture. The page lifecycle is not a rigidly defined set of events, but is rather a set of events for a typical use case.

Figure 21–1shows a sequence diagram of the lifecycle of a web page request using JSF and Oracle ADF in tandem.

The basic flow of processing a web page request using JSF and Oracle ADF happens as
follows:

1. A web request for http://yourserver/yourapp/faces/some.jsp arrives from the client to the application server.
2. The ADFBindingFilter object looks for the ADF binding context in the HTTP session, and if it is not yet present, initializes it for the first time.
Some of the functions of the ADFBindingFilter include finding the name of the binding context metadata file, and finding and constructing an instance of each data control.

3. The ADFBindingFilter object invokes the beginRequest() method on each data control participating in the request. This method gives the data control a notification at the start of every request so that it can perform any necessary setup.

4. The JSF Lifecycle object, which is responsible for orchestrating the standard processing phases of each request, notifies the ADFPhaseListener class during each phase of the lifecycle, so that it can perform custom processing to coordinate the JSF lifecycle with the ADF Model data binding layer. For more information about the details of the JSF and ADF page lifecycle phases, see Section 21.2, "The JSF and ADF Page Lifecycles." The JSF and ADF Page Lifecycles Understanding the Fusion Page Lifecycle 21-3

5. The ADFPhaseListener object creates an ADF PageLifecycle object to
handle each request and delegates appropriate before and after phase methods to
corresponding methods in the ADF PageLifecycle class. If the appropriate
binding container for the page has never been used before during the user's
session, it is created.

6. The first time an application module data control is referenced during the request, it acquires an instance of the application module from the application module pool.

7. The JSF Lifecycle object forwards control to the page to be rendered.
8. The UI components on the page access value bindings and iterator bindings in the page's binding container and render the formatted output to appear in the browser.

9. The ADFBindingFilter object invokes the endRequest() method on each data control participating in the request. This method gives a data control notification at the end of every request, so that they can perform any necessary resource cleanup.

10. An application module data control uses the endRequest notification to release the instance of the application module back to the application module pool.

11. The user sees the resulting page in the browser.

The ADF page lifecycle also contains phases that are defined simply to notify ADF page lifecycle listeners before and after the corresponding JSF phase is executed (that is, there is no implementation for these phases). These phases allow you to create custom listeners and register them with any phase of both the JSF and ADF page lifecycles, so that you can customize the ADF page lifecycle if needed, both globally or at the page level.

Tuesday, 5 November 2013

adf intigratation with ldap

I received last week in my work new requirement to make signing in application single sign on(sso) through active directory. So I have a lot of solution 1- Use ADF Security and integrate with active directory LDAP from weblogic server      This solution is declarative but customization is hard  2- Use custom java code to integrate with LDAP directly.      This solution is good but what if I change UI development by another tool? I will redevelop again in new   framework  3- Create database package to integrate with LDAP       I prefer this solution as I use DB to integrate with LDAP and it is unit of later maintenance and applicable for other application. I will illustrate the last two solution
2) Use Custom Java Code to Integrate with LDAP
I create class for this purpose for test as below We need some properties of LDAP 1-host name or IP of LDAP Server and port
       protected static String MY_HOST = "ldap://10.32.209.230:389";
2-Search base in LDAP

       protected static String MY_SEARCHBASE = "DC=MCIT,DC=LOCAL";

3- User in LDAP to connect by it in LDAP
       protected static String MGR_DN = "crmtest";

4-password of user which we connect by it. 
       protected static String MGR_PW = "mcit@****";
We should enter search criteria to LDAP, in our example we search about use in LDAP, so I used below filter
    protected static String MY_FILTER = "sAMAccountName=mmahmoud";
As in previous example mmahmoud is user id which  I search about it in LDAP You can run below class and see the results. 
   package view; 
  
   import java.util.Hashtable; 
   import javax.naming.*; 
   import javax.naming.directory.*; 
   public class LdapTest { 
     protected static String INITCTX = "com.sun.jndi.ldap.LdapCtxFactory"; 
     protected static String MY_HOST = "ldap://10.32.209.230:389"; 
     protected static String MY_SEARCHBASE = "DC=MCIT,DC=LOCAL"; 
     protected static String MY_FILTER = "sAMAccountName=mmahmoud"; 
     protected static String MGR_DN = "crmtest"; 
     protected static String MGR_PW = "mcit@****"; 
     public static void main(String[] args) { 
       try {
         Hashtable params = new Hashtable();   
         params.put(Context.INITIAL_CONTEXT_FACTORY, INITCTX); 
         params.put(Context.SECURITY_AUTHENTICATION, "simple");
         params.put(Context.PROVIDER_URL, MY_HOST);
         params.put(Context.SECURITY_PRINCIPAL, MGR_DN); 
         params.put(Context.SECURITY_CREDENTIALS, MGR_PW);

         DirContext ctx = new InitialDirContext(params); 
  
         SearchControls constraints = new SearchControls(); 
  
         constraints.setSearchScope(SearchControls.SUBTREE_SCOPE); 
  
         NamingEnumeration results = ctx.search(MY_SEARCHBASE, MY_FILTER, constraints); 
  
         if (results != null && results.hasMore()) { 
           SearchResult sr = (SearchResult)results.next(); 
           String dn = sr.getName(); 
           System.out.println("Desc name is " + dn); 
           Attributes attrs = sr.getAttributes(); 
           System.out.println(attrs.get("sAMAccountName")); 
         } else { 
           System.out.println("Not exist User");                    
         } 
       } catch (AuthenticationException e) { 
         System.out.println("You aren't authenticated on LDAP"); 
       } catch (PartialResultException e) { 
         System.out.println(MY_FILTER + " Not exists in LDAP"); 
       } catch (NamingException e) { 
         e.printStackTrace(); 
       } 
     } 
   }
3) Create database package to integrate with LDAP
I used predefined package developed by oracle DBMS_LDAP to integrate with LDAP through DB I created my custom package as below ldap_integration CREATE OR REPLACE PACKAGE  ldap_integration IS    PROCEDURE init (p_ldap_host    VARCHAR2,                    p_ldap_port    NUMBER,                    p_ldap_user    VARCHAR2,                    p_ldap_pwd     VARCHAR2,                    p_ldap_base    VARCHAR2);    FUNCTION search_user (p_user IN VARCHAR2, p_pwd IN VARCHAR2 DEFAULT ' ')       RETURN VARCHAR2; END ldap_integration; / CREATE OR REPLACE PACKAGE BODY  ldap_integration IS    -- globale variables --    GC$ldap_host   VARCHAR2 (256) ;    GC$ldap_port   VARCHAR2 (256) ;    GC$ldap_user   VARCHAR2 (256) ;    GC$ldap_pwd    VARCHAR2 (256);    GC$ldap_base   VARCHAR2 (256);    PROCEDURE init (p_ldap_host    VARCHAR2,                    p_ldap_port    NUMBER,                    p_ldap_user    VARCHAR2,                    p_ldap_pwd     VARCHAR2,                    p_ldap_base    VARCHAR2)    IS    BEGIN       GC$ldap_host := p_ldap_host;       GC$ldap_port := p_ldap_port;       GC$ldap_user := p_ldap_user;       GC$ldap_pwd := p_ldap_pwd;       GC$ldap_base := p_ldap_base;    END init;    FUNCTION search_user (p_user IN VARCHAR2, p_pwd IN VARCHAR2 DEFAULT ' ')       RETURN VARCHAR2    IS       l_retval      PLS_INTEGER;       l_session     DBMS_LDAP.session;       l_attrs       DBMS_LDAP.string_collection;       l_message     DBMS_LDAP.MESSAGE;       l_ret_value   VARCHAR2 (500);    BEGIN       DBMS_LDAP.USE_EXCEPTION := TRUE;       -- Connect to the LDAP server.       l_session :=          DBMS_LDAP.init (hostname => GC$ldap_host, portnum => GC$ldap_port);       l_retval :=          DBMS_LDAP.          simple_bind_s (ld       => l_session,                         dn       => GC$ldap_user,                         passwd   => GC$ldap_pwd);       -- Get all attributes       l_attrs (1) := '*';                           -- retrieve all attributes       l_retval :=          DBMS_LDAP.search_s (ld         => l_session,                              base       => GC$ldap_base,                              scope      => DBMS_LDAP.SCOPE_SUBTREE,                              filter     => 'sAMAccountName=' || p_user,                              attrs      => l_attrs,                              attronly   => 0,                              res        => l_message);       IF DBMS_LDAP.count_entries (ld => l_session, msg => l_message) > 0       THEN          l_ret_value := 'OK';       ELSE          l_ret_value := 'FALSE';       END IF;       -- Disconnect from the LDAP server.       l_retval := DBMS_LDAP.unbind_s (ld => l_session);       RETURN l_ret_value;    EXCEPTION       WHEN OTHERS       THEN          DBMS_OUTPUT.          put_line (' sql error  : ' || SQLCODE || ' sql msg : ' || SQLERRM);          IF l_session IS NOT NULL          THEN             l_retval := DBMS_LDAP.unbind_s (ld => l_session);          END IF;          RETURN ' sql error  : ' || SQLCODE || ' sql msg : ' || SQLERRM;    END search_user; END ldap_integration; / After creating previous package you can call it as below script you must assign that variables to procedure INTEGRATION.INIT 1-LDAP_Host 2-LDAP Port 3-LDAP user name 4-LDAP user password 5-LDAP Base( Which base we use to search about entered user) Then pass search user id to function LDAP_INTEGRATION.search_user that will return "OK" if user exists in LDAP otherwise It will return "FALSE". DECLARE    P_LDAP_HOST   VARCHAR2 (512);    P_LDAP_PORT   NUMBER;    P_LDAP_USER   VARCHAR2 (512);    P_LDAP_PWD    VARCHAR2 (512);    P_LDAP_BASE   VARCHAR2 (512);    P_userid      VARCHAR2 (200); BEGIN    P_LDAP_HOST := '10.32.209.230';    P_LDAP_PORT := 389;    P_LDAP_USER := 'crmtest';    P_LDAP_PWD := 'mcit@****';    P_LDAP_BASE := 'DC=MCIT,DC=LOCAL';    P_userid := 'mmahmoud';    MCIT_CMS.LDAP_INTEGRATION.INIT (P_LDAP_HOST,                                    P_LDAP_PORT,                                    P_LDAP_USER,                                    P_LDAP_PWD,                                    P_LDAP_BASE);    DBMS_OUTPUT.put_line (MCIT_CMS.LDAP_INTEGRATION.search_user (P_userid)); END; Because I haven't a lot of time, I wrote this article quickly and briefly. If you have any query, don't hesitate to contact me.

Using FacesMessage to Create a Message (javaee7)

 FacesMessage msg=new FacesMessage("This is an inline FacesMessage");
 msg.setSeverity(FacesMessage.SEVERITY_FATAL);
 FacesContext fctx=FacesContext.getCurrentInstance();
 fctx.addMessage(null, msg);





http://adfgouravtkiet.blogspot.in/2012/07/how-to-use-facesmessage-component-in-adf.html

http://oracleadf-java.blogspot.in/2012/10/show-inline-message-in-oracle-adf.html