Posts

Showing posts from October, 2013

Get value instead of index for LOV in ADF

Put a value change listner on LOv and autosubmit=true.  Inside the value change listner put the below code.     public void valueChangeDepartments(ValueChangeEvent valueChangeEvent) {         BindingContext bctx = BindingContext.getCurrent();                BindingContainer bindings = bctx.getCurrentBindingsEntry();                JUCtrlListBinding list=(JUCtrlListBinding) bindings.get("TypeBp");                int index;                index=Integer.parseInt(valueChangeEvent.getNewValue().toString());                list.setSelectedIndex(index);         ...

Put clear table filter in ADF

Image
Create a table based on "EMPLOYEE" table of HR schema. Now put a extra column in the beginning. <af:column rowHeader="true"                   headerText="Clean"                   id="c14" width="40" inlineStyle="text-align:left;">          <af:outputText value="#{vs.index+1}" id="ot20">                   <af:convertNumber groupingUsed="false"/>           </af:outputText>   </af:column> Now when you will run your page you can see that first column is containing row number and a icon in place of filter. Now when you put some text in any filter and press enter you can see that the table is getting filter. When you click on that icon it will clear the input text in filter and show all data. Thats all :) Happy coding.

Calling custom method on clicking search button in af:query panel

Create the query panel and table. Now create a TestBean.java and put the follwing code in your bean. Also don't forget to register your bean in your taskflow with scope backingBean. public void onQueryList(QueryEvent queryEvent) {          QueryDescriptor qdes = queryEvent.getDescriptor();                   System.out.println("NAME "+qdes.getName());                  invokeQueryEventMethodExpression("#{bindings.EmployeesVOCriteriaQuery.processQuery}",queryEvent);      // Do extra coding whatever you want      }      private void invokeQueryEventMethodExpression(                            ...

Putting LOV in ADF Table Filter

Image
Create two View Object "EmployeeVO" and "DepartmentLOV" and shuttle both your VO in application module as shown in figure below. Now create a jspx and then create a read only or editable table by taking EmployeesVO based on your requirement. Now create a SelectOneChoice inside the DepartmentId column as follows: <af:column sortProperty="DepartmentId" filterable="true"                      sortable="true"                      headerText="#{bindings.EmployeesVO1.hints.DepartmentId.label}"                      id="c2" width="140">             <af:selectOneChoice value="#{row.bindings.DepartmentId.inputValue}"                                 label="#{row.bindings.DepartmentId.label}"  ...

Problem with date field format in ADF

Image
When you have some requirement to format the date field in ADF application, You may face the following problem if you have given the format at View object attribute level. The attribute in query panel and result in table will be shown perfectly, but when you click on date picker of table filter of HireDate column and select some date you can see the format is not coming proper.  In order to resolve this you have to give <af:convertDateTime> format for filter facet as "dd/MM/yyyy" as shown below. <af:column sortProperty="HireDate" filterable="true" sortable="true"                        headerText="#{bindings.EmployeesVO1.hints.HireDate.label}"                        id="resId1c5">               <f:facet name="filter">                 <af:inputD...

Calling taskflow programatically in ADF

Image
Scenario: If you have two bounded task flow and on one task flow you want to show the employees data and on other you want to show department data. You have to create two page fragment, one will be putted on employee task flow and other will be on department. Now we are going to call department taskflow from employee taskflow. In order to do this you have to call the following code from your manage bean.         FacesContext facesContext = FacesContext.getCurrentInstance();                     NavigationHandler navHandler =                         facesContext.getApplication().getNavigationHandler();                     navHandler.handleNavigation(facesContext, null, "dept"); That's all :) Happy Coding.

ADFUtils.java For ADF Application

package com.kunal.view; import java.util.ArrayList; import java.util.List; import javax.faces.model.SelectItem; import oracle.adf.model.BindingContext; import oracle.adf.model.binding.DCBindingContainer; import oracle.adf.model.binding.DCIteratorBinding; import oracle.adf.model.binding.DCParameter; import oracle.binding.AttributeBinding; import oracle.binding.BindingContainer; import oracle.binding.ControlBinding; import oracle.jbo.ApplicationModule; import oracle.jbo.Key; import oracle.jbo.Row; public class ADFUtils {   /**    * This method is to get an application module data control by name.    * @param name application module data control name    * @return ApplicationModule    */   public static ApplicationModule getApplicationModuleForDataControl(String name) {     return (ApplicationModule)JSFUtils.resolveExpression("#{data."+name+".dataProvider}");   }   /**    * method...

JSFUtils.java for ADF Application

import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.MissingResourceException; import java.util.ResourceBundle; import javax.el.ELContext; import javax.el.ExpressionFactory; import javax.el.MethodExpression; import javax.el.ValueExpression; import javax.faces.application.Application; import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; import javax.faces.component.UIViewRoot; import javax.faces.context.ExternalContext; import javax.faces.context.FacesContext; import javax.servlet.http.HttpServletRequest; public class JSFUtils {   private static final String MISSING_RESOURCE = "Missing resource: ";   /**    * Method for taking a reference to a JSF binding expression and returning    */   public static Object resolveExpression(String expression)   {     FacesContext facesContext = getFacesContext();     Application app = face...

Error Message Going Behind Popup in ADF

Image
Scenario: When you have a Popup to edit the employee record. Now you have putted some validation like if salary is less than 1000 then you want to show some error message to user from your bean. The code of the validation on button click that I have written is as follows:     public void validateSalary(ActionEvent actionEvent) {         DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();          DCIteratorBinding iter = bindings.findIteratorBinding("EmployeesVO1Iterator");          if(((oracle.jbo.domain.Number)iter.getCurrentRow().getAttribute("Salary")).intValue()<1000){              FacesContext ctx = FacesContext.getCurrentInstance();              FacesMessage fm =                new FacesMessage(FacesMessage.SEVERITY_ERR...

Calling javaScript method with and without parameter from bean in ADF

Put your javascript method in jspx as follows: In my example I am calling this javascript from value change listner of one checkbox. This javascript method is setting focus in a input text field whose id is "it25" when checkbox is checked. "pt1" is the id of page template if you have otherwise you can remove this.      <f:facet name="metaContainer">         <af:resource type="javascript">              function show(id){       if(id=="pt1:sbc6"){     var comp=AdfPage.PAGE.findComponent("pt1:it25");     comp.focus();       } }         </af:resource>       </f:facet> We need to write the following code in value change listner of bean. public void setFocusOnText(ValueChangeEvent vce)       {            boolean selectedValue = (Boole...