Wednesday 18 September 2013

Synchronizing problem with migrating the jdeveloper 11.1.1.7.0 to jdeveloper 11.1.2.3.0

i was migrating the jdeveloper 11.1.1.7.0 to 11.1.2.3.0 ...The synchronize with database option was disabled on all entities - migrated entities as well as new entities created in the project.

I found a solution which seems to work. we haven't found any drawbacks yet and the application runs just fine.


The problem with our project, was the type mapping value, which has been changed to "Java" during the migration. You can see your current value in project properties -> ADf Business Components -> Data Type Map. You cannot change this value in the project properties but you can change it manually in the Model.jpx. In this file changes the value of the attribute "_jbo.TypeMapEntries" to "OracleApps" (Java extended for oracle). I discovered that after this change, the "synchronize with database" context menu item was enabled again and the application ran without more changes. But, after the change, new entities are created with some other data type mappings (Long, Integer, Date, Timestamp) which in some cases were different than the existing ones. Thus we updated the complete entity model to use the
"OracleApps" data types and now we don't have to worry about the entity data types anymore. And the synchronization with the database works perfectly.

Sunday 9 June 2013

Enable the ADF Security

1)Declarative security support for ADF resources, such as the bounded task flow.

With Oracle ADF Security, you can control whether or not the user can enter a task flow. Thus, a single security policy for a task flow can control access to multiple web pages.


2)Simplified permission assignment using application roles that allow for the inheritance of permissions

While Java EE security roles that are used by Java EE security constraints are flat, JAAS permissions are granted to application roles, which can be nested and may be mapped to enterprise roles that the Oracle WebLogic Server domain defines.



3)Utility methods for use in EL expressions to access ADF resources in the security context

You can use the Oracle ADF Security EL expression utility methods to determine whether the user is allowed to perform a known operation. For example, you can determine whether the user is allowed to view a particular task flow.
Steps :
1.Enable Oracle ADF Security for the application:
(a)From the Application menu, choose Secure > Configure ADF Security.
(b)In the ADF Security page, leave the default ADF Authentication and Authorization option selected. Click Next.
(c)In the Authentication Type page> select the authentication type that you want your application to use when the user submits their login information. Click Next.
Select Form-based Authentication, you can also select Generate Default Pages to allow the wizard to generate a default login and error page.
(d)In the Automatic Policy Grants page, leave the default No Automatic Grants option selected. Click Next .

(e)In the Authenticated Welcome page, select Redirect Upon Successful Authentication to direct the user to a specific web page after they log in. Click Next. Then Finish.

2)Creating Application Roles
You create application roles to represent the policy requirements of the application and to define groups of users with the same view permission rights.
(a)Choose Secure > Application Roles from the Application menu in the JDeveloper.


b)Select Add New Role in the Application Roles tab. Provide the name for Role(eg: Admin)
When you add an application role to the policy store, JDeveloper updates the jazn-data.xml file located in the src/META-INF folder relative to the application workspace.

(c)Add users to the newly created Roles


Create the User and select the check box. Click OK.

3)Grant public access to ADF security-aware resources
In the Resource Grants overview editor, click one of the following Resource Type :
Task Flows when you want to make a bounded task flow public. The application displays the web pages under the permission you define for the task flow itself. Thus, all constituent web pages of the bounded task flow will become public.

Web Pages when you want to make individual web pages public. Typically, these pages are defined by an unbounded task flow and are top-level pages in the application, such as a home page.

Add required Application role or User to the TF or web page.

Use EL to specify viewable components on the Page. For Eg:
For login/logout Link:
Text: #{securityContext.authenticated ? "Logout" : "Login"}
Destination: #{securityContext.authenticated ? "/adfAuthentication?logout=true&end_url=/faces/IndexPage.jspx" : "/adfAuthentication?success_url=/faces/IndexPage.jspx"}

Use EL to configure rendered property of Button/Link for particular Role. For Eg:


#{securityContext.UserInRole['Admin']}
OR
#{securityContext.UserInRoles['Admin','Staff']}

4)Security can be bestowed upon Entity object attributes too.




Once security is enabled, you need to associate roles to it, or no one will be able to edit this attribute.


When 'Edit Authorization' is clicked jazn-data.xml is opened where you can configure the roles for the attributes to be modifiable.
On the starting Page of your Application , to enable view for all users(anonymous), configure the role as 'Anonymous User' for the landing page as follows:



#{securityContext.taskflowViewable['SomeTaskFlow']}:Returns true if the user has access to the specific SomeTaskFlow task flow

