Tuesday, January 22, 2013

Programmatic ViewCriteria adf


               
http://docs.oracle.com/cd/B14099_19/web.1012/b14022/oracle/jbo/ViewCriteriaRow.html

     ViewCriteria viewCriteria =
                availableVO.createViewCriteria();

            ViewCriteriaRow viewCriteriaRow =
                viewCriteria.createViewCriteriaRow();

            viewCriteriaRow.setAttribute("VOAttribute", someValue);

            viewCriteria.add(viewCriteriaRow);

            availableVO.applyViewCriteria(viewCriteria);

            availableVO.executeQuery();

set an iterator to particular key adf

Friday, January 18, 2013

Usage of getters in RowImpl of VO to get dynamic generated values


            ExampleAppModuleImpl appModule =
                (ExampleAppModuleImpl)getApplicationModule();
//Get the AppModule and call the required methods.you can pass row values like getId()

Pass an array to Stored Procedure ADF

http://technology.amis.nl/2008/07/16/oracle-jdbc-passing-a-table-of-custom-object-type-to-a-stored-procedure-implementing-efficient-single-round-trip-data-exchange-part-two-of-an-adf-application-on-a-plsql-api/

public String getCount(String[] parmArray, String sqlIn) {
        CallableStatement cs = null;
        Connection conn;
        try {
            cs =
 getDBTransaction().createCallableStatement("begin SP_CREATESQL(?,?,?,?,?);end;",
                                            0);

            conn = getDBTransaction().createStatement(1).getConnection();
         
           Object[] paramArray = new Object[2];
            paramArray[0] = parmArray[0];
            paramArray[1] = parmArray[1];


            ArrayDescriptor arrayDesc =
                ArrayDescriptor.createDescriptor("T_STRINGARRAY", conn);
// T_STRINGARRAY is a  Collection Type defined in the database schema
            ARRAY sqlArray = new ARRAY(arrayDesc, conn, paramArray);
            cs.setArray(1, sqlArray);
            cs.setString(2, sqlIn);
            cs.registerOutParameter(3, Types.VARCHAR);
            cs.registerOutParameter(4, Types.INTEGER);
            cs.registerOutParameter(5, Types.VARCHAR);
            cs.executeUpdate();
            System.out.println("Count " + cs.getString(3));
            System.out.println("Error Code: " + cs.getInt(4));
            System.out.println("Error Message: " + cs.getString(5));
            return cs.getString(3);


        } catch (SQLException e) {
            e.printStackTrace();
            throw new JboException(e);

        } finally {
            if (cs != null) {
                try {
                    cs.close();
                } catch (SQLException e) {
                    System.out.println(e.getMessage());
                    System.out.println(e.getSQLState());
                }
            }
        }
    }


Thursday, January 17, 2013

DynamicVO - Executes DynamicSQL Query

http://mahmoudoracle.blogspot.com/2012/05/adf-dynamic-view-object.html#.UPh5UB3AfSg

Create a VO with- select * from dual

    public void changeDynamicVoQuery(String sqlStatement) {
        ViewObject dynamicVO = this.findViewObject("DynamicVO");
        dynamicVO.remove();
        dynamicVO =
                this.createViewObjectFromQueryStmt("DynamicVO", sqlStatement);
        dynamicVO.executeQuery();
        ViewRowImpl row = (ViewRowImpl)dynamicVO.next();
     
        String count = (String)row.getAttribute(0).toString();
     
        this.setCount(count);

    }

Friday, January 11, 2013

Action Or Action Listener which is called first?

Action Listener then Action

Action Listener is called First

Difference between Action Listener vs Action
AL - return type void A- return type String
AL- accepts parameters A-Doesn't
AL- Can't Navigate to another page A- we can navigate to another page


How to pass a parameter to AL?
http://www.gebs.ro/blog/oracle/adf-send-parameter-to-actionlistener/

Thursday, January 10, 2013

Get TaskFlow's PageFlowScope Parameter in BackingBean


        ADFContext adfCtx = ADFContext.getCurrent();
        Map pageFlowScope = adfCtx.getPageFlowScope();    
        Object val = pageFlowScope.get("attributeName")

Monday, January 7, 2013

Programmatic PPR

//Refresh the component from managed/backing bean AdfFacesContext.getCurrentInstance().addPartialTarget(componentBinding);

Sunday, January 6, 2013

Remote Debugging

Get the current selected value in the backing bean on ValueChangeListener() of SelectOneChoice ADF

 

public void valueChanged(ValueChangeEvent valueChangeEvent) throws Exception{

valueChangeEvent.getComponent().processUpdates(FacesContext.getCurrentInstance());

DCBindingContainer bindings =

(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();

DCIteratorBinding iter =

bindings.findIteratorBinding("CountryTRVOIterator");

CountryTRVORowImpl countryRow= (CountryTRVORowImpl) iter.getCurrentRow();

System.out.println(countryRow.getCountryId());

}

or

public void valueChanged(ValueChangeEvent valueChangeEvent){

OperationBinding oper1 = ADFUtils.findOperation("GetHyperLinkEWP");

if (JSFUtils.resolveExpression("#{bindings.ActionRef<attribute_in_bindings>.selectedValue.attributeValues[1]}").toString().equals("Compliant")) {

oper1.getParamsMap().put("BindLabel", "Approval Report");

System.err.println("Approval Report");

} else {

oper1.getParamsMap().put("BindLabel", "Rejection Report");

System.err.println("Rejection Report");

}

oper1.execute();

}

or

if you are trying to get the new value of the select one choice before the value gets updated to model

public void valueChanged(ValueChangeEvent valueChangeEvent) {

this.setValueToEL("#{bindings.Deptno.inputValue}", valueChangeEvent.getNewValue()); //Updates the model

System.out.println("\n******** Selected Value: "+resolveExpression("#{bindings.Deptno.attributeValue}"));

System.out.println("\n******** Display Value: "+resolveExpression("#{bindings.Deptno.selectedValue ne ' ' ? bindings.Deptno.selectedValue.attributeValues[1] : ''}"));

}