Friday 15 September 2017

JDeveloper 12c Oracle ADF Clear the Selected Value from LOV

LOV Fields are: fnameId and lnameId
Button: Clear
Create Managed Bean and write the following code:

public void clearLOVValues()
{
FacesContext facesContext = FacesContext.getCurrentInstance();
        UIViewRoot root = facesContext.getViewRoot();
        ComponentReference<RichInputListOfValues> richText1  =
        ComponentReference.newUIComponentReference((RichInputListOfValues)root.findComponent("fnameId"));
        RichInputListOfValues FinputText1  = richText1.getComponent();
       
        ComponentReference<RichInputListOfValues> richText2  =
        ComponentReference.newUIComponentReference((RichInputListOfValues)root.findComponent("lnameId"));
        RichInputListOfValues LinputText2  = richText2.getComponent();
             
        FinputText1.setValue("");
        LinputText2.setValue("");
}

Properties for LOV1 and LOV2:
AutoSubmit=True
PartialTrigger to Clear

JDeveloper 12c Oracle ADF Get the selected Value from LOV

LOV Fields are: fnameId and lnameId
Button: Clear
Create Managed Bean and write the following code:

public void showLOVValues()  
{
FacesContext facesContext = FacesContext.getCurrentInstance();
               UIViewRoot root = facesContext.getViewRoot();
               ComponentReference<RichInputListOfValues>
           richText1  = ComponentReference.newUIComponentReference((RichInputListOfValues)root.findComponent("fnameId"));
        RichInputListOfValues FinputText1  = richText1.getComponent();
     
        ComponentReference<RichInputListOfValues> richText2  =
        ComponentReference.newUIComponentReference((RichInputListOfValues)root.findComponent("lnameId"));
        RichInputListOfValues LinputText2  = richText2.getComponent();
     
System.out.println("**** First LOV String is :"+FinputText1.getValue());
        System.out.println("**** Second LOV String is :"+LinputText2.getValue());
}