#{securityContext.regionViewable['SomePageDef']}:Returns true if the user has access to the specific SomePageDef page definition file associated with a page.

#{securityContext.userName}:
Returns the authenticated user's username.

#{securityContext.authenticated}:Returns true if the user has been authenticated.

#{securityContext.userInAllRoles['roleList']}:Returns true if user has roles in the comma seperated rolesList assigned.

Saturday 8 June 2013

Table Pagination with JDeveloper 11.1.1.7



One of the new features listed for JDeveloper 11.1.1.7 is pagination for tables, a frequently requested and long awaited feature (http://www.oracle.com/technetwork/developer-tools/jdev/index-088099.html). 
The tag documentation about this feature states that to switch pagination on you simply set the scrollPolicy property to page.Truth to be told, there is a little bit more for you to do.

1. You need to set the
autoHeightRows property to 0

2. You need to make sure the surrounding container provides a floating layout and doe not stretch (e.g. using a panelGroupLayout)

3. To bring the table into shape (full width) you then
set styleClass="AFStretchWidth"

All changes at a glance:

scrollPolicy="page" autoHeightRows="0" styleClass="AFStretchWidth"
Once you did this, the table renders as shown in the image below.

Friday 7 June 2013

commiting the record from bean

In many situation we need to get binding container from our backingbean to execute some of the operation as ( Commit - Rollback - Next - Last - Execute With Param - ............. ) or get your Iterator to get some information as (get Current Row - get View Object - get number of row count - refresh iterator - .............. ) There are two way to get your binding container from backingbean :

1-BindingContainer bindngs=BindingContext.getCurrent().getCurrentBindingsEntry();
then you can use bindings object to execute some of binding operation as commit operation as:


OperationBinding operationBinding = bindings.getOperationBinding("Commit");
operationBinding.execute();


2- The second way to get binding container is to define a method that return binding container as :

private BindingContainer bindings;
public BindingContainer getBindings() {
if (this.bindings == null) {
FacesContext fc=FacesContext.getCurrentInstance();
this.bindings = (BindingContainer)fc.getApplication().evaluateExpressionGet(fc,"#{bindings}",
BindingContainer.class);
}
return this.bindings;
}

to get binding and execute a commit operation :
BindingContainer bindings = getBindings();
OperationBinding operationBinding = bindings.getOperationBinding("Commit");
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty()) {
return null;
}

this is also use ful code when creating a button through managedbean


BindingContainer bindings = (BindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
OperationBinding operationBinding = (OperationBinding)bindings.getOperationBinding("CreateInsert");
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty())
{
FacesMessage fm = new FacesMessage(operationBinding.getErrors().get(0).toString());
fm.setSeverity(FacesMessage.SEVERITY_ERROR);
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, fm);
}
   

Monday 27 May 2013

what are Task Flow Activities and Control Flows?

Method Call:Invokes a method, typically a method on a managed bean. A method call activity can be placed anywhere within an application's control flow to invoke application logic based on control flow rules.

Parent Action:Allows a bounded task flow to generate outcomes that are passed to its parent view activity.

Router:Evaluates an EL expression and returns an outcome based on the value of the expression. For example, a router in a credit check task flow might evaluate the return value from a previous method call and generate success, failure, or retry outcomes based on various cases. These outcomes can then be used to route control to other activities in the task flow.

Wednesday 22 May 2013

How to pass parameters between taskflows?

Here is the sample Taskflow design and we need to pass parameters from Caller TF to Callee TF.
Go to the definition of Callee TF and goto Parameters tab and define the Input Parameter Definitions.
Now go to the taskflow design and click on the Callee TF and go to the properties tab. In the 'Parameters' section you will see the parameters that you defined earlier. Here you should fill in the values that you want to pass.

On the event of which the Callee TF is called, you should set the values in the pageFlowScope.param1 and param2.
<af:commandToolbarButton id="ctbCreate" action="dialog:showWizard" >
<af:setPropertyListener from="0"
to="#{pageFlowScope.dpDimensionId}"
type="action" />
<af:setPropertyListener from="0"
to="#{pageFlowScope.decisionPackageId}"
type="action" />
</af:commandToolbarButton >

Now you would be able to get the values of param1 and param2 as 0 in the callee TF.

Tuesday 14 May 2013

Use Checkbox For Selecting Multiple Rows From af:table

One of the feature which existed in JDeveloper 10g but not found in JDeveloper 11g is using checkbox for selecting multiple rows from af:table.
This is my workaround for achieving this feature in JDeveloper 11g. Follow this steps:


