Wednesday, July 31, 2013

Auto Suggestion lov ADF




Here is a simple example on how to achieve an Auto Suggestion LOV for input text box or input text box with list of values using Auto Suggest Behavior





  • Add a tree structure(Employees1LookupView1) and action(ExecuteWithParams) to the bindings of the page- these are referenced from the managedBean ->SelectListBean


     <af:inputText
                        label="#{bindings.LastName1.hints.label}"
                        required="#{bindings.LastName1.hints.mandatory}"
                        columns="#{bindings.LastName1.hints.displayWidth}"
                        maximumLength="#{bindings.LastName1.hints.precision}"
                        shortDesc="#{bindings.LastName1.hints.tooltip}"
                        id="it10" autoSubmit="true">
            <f:validator binding="#{bindings.LastName1.validator}"/>
            <af:autoSuggestBehavior maxSuggestedItems="10"
                                    suggestedItems="#{viewScope.SelectListBean.onCitySuggest}"/>
          </af:inputText>

 
 // method in a managed bean

//searchLastName is from the entered text field 

public List onCitySuggest(String searchLastName) {
    ArrayList<SelectItem> selectItems = new ArrayList<SelectItem>();

    System.out.println(searchLastName);
    //get access to the binding context and binding container at runtime
    BindingContext bctx = BindingContext.getCurrent();
    BindingContainer bindings = bctx.getCurrentBindingsEntry();
    //set the bind variable value that is used to filter the View Object
    //query of the suggest list. The View Object instance has a View
    //Criteria assigned
    OperationBinding setVariable = (OperationBinding) bindings.get("ExecuteWithParams");
    setVariable.getParamsMap().put("BindName", searchCityName);
    setVariable.execute();
    //the data in the suggest list is queried by a tree binding.
    JUCtrlHierBinding hierBinding = (JUCtrlHierBinding) bindings.get("Employees1LookupView1");


    //re-query the list based on the new bind variable values
    hierBinding.executeQuery();

    //The rangeSet, the list of queries entries, is of type
    //JUCtrlValueBndingRef.
    List<JUCtrlValueBindingRef> displayDataList = hierBinding.getRangeSet();

    for (JUCtrlValueBindingRef displayData : displayDataList){
    Row rw = displayData.getRow();
    //populate the SelectItem list
    //new SelectItem(DateValue(value set to database), ListValue(list of values displayed));
    selectItems.add(new SelectItem(
    (String)rw.getAttribute("LastName"),
    (String)rw.getAttribute("LastName")));
    }

    return selectItems;
    }


 Query

SELECT Employees1Lookup.EMPLOYEE_ID,
       Employees1Lookup.FIRST_NAME,
       Employees1Lookup.LAST_NAME,
       Employees1Lookup.EMAIL,
       Employees1Lookup.PHONE_NUMBER,
       Employees1Lookup.HIRE_DATE,
       Employees1Lookup.JOB_ID,
       Employees1Lookup.SALARY,
       Employees1Lookup.COMMISSION_PCT,
       Employees1Lookup.MANAGER_ID,
       Employees1Lookup.DEPARTMENT_ID
FROM EMPLOYEES Employees1Lookup

WHERE ( (UPPER(Employees1Lookup.LAST_NAME) LIKE UPPER('%' || :BindName || '%') ) )

click this to download sample

Reference: https://blogs.oracle.com/adf/entry/how_to_create_cascading_depending

http://www.oracle.com/technetwork/developer-tools/jdev/autosuggest-090094.html

Thursday, July 25, 2013

Compare Values using Expression Language ADF

#{row.bindings.ExampleStatus.inputValue!='1' || row.bindings.ExampleStatus.inputValue!='2' || row.bindings.ExampleStatus.inputValue!='3'}

Make a component required depending other attribute value ADF




Code/Syntax:

public void onSelectOneChoice(ValueChangeEvent valueChangeEvent) {

        FacesContext.getCurrentInstance().renderResponse();
     
        if (valueChangeEvent.getNewValue() != null &&
                     valueChangeEvent.getNewValue().toString().equalsIgnoreCase("Yes")) {
        System.out.println("(Boolean.FALSE"+valueChangeEvent.getNewValue());
                         commentsITB.setValue("");
                        commentsITB.setRequired(Boolean.FALSE);
                         AdfFacesContext adfFacesContext = AdfFacesContext.getCurrentInstance();
                         adfFacesContext.addPartialTarget(commentsITB);
                    
                         
                       
                     }
        else {
            System.out.println("On Select no comments Input Text box should be "+valueChangeEvent.getNewValue());
            commentsITB.resetValue();
            commentsITB.setValue("");
            commentsITB.setRequired(Boolean.TRUE);
        }
}

    public void setCommentsITB(RichInputText commentsITB) {
        this.commentsITB = commentsITB;
    }

    public RichInputText getCommentsITB() {
        return commentsITB;
    }