Properties:
AutoSubmit = True
PartialTrigger = ClearButton for both Lov fields
=============================================================

    public String Findbutton_action() {
        System.out.println("**** Find Button ****");
        System.out.println("GroupCode is :"+getGroupCodeBind().getValue());
        System.out.println("GroupName is :"+getGroupNameBind().getValue());

       /* FacesContext facesContext = FacesContext.getCurrentInstance();
        UIViewRoot root = facesContext.getViewRoot();
        ComponentReference<RichInputListOfValues>
        richText1  = ComponentReference.newUIComponentReference((RichInputListOfValues)findComponent("groupCodeId"));
        RichInputListOfValues GroupCodeStr  = richText1.getComponent();
        ComponentReference<RichInputListOfValues>
        richText2  = ComponentReference.newUIComponentReference((RichInputListOfValues)findComponent("groupNameId"));
        RichInputListOfValues GroupNameStr  = richText2.getComponent();        
        RichInputListOfValues GroupCodeStr1 = (RichInputListOfValues) root.findComponent("groupCodeId");
        //ComponentReference<RichInputListOfValues> richText2  =
        //ComponentReference.newUIComponentReference((RichInputListOfValues)root.findComponent("groupNameId"));
       
        System.out.println("**** First LOV String is :"+GroupCodeStr.getValue());
        System.out.println("**** Second LOV String is :"+GroupNameStr.getValue());
        //System.out.println("**** GroupCodeStr1 LOV String is :"+GroupCodeStr1.getValue().toString());
        */
        return null;
    }

    public String clearButton_action() {
        System.out.println("**** Clear Button ****");
        AppModuleAMImpl am = (AppModuleAMImpl) resolvElDC("AppModuleAMDataControl");
        ViewObject grpSearchVo = am.getGroupSearch1();
        grpSearchVo.executeEmptyRowSet();
        Row row=grpSearchVo.createRow();
        grpSearchVo.insertRow(row);
        grpSearchVo.setCurrentRow(row);
        /* FacesContext facesContext = FacesContext.getCurrentInstance();
        UIViewRoot root = facesContext.getViewRoot();
        ComponentReference<RichInputListOfValues>
        richText1  = ComponentReference.newUIComponentReference((RichInputListOfValues)findComponent("groupCodeId"));
        RichInputListOfValues GroupCodeStr  = richText1.getComponent();
        ComponentReference<RichInputListOfValues>
        richText2  = ComponentReference.newUIComponentReference((RichInputListOfValues)findComponent("groupNameId"));
        RichInputListOfValues GroupNameStr  = richText2.getComponent();        
        //ComponentReference<RichInputListOfValues> richText2  =
        //ComponentReference.newUIComponentReference((RichInputListOfValues)root.findComponent("groupNameId"));
        GroupCodeStr.setValue("");
        GroupNameStr.setValue("");
        System.out.println("**** First LOV String is :"+GroupCodeStr.getValue());
        System.out.println("**** Second LOV String is :"+GroupNameStr.getValue());
*/
        return null;
    }

    public UIComponent findComponent(final String id) {

        FacesContext context = FacesContext.getCurrentInstance();
        UIViewRoot root = context.getViewRoot();
        final UIComponent[] found = new UIComponent[1];

        root.visitTree(new FullVisitContext(context), new VisitCallback() {    
            @Override
            public VisitResult visit(VisitContext context, UIComponent component) {
                if(component.getId().equals(id)){
                    found[0] = component;
                    return VisitResult.COMPLETE;
                }
                return VisitResult.ACCEPT;            
            }
        });
        return found[0];

    }

    public Object resolvElDC(String data) {
            FacesContext fc = FacesContext.getCurrentInstance();
            Application app = fc.getApplication();
            ExpressionFactory elFactory = app.getExpressionFactory();
            ELContext elContext = fc.getELContext();
            ValueExpression valueExp =
                elFactory.createValueExpression(elContext, "#{data." + data + ".dataProvider}", Object.class);
            return valueExp.getValue(elContext);
        }

Thursday 14 September 2017

Oracle ADF Groovy

https://docs.oracle.com/cd/E24001_01/web.1111/b31974/bcadveo.htm#sm0483
Refresh ADF table programmatically

<af:inputText label="Label 1" id="it1" contentStyle="text-

transform:uppercase;"/>

<af:inputText label="Label 1" id="it1" contentStyle="text-

transform:lowercase;"/>

<af:inputText label="Label 1" id="it1" contentStyle="text-

transform:capitalize;"/>
/**
* Gets the attribute value for the calculated attribute OldDepartmentName.
* @return the OldDepartmentName
*/
public String getOldDepartmentName() {
return (String) getAttributeInternal(OLDDEPARTMENTNAME);
}
Groovy: getPostedAttribute(model.EmployeesImpl.SALARY)
Button1 Pressed:
 text2.setValue(text1.getValue().toString());
 ADFFacesContext adffacesContext1=AdfFacesContext.getCurrentInstance();
 adffacesContext1.addPartialTarget(text2);

    public void remove() {
        setDelflag(0);
         super.remove();
    }
    protected void doDML(int operation, TransactionEvent e) {
        if ( operation == DML_DELETE) {
            if(getDelflag()==0) {
                super.doDML(DML_UPDATE, e);
            }
        }
        else if ( operation == DML_INSERT) {
            setDelflag(1);
            super.doDML(operation, e);
        }
        else
        {
            System.out.println("Operation3 value="+operation);
        super.doDML(operation, e);
        }
    }

// In your custom Java entity class
RowSet rs = (RowSet)getProducts();
rs.reset(); // Reset default row set iterator to slot before first row!
while (rs.hasNext()) {
  ProductImpl r = (ProductImpl)rs.next();
  // Do something important with attributes in ea