1- Make a new ADF fusion web Application.
2- choose your database connection. (assume we are using HR Schema).
3- Make one viewObject based on entity (assume Employees viewObject based on Employees Entity).
4- Open your Employees ViewObject and make a new transient attribute with type boolean and make it always updatable (assume the transient Attribute name is 'TransientAttr').


5- Make a new page and drag your employee view as a table and don't check on Row Selection checkbox.

6- In your Structure Palette goto your inputText Transient attribute and right click and choose Convert to.

7- From opening dialog choose Select Boolean Checkbox --->ok-->ok


8- Make the selectBooleanCheckbox component AutoSubmit with true and put its Id in the table partialTrigger and clear its lable and text.


9-
Select all columns and goto Style Property and inlineStyle write
this #{(row.TransientAttr)?"background-color: #ffaaaa":""};
where #ffaaaaa is the color of the selected row (you can change this color as you want).

10-Now any row has its transient Attribute with true value, this row will be selected row.

Sunday 5 May 2013

Custom SkipValidation in a fragment pageDef

Test 1 : 

-
SkipValidation=false in a fragment pagedef :
Entity level validations are executed.
All datacontrols validations of a page are executed.
And we see the other tabs validations errors. It is not the desirable behaviour for us.

Test 2:

- SkipValidation=true in a fragment pagedef :
Entity level validations are not executed when we change row ...
Validations of datacontrols are executed at the commit.
The other datacontrols validations are not executed.
Unfortunately, it is not the desirable behaviour for us because we need a validation when we change row ... entity level validation.

Test 3 :

- SkipValidation=skipDatacontrol in a fragment pagedef :
The same behaviour like test 2.
Why Entity levels validations are executed at the commit, not when we change a row. Is that normal?
The documentation said that with this value of skipValidation, the framework will execute validation
rules defined at attribute level or at entity object level for rows which are modified in the current transaction.
We dont understand the difference between SkipValidation=true and SkipValidation=skipDatacontrol


Test 4 : 

- SkipValidation=custom in a fragment pagedef : 


The custom validator in configured like managedBean in the adfc-config.xml with request Scope
The custom validator is not executed, but te behaivour is like test 2 (skipvalidator=true)

Test 5 :

- SkipValidation=custom in a main page PageDefs :

The custom validator is executed, but te behaivour is like test 2 (skipvalidator=true)
In these case we try to set the property SkipValidation of the pageDefs of tabs, but is not working.



public void validateBindingContainer(BindingContainer bindingContainer) {


DynTabManager tabMng = (DynTabManager)JSFUtil.resolveExpression("#{viewScope.dynTabManager}");

String selectedTabId = tabMng.getSelectedTabId();

for (DynTab tab : tabMng.getTabList()) { 

String tabPageDef = (String)tab.getParameters().get("pi_bindings");

DCBindingContainer binding = (DCBindingContainer) JSFUtil.resolveExpression("#{data."tabPageDef"}");


if (tab.getId().equals(selectedTabId)) {
// Normal validation in current TAB
binding.setSkipValidation(false);
} else {
//avoid validation other tabs
binding.setSkipValidation(true);
}
}
return;
}

difference between beanscope and pageflow scope?


It all depends on the kind of functionality that you have implemented in the backing bean. For example, if you want certain backing bean variables to persist from one request to another, then requestScope won't do - the backing bean will be created/destroyed for each user request. As you probably know, the scope determines the lifecycle of the bean, i.e. when the bean is created and when it is destroyed.

Now, backingBeanScope is used exclusively for page fragments (regions).

In our project we are using pageFlowScope. In this case, the backing bean persists for the duration of the page (i.e. mulitple requests for the same page).

Friday 26 April 2013

Insert Rows in ADF View Object Programatically

I will illustrate how to insert new rows in view object programatically.

ٍSuppose that I have EmpVO view object which have below attributes
a-EmpId
b-FirstName
c-LastName

We can do inserting rows by two ways in data model layer (Application Model or ViewObject classes)
I will write my code in ApplicationModuleImpl class



1-createRow() method
2-createAndInitRow() method

  
I prefer using second method createAndInitRow because it sets default values of attributes in view object but first method insertRow doesn't do this.

ADF : Redirect to another View Programatically

You can use the below method to redirect to another view in ADF programatically.

public static void redirectToView(String viewId) 