http://andrejusb.blogspot.com/2009/12/conditionally-required-fields-in-oracle.html

attribute Value returns the value (ref number)


Thursday, July 18, 2013

Remove/Delete all rows from Master-Detail ViewObjects ADF

 
*method in AMImpl to delete the rows from view object

public String removeRows(BigDecimal bindId){
        DCInspExampleVOImpl exVO=(DCInspExampleVOImpl) this.getDCInspExampleVO();
        DCInspExampleDetailsVOImpl ex etVO=(DCInspExampleDetailsVOImpl) this.getDCInspExampleDetailsVO();
        exVO.setBindId(bindId);
        exVO.executeQuery();
        while(exVO.hasNext()){
            DCInspExampleVORowImpl exRow=(DCInspExampleVORowImpl) exVO.next();
            exDetVO.setBindEnfId(exRow.getInspectionExampleId());
            exDetVO.executeQuery();
            RowSetIterator row = exDetVO.createRowSetIterator(null);
            while(row.hasNext()){
                row.next();
                 row.removeCurrentRow();
            }
            exVO.removeCurrentRow();
        }
             exVO.closeRowSetIterator();
             row.closeRowSetIterator();

        this.getDCInspExampleVO().getDBTransaction().commit();
        this.getDCInspExampleDetailsVO().getDBTransaction().commit();
        return null;
    }

Tuesday, July 16, 2013

Dialog Listener of a Popup dialog

    public void onExDetailsDialoglistener(DialogEvent dialogEvent) {
        // Add event code here...
        if(dialogEvent.getOutcome()==DialogEvent.Outcome.ok){
            AdfFacesContext.getCurrentInstance().addPartialTarget(exampleDetailTable);
        }
       
    }


    public void onExDocDialogListener(DialogEvent dialogEvent) {
        // Add event code here...
        if(dialogEvent.getOutcome()==DialogEvent.Outcome.ok){
            AdfFacesContext.getCurrentInstance().addPartialTarget(exampleTable);
        }
    }

InvokeAction in Executables of a page bindings

Wednesday, July 3, 2013

Using Variables in PageDef to share between components ADF

Validate Filters for Table ADF

http://www.jobinesh.com/2010/10/enabling-validation-for-table-filters.html



<af:table value="#{bindings.ExampleReviewROVO.collectionModel}"
                          var="row"
                          rows="#{bindings.ExampleReviewROVO.rangeSize}"
                          emptyText="#{bindings.ExampleReviewROVO.viewable ? 'No data to display.' : 'Access Denied.'}"
                          fetchSize="#{bindings.ExampleReviewROVO.rangeSize}"
                          rowBandingInterval="0"
                          filterModel="#{bindings.ExampleReviewROVOQuery.queryDescriptor}"
                          queryListener="#{bindings.IExampleReviewROVOQuery.processQuery}"
                          filterVisible="true" varStatus="vs"
                          selectedRowKeys="#{bindings.ExampleReviewROVO.collectionModel.selectedRow}"
                          selectionListener="#{bindings.ExampleReviewROVO.collectionModel.makeCurrent}"
                          rowSelection="single" id="t1"
                          columnStretching="column:c9" immediate="true">
 <af:column sortProperty="Bin" filterable="true"
                             sortable="true"
                             headerText="#{bindings.ExampleReviewROVO.hints.Bin.label}"
                             id="c6" width="55">
                    <af:inputText value="#{row.bindings.Bin.inputValue}"
                                  label="#{bindings.ExampleReviewROVO.hints.Bin.label}"
                                  required="#{bindings.ExampleReviewROVO.hints.Bin.mandatory}"
                                  columns="#{bindings.ExampleReviewROVO.hints.Bin.displayWidth}"
                                  maximumLength="#{bindings.ExampleReviewROVO.hints.Bin.precision}"
                                  shortDesc="#{bindings.ExampleReviewROVO.hints.Bin.tooltip}"
                                  id="it1">
                      <f:validator binding="#{row.bindings.Bin.validator}"/>
                    </af:inputText>
<f:facet name="filter">
                   
                    <af:inputText value="#{vs.filterCriteria.Bin}" id="id31"
               label=" ">
       <af:convertNumber groupingUsed="false"
                 pattern="#{bindings.ExampleReviewROVO.hints.Bin.format}"/>
                 </af:inputText>
</f:facet>
 </af:column>
</af:table>

Tuesday, July 2, 2013

create javadoc in JDeveloper

http://codigoadf.wordpress.com/2012/10/16/generate-javadoc-in-jdeveloper/
  • Write your javadoc comments for the methods in /** ... */
  • Go to Main Menu->Build->JavaDoc for the JavaClass
  • Go to Main Menu->Navigate->Go to JavaDoc for the Bean