Sunday, November 8, 2009

One of the Issue I found when I use af:selectOneChoice component that when I want to get the selected value from one of the selectOneChoice attribute from backingbean I found the return value is the index of selected value not the value. (Using HR Schema)assume we have an EmployeesView which has a DepartmentId (as a lookup to DepartmentView) and want to get the the value of selected Department. To solve this problem do this :

Monday, November 2, 2009

Declarative Component is used to build a reusable UI component. You can design your own component using ADF Faces Component. To establish declarative component follow this Steps :

1- Make a new ADF Application.2- In ViewController Project, right click in a web content folder -----> new.3- In Web tier -->JSF--> JSF Declarative Component.4- Enter Declarative component name (e.g. UserInfo) and package.5- Define a tag library name. This tag library name will be the name of the library in which the component will be stored and is the name you will see in the drop down of the component palette when you use the component.There is a facet Definitions - Attributes – Methods. You can define any of thesedepend on your component. Assume we want to make a component for userInformation it contain a three text as name, Address and telephone and one toolbar thatcan manage user to add any button to do any action. In this case we need one facet toadd in the toolbar and three attributes then press Ok.6- Drag and Drop af:panelBox in the page and set its Text to User Information thin in panelBox toolbar facet drag af:facetRef and choose your facet.

7- Drag af:panelFormLayout and insert inside it a three inputText and set its label to Name, Address and Telephone.

8- In the af:inputText (Name) edit the value by choosing Expression Builder then from JSP Object choose attrs then Name.9- Repeat this Steps to af:inputText (Address) and af:inputText (Telephone).10- In ViewController Project right click then choose Project Properties.11- Choose Deployment then press new.

12- In Archive Type choose ADF Library JAR File and Enter the name of Jar as (UserInfoJar) then press Ok.

Sunday, November 1, 2009

One of the af:table feature is a filter over its column to filter its data. You can manipulate with this fields with backingbean, this manipulation can be as :- Execute some code before filtering.- Execute some code after filtering.- Add something to the value you enter to filter before filtering.- Re-execute query....

to do this follow this steps :

1- Bind your table in the backingbean (e.g.in Binding property of table set #{myBackingbean.myTable}).2- In table QueryListener property set its value to#{ myBackingbean.onTableQueryExecuted}3- In your backingbean implement onTableQueryExecuted with:public void onTableQueryExecuted(QueryEvent queryEvent) {// If needed, do something before the table's query is processed

getTableFilterCriteria().clear(); // to clear all filds.getTableFilterCriteria().put("Dname","%N%");// to set value of the filterable field .getTableFilterCriteria().remove("Dname"); // to clear the Dname Filterable text only.getTableFilterCriteria().get("Dname");// to get the value that you enter to filter the table.

On of the major component in tha ADF RC component is a af:selectOneChoice. You can fill this component from backingbean by tow ways:

A) Fill SelectOneChoice Component Programmatically:
1-In the backingbean you can define a variable that hold the selected Value (the value which you are select from selectOneChoice component ) [e.g public String selectedValue;] and make its setter and getter.
2- In the backingbean you can define an array of selectItem that will fill the selectOneChoice(e.g. public SelectItem[] elements = null;) and make its getter and setter.
3- In the getter of selectItem write this code :

where : UCustomerView1Iterator is the Iterator which its data will fill the selectOneChoice (You must add this iterator in the pageDef).

You backingbean it should be like this :-----------------------------------------------

4- In you page Drage a selectOneChoice component and set its value to :
#{yourBean.selectedValue}.
5- Insert f:selectItems inside af:selectOneChoice and set its value to:
#{yourBean.elements}.
--------------------------------------------------------------------------------B) The second way to fill the selectOneChioce is to use af:forEach component and I prefer this way:
1- In the pageDef make a table in the binding section that will fill your selectOneChoice(assume that you make a DeptView1 table in the binding.
2- DeptView1 Table is point to the DeptView1Iterator make its length to -1.
3- Drag and drop a selectOneChoice component and set its value to the attribute in the backingbean.
4- Insert inside selectOneChoice af:forEach component and set Items property to : #{bindings.DeptView1.rangeSet} and set Var property to row.
5- Insert Inside af:forEach af:selectItem set Value Property to #{row.Deptno} this represent the return value of the selectOneChoice if you want the return value be a name of the department set Value Property to #{row.Dname}. Set the Label Property to #{row.Dname}.(Where Deptno and Dname is the attribute of the iterator you use to fill selectOneChoice).
you can download an example from here.

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