FacesContext fCtx = FacesContext.getCurrentInstance();
ExternalContext eCtx = fCtx.getExternalContext(); String activityUrl = ControllerContext.getInstance().getGlobalViewActivityURL(viewId); 
 try { 
 eCtx.redirect(activityUrl); 
 } 
catch (IOException e) { 
e.printStackTrace(); JSFUtils.addFacesErrorMessage("Exception when redirect to " + viewId); 
 } 
 }

Custom Exception in ADF

sometimes in your business logic you want to throw
an exception regarding business requirements not Java syntax coding exception.
For example you want to raise an exception that birthday is not later than hire date.

To implement this cased in ADF I prefer the below steps.
1- Create new "ApplicationException" class and extend oracle.jbo.JboException


Create new custom class which extends oracle.jbo.JboException for adding your custom code to exception later.
import oracle.jbo.JboException;
import oracle.jbo.common.ResourceBundleDef;
public class ApplicationException extends JboException { 

 public ApplicationException(Class class1, String string, Object[] objects, Exception[] exceptions) { 

super(class1, string, objects, exceptions); 
 } 
 public ApplicationException(Class class1, String string, Object[] objects, JboException[] jboExceptions) 

 super(class1, string, objects, jboExceptions); 
 } 
 public ApplicationException(ResourceBundleDef resourceBundleDef, String string, Object[] objects) { 
 super(resourceBundleDef, string, objects); 
 } 
 public ApplicationException(Class class1, String string, Object[] objects)
 { 
 super(class1, string, objects); 
 } 
 public ApplicationException(Throwable throwable) 

 super(throwable); 
 }
 public ApplicationException(String string) { super(string); 
 }
 public ApplicationException(String string, String string1, Object[] objects) 

 super(string, string1, objects); 
 }
 }


2- Throw an exception in your code using the new class.
Anywhere in your code you can throw an exception using the following code


throw new ApplicationException("birthday should not later than hire date");

Tuesday 23 April 2013

Adding a javascript to a page in Oracle adf

In your ADF web application you may want to use javaScript functions to perform some actions in client side. You can either add inline JavaScript directly to a page or you can import JavaScript
libraries into a page. When you import libraries, you reduce the page content size, the libraries can be shared across pages, and they can be cached by the browser. You
should import JavaScript libraries whenever possible. Use inline JavaScript only for cases where a small, page-specific script is needed.

How to Use Inline JavaScript

1. Add the MyFaces Trinidad tag library to the root element of the page by adding the code


<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
xmlns:trh="http://myfaces.apache.org/trinidad/html">


2.In the Component Palette, from the Layout panel, in the Core Structure group,drag and drop a Resource onto the page .

3. In the Insert Resource dialog, select javascript from the dropdown menu and click OK.

4. Create the JavaScript on the page within the tag.


<af:resource>
function sayHello()
{
alert("Hello, world!")
}
</af:resource>



5. In the Structure window, right-click the component that will invoke the JavaScript,and choose Insert inside component>ADF Faces>Client Listener.

6. In the Insert Client Listener dialog, in the Method field, enter the JavaScript function name. In the Type field, select the event type that should invoke the
function.

Note : You can add CSS as well in resource tag.

Thats it.now enjoy javascript in ADF.

Now why we write plain javascript , when we have such a well documented library like jquery or EXTJS. see how we can do that.

How to Import JavaScript Libraries

Use the af:resource tag to access a JavaScript library from a page. This tag should appear inside the document tag’s metaContainer facet.

1. Inside document tag, add the code below and replace the /path with the relative path to the directory that holds the JavaScript library. for example ,You can add Jquery and EXTJS .


<af:document>
<f:facet name="metaContainer">
<af:resource source="/path"/>
</facet>
<af:form></af:form>
</af:document>



2. Structure window, right-click the component that will invoke the JavaScript,and choose Insert inside component>ADF Faces>Client Listener.

3. In the Insert Client Listener dialog, in the Method field, enter the fully qualified name of the function. For example, if the showAlert
function was in the MyScripts library, you would enter MyScripts.showAlert . In the Type field, select the event type that should invoke the function.

Adding a portlet into webcenter


If you have portlets based on JSR 168 or JSR 286 and you want to add in webcenter 11g application.Oracle WebCenter Framework enables you to consume a portlet by registering its producer either with an application or with the Resource Palette from where you can add it to any application. After you register the producer, its portlets appear under the registered producer’s name under the Connections node in the Application Resources panel or in the Resource Palette.

For this you need to register WSRP portlet producer .If porlets JSR 168 is WSRP 2.0 enabled then it can be usable in webcenter 11g.

