Thursday, July 4, 2019

Steps to create a new project/module

How to create a new project/Module
-------------------------------------
1. create a new ADF Application

  1.1> New-->Applications>Fusion adf applications
2. create AM
3. copy source Amimpl file
4. create MyPagePhaseListener in ViewController(com.view.listeners)
5. adfs-settings.xml --> META-INF register the MyPagePhaseListener
6. DemoPhaseListener(com.view.listeners)
7. WEB-INF --> faces-config.xml --> register DemoPhaseListener

8. create --> viewcontroller--> create new ADF skin --> skin1.css -- copy this source from inv
9. copy all pageflow,commoncode,reusablecode under viewcontroller

10. then copy viewCOntroller-->public_html copy all these images and javascript

11. need to register pageflowscope class at adfc-config.xml

12.select create ADF PageTemplate instead of page--> pagetemplate_new.jspx and copy template source code
13. Create backing bean class for the page template and copy source code

14. copy buttontemplate.jar,commoncomponent.jar and change.csv file

15. Need to add jar at viewcontroller--> projectproperties--> libraries and classpath

16. Class path need to change at Project Properties and Appliaction Properties.
selevt ViewController projectproperties -->
D:\Naren\gitsrc\GST_root\GST\src
remove GST
D:\Naren\gitsrc\GST_root\src
/
appliation properties
D:\Naren\gitsrc\GST_root\GST\src

--depoyment--> weblogic --> 
select only
Use the existing settings in Weblogic-application.xml

un select remaining things because of server deployment
/

for Model project properties
D:\Naren\gitsrc\GST_root\GST\Model\classes
D:\Naren\gitsrc\GST_root\Model\classes



Monday, June 24, 2019

creating a viewcriteria with in operator programatically

    public void applyInClassGRN(String values) {
        DCBindingContainer dcb = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
        AppModuleAMImpl am = (AppModuleAMImpl)dcb.getDataControl().getApplicationModule();
        DCIteratorBinding dcibHdr = dcb.findIteratorBinding("PiGrnDtlCostingRef1Iterator");
        ViewObjectImpl voHdr = (ViewObjectImpl)dcibHdr.getViewObject();
        ViewCriteria departmentsCriteria = voHdr.createViewCriteria();
        departmentsCriteria.setName("GrnCosting");
        String inClause = "IN (" + values + ")";

        ViewCriteriaRow criteriaRow = departmentsCriteria.createViewCriteriaRow();
        criteriaRow.setAttribute(PiGrnDtlCostingRefVORowImpl.GRNCNTRLNO, inClause);
        System.out.println("grn Control in apply clause " + PiGrnDtlCostingRe

fVORowImpl.GRNCNTRLNO + "     " +
                           "Parameter cntrl no " + inClause);
        departmentsCriteria.addElement(criteriaRow);
        voHdr.applyViewCriteria(departmentsCriteria, true);
        String query = voHdr.getQuery();
        System.out.println("Query is " + query);
        voHdr.executeQuery();

        // return voHdr.getRowCount();
        AdfFacesContext.getCurrentInstance().addPartialTarget(t3);
        System.out.println("Number of Products in Grn tab " + voHdr.getRowCount());

    }

Tuesday, April 16, 2019

Disable future Date on ADF “inputDate” Component

http://www.adftutorials.com/disable-future-date-on-adf-inputdate-component.html


Sometimes we need to disable future date on ADF inputDate Component so that, a user is unable to select date after the current date.
For this purpose we can use ADF inputDate component MaxValue property. Here’s a small step by step tutorial to achieve this requirement.
Step1:- drag-drop ADF inputDate component on jspx page from component palette.
Step2:- create following method on backing bean class which return oracle.jbo.domain.Date type  currentDate.

Step3:- select inputDate component on jspx page and go to property inspector  MaxValue select Expression Builder select currentDate function.

1
Now when you’ll run the program, you be able to see that the  future date is disabled. User will be able to select the dates  before the current date.
2

If user manually enters the date, it’ll validate the date and will display a validation message.
3

Wednesday, March 13, 2019

lock

    public void lock() {
        try {
            super.lock();
        } catch (oracle.jbo.RowInconsistentException e) {
            if (e.getErrorCode().equals("25014")) {
                super.lock();
            } else
                throw e;
        }
    }

Monday, February 18, 2019

Getting selected value (not index) & display value of select one choice programmatically in ADF