Register a WSRP portlet producer:

-> In the Application Resources panel of the Application Navigator, right-click Connections, choose New Connection and then choose WSRP Producer.
-> Use the Register WSRP Portlet Producer wizard , provide information and register .

Adding Portlets to a Page

Placing a portlet on a WebCenter Portal application page is a simple matter of dragging the portlet from the Application Resources panel or Resource Palette and dropping it on the page.
In the Application Navigator, open the application that contains the page (.jspx file) to which you want to add the portlet.
Under the Connections node in the Application Resources panel of the Application Navigator, or in the Resource Palette:
If the producer is a WSRP producer, expand the WSRP Producer node.
If the producer is a PDK-Java producer, expand the Oracle PDK-Java Producer node.

Expand the node for the portlet producer that contains the portlet to add to the page.Under the selected producer, all portlets contained by that producer are listed.
Drag the portlet from the producer node directly onto the page.You should drag the portlet onto a form on the page.

When you add a portlet to a page, a portlet tag (adfp:portlet or adfph:portlet) is added to the page source. This is the tag that represents the portlet component. This tag includes attributes that you can edit using the Property Inspector, or in the page source, to further control the behavior and appearance of the portlet.

The type of portlet tag used is determined by the following:

->If the project is configured for rich client components alone, the adfp:portlet tag is used.
->If the project is configured for Trinidad components alone, the adfph:portlet tag is used.


<adfp:portlet value="#{bindings.FooterPortlet1_3}"
portletType="/oracle/adf/portlet/SamplePortlets_1257247466260/ap/E2default_ba133935_0124_1000_8008_0a093208e9fc"
id="portlet18" binding="#{backing_home.portlet18}"
displayHeader="false" width="100%"
renderPortletInIFrame="false"
displayScrollBar="false"/>

Monday 22 April 2013

Oracle ADF Interview Questions and Answers/Tips- Part-2


Q : What is Action Listener ?

Ans : An action listener is a class that wants to be notified when a command component
fires an action event. An action listener contains an action listener method that
processes the action event object passed to it by the command component

Q:What are business Component In ADF.Describe them?

Ans: All of these features can be summarized by saying that using ADF Business
Components for your J2EE business service layer makes your life a lot easier. The key
ADF Business Components components that cooperate to provide the business service
implementation are:

 Entity Object
An entity object represents a row in a database table and simplifies modifying its
data by handling all DML operations for you. It can encapsulate business logic for
the row to ensure your business rules are consistently enforced. You associate an
entity object with others to reflect relationships in the underlying database schema
to create a layer of business domain objects to reuse in multiple applications.

 Application Module
An application module is the transactional component that UI clients use to work
with application data. It defines an up datable data model and top-level
procedures and functions (called service methods) related to a logical unit of work
related to an end-user task.

 View Object
A view object represents a SQL query and simplifies working with its results. You
use the full power of the familiar SQL language to join, project, filter, sort, and
aggregate data into exactly the “shape” required by the end-user task at hand. This
includes the ability to link a view object with others to create master/detail
hierarchies of any complexity. When end users modify data in the user interface,
your view objects collaborate with entity objects to consistently validate and save
the changes

Q: What is Top Link?

Ans:
Top Link is an Object-Relational Mapping layer that provides a map between the Java objects that
the model uses and the database that is the source of their data.
By default, a session is created named default. In the following steps, you create a new session

Q:What is Managed Bean?

Ans:JavaBean objects managed by a JSF implementation are called managed beans. A managed bean describes how a bean is created and managed. It has nothing to do with the bean’s functionality.

Managed bean is about how the bean is created and initialized. As you know, jsf uses the lazy initialization model. It means that the bean in the particular scope is created and initialized not at the moment when the scope is started, but on-demand, i.e. when the bean is first time required.

Q :What is Backing Bean?

Ans:Backing beans are JavaBeans components associated with UI components used in a page. Backing-bean management separates the definition of UI component objects from objects that perform application-specific processing and hold data.

Backing bean is about the role a particular managed bean plays. This is a role to be a server-side representation of the components located on the page. Usually, the backing beans have a request scope, but it is not a restriction.
The backing bean defines properties and handling-logics associated with the UI components used on the page. Each backing-bean property is bound to either a component instance or its value. A backing bean also defines a set of methods that perform functions for the component, such as validating the component’s data, handling events that the component fires and performing processing associated with navigation when the component activates.

What is view object?

Ans :A view object is a model object used specifically in the presentation tier. It contains the data that must display in the view layer and the logic to validate user input, handle events, and interact with the business-logic tier. The backing bean is the view object in a JSF-based application. Backing bean and view object are interchangeable terms

Q: Difference between Backing Bean and Managed Bean?

Backing Beans
Managed Beans
A backing bean is any bean that is referenced by a form.
A managed bean is a backing bean that has been registered with JSF (in faces-config.xml) and it automatically created (and optionally initialized) by JSF when it is needed.

The advantage of managed beans is that the JSF framework will automatically create these beans, optionally initialize them with parameters you specify in faces-config.xml,
Backing Beans should be defined only in the request scope
The managed beans that are created by JSF can be stored within the request, session, or application scopes
Q? What do you mean by Bean Scope?
Bean Scope typically holds beans and other objects that need to be available in the different components of a web application.


Q.  What are the different kinds of Bean Scopes in JSF?

JSF supports three Bean Scopes. viz.,

Request Scope: The request scope is short-lived. It starts when an HTTP request is submitted and ends when the response is sent back to the client.

Session Scope: The session scope persists from the time that a session is established until session termination.

Application Scope: The application scope persists for the entire duration of the web application. This scope is shared among all the requests and sessions.

What is the difference between JSP-EL and JSF-EL?

JSP-EL
JSF-EL
In JSP-EL the value expressions are delimited by ${…}.
In JSf-EL the value expressions are delimited by #{…}.
The ${…} delimiter denotes the immediate evaluation of the expressions, at the time that the application server processes the page.
The #{…} delimiter denotes deferred evaluation. With deferred evaluation ,the application server retains the expression and evaluates it whenever a value is needed.

Q:How to declare the page navigation (navigation rules) in faces-config.xml file in ADF 10g
?

Ans: Navigation rules tells JSF implementation which page to send back to the browser after a form has been submitted. We can declare the page navigation as follows:
<naviagation-rule>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>login</from-outcome>
<to-view-id>/welcome.jsp</to-view-id>
</navigation-case>
</naviagation-rule>
This declaration states that the login action navigates to /welcome.jsp, if it occurred inside /index.jsp.
Q: Setting the range of table

Ans : <af:table rows=”#{bindings.LoggedInUserServiceRequests.rangeSize}”…/>

Q : Which component in ADF BC manages transaction ?

A : Application Module, manages transaction.

Q : Can an entity object be based on two Database Objects(tables/views) or two Webservices ?

A : No entity objects will always have one to one relationship with a database object or web service.

Q : Where is that we write business rules/validations in ADF and why?

A : We should ideally be writing validations at Entity Object level, because they provide highest degree of reuse.

Q:What are the JSF life-cycle phases?

Ans:The six phases of the JSF application lifecycle are as follows (note the event processing at each phase):

1. Restore view
2. Apply request values; process events
3. Process validations; process events
4. Update model values; process events
5. Invoke application; process events
6. Render response

Q. Explain briefly the life-cycle phases of JSF?

1. Restore View : A request comes through the FacesServlet controller. The controller examines the request and extracts the view ID, which is determined by the name of the JSP page.

2. Apply request valuesThe purpose of the apply request values phase is for each component to retrieve its current state. The components must first be retrieved or created from the FacesContext object, followed by their values.

3. Process validationsIn this phase, each component will have its values validated against the application’s validation rules.

4. Update model valuesIn this phase JSF updates the actual values of the server-side model ,by updating the properties of your backing beans.

5. Invoke applicationIn this phase the JSF controller invokes the application to handle Form submissions.

6. Render responseIn this phase JSF displays the view with all of its components in their current state.

Q: What is setActionListener?

Ans:SetActionListener – The setActionListener tag is a declarative way to allow an action source ( , , etc.) to set a value before navigation. It is perhaps most useful in conjunction with the “processScope” EL scope provided b ADF Faces, as it makes it possible to pass details from one page to another without writing any Java code. This tag can be used both with ADF Faces commands and JSF standard tags.
Exmaple of this can be as follows. Suppose we have a table “employee”.We want to fetch the salary of an employee of some particular row and want to send this salary in
Next page in process scope or request scope etc.So using this we can do this.
It have two attributes :
From – the source of the value; can be an EL expression or a constant value
To – the target for the value; must be an EL expression
1
<af:setActionListener from="#{row.salary}"
2
to="#{processScope.salary1}"/>
This setActionListener will pick value of salary of that row and store this value into salary1 variable.So anyone can use this salary
As processScope.salary1 . It is very simple to use. And very useful