Hello All,
This post is about a common requirement of getting selected value & display value of af:selectOneChoice in the managed bean
normally when we try to get selected value of  selectOneChoice in the managed bean (in ValueChange/ Validator or using binding) it returns the index of that row
so there is a little piece of code using that we can get selected value of choice component


    • I have used Departments table of HR Schema in the sample and created a lov on a transient field


    • Now dropped that ViewObject on the page as a table


    • Created a value change listener in managed bean fro DeptIdTrans but it returns the index of the selected value


    • Then i googled about it and used this method to solve my headache, try to get attributeValue instead of inputValue, see the code written in valueChaneListener in managed bean
/**Value Change Listener of DeptIdTrans (to get selected and display value)
     * @param vce
     */
    public void deptIdVCE(ValueChangeEvent vce) {
        System.out.println("New Value is-" + vce.getNewValue());
        if (vce.getNewValue() != null) {
            this.setvalueToExpression("#{row.bindings.DeptIdTrans.inputValue}",
                                      vce.getNewValue()); //Updating Model Values
            Integer selectedCode =
                Integer.parseInt(this.getValueFrmExpression("#{row.bindings.DeptIdTrans.attributeValue}").toString());

System.out.println("******** Selected Value in List***** " + selectedCode);
System.out.println("*******Display Value in List ****" +
getValueFrmExpression("#{row.bindings.DeptIdTrans.selectedValue.attributeValues[1]}"));

        }
    }


  • There is two methods to set and get value in expression (EL)

 /**Method to set value in Expression (EL)
     * @param el
     * @param val
     */
    public void setvalueToExpression(String el, Object val) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ELContext elContext = facesContext.getELContext();
        ExpressionFactory expressionFactory = facesContext.getApplication().getExpressionFactory();
        ValueExpression exp = expressionFactory.createValueExpression(elContext, el, Object.class);
        exp.setValue(elContext, val);
    }

    /**Method to get value from Expression (EL)
 * @param data
 * @return
 */
    public String getValueFrmExpression(String data) {
FacesContext fc = FacesContext.getCurrentInstance();
Application app = fc.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = fc.getELContext();
ValueExpression valueExp = elFactory.createValueExpression(elContext, data, Object.class);
String Message = null;
Object obj = valueExp.getValue(elContext);
        if (obj != null) {
Message = obj.toString();
        }
        return Message;
    }



  • Again run the page and select any value in selectOneChoice (LOV) and see the result
Getting selected value

Tuesday, February 12, 2019

populate data into af:table with createrowsetiterator

        ViewObject vo = CommonCode.getViewObjectByIteratorName("PosCustomerInfoVuVORef1Iterator");
        RowSetIterator iter =  vo.createRowSetIterator(null);
       
        DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
        DCIteratorBinding itr = bindings.findIteratorBinding("PiCustOfferDtlVO2Iterator");
        ViewObject voc = itr.getViewObject();
       
         while(iter.hasNext()){
             Row rw = iter.next();
             String isSelected = (String)rw.getAttribute("TSelectCust");
             BigDecimal custid = (BigDecimal)rw.getAttribute("CustId");
             String custcode = (String)rw.getAttribute("CustCode");
             if(isSelected!=null && "Y".equals(isSelected)){
                if(custid!=null){
                    Row rw1 = voc.createRow();
                    System.out.println("custid *****"+custid);
                    rw1.setAttribute("CustId", custid);
                    rw1.setAttribute("CustCode", custcode);
                    rw1.setAttribute("CustOfferPromoCode", generatePromoCode());
                    System.out.println("custid ***** CustOfferPromoCode "+ rw1.getAttribute("CustOfferPromoCode"));
                   
                    voc.insertRow(rw1);
                }
             } /* else{
                 CommonCode.errmsg("Please Select Categories", null);
             }  */
         
         }
        iter.closeRowSetIterator();

viewcriteria applying for VO

        ViewObject vo= ReusableMethodsClass.getAM().findViewObject("PosCustomerInfoVuVORef1");
        DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
        DCIteratorBinding dcItteratorBindings = bindings.findIteratorBinding("PosCustomerInfoVuVORef1Iterator");
        // Get an object representing the table and what may be selected within it
        ViewObjectImpl voi = (ViewObjectImpl)dcItteratorBindings.getViewObject();
        ViewCriteria vc = voi.getViewCriteria("PosCustomerInfoVuVORefCriteriaCustType");
        voi.applyViewCriteria(vc);
        voi.setNamedWhereClauseParam("pcompcust", compcode);
        voi.setNamedWhereClauseParam("pcusttype", "N");
        vo.executeQuery();
        System.out.println("no of rows vo.getFetchedRowCount() "+vo.getFetchedRowCount());