Thursday, February 28, 2013

Generate primary key through Entity

Tuesday, February 12, 2013

Expand all the nodes of a tree table component adf

   // treeTable
 private RichTreeTable treeTable;

    public void setTreeTable(RichTreeTable treeTable) {
        this.treeTable= treeTable;
    }

    public RichTreeTable getTreeTable() {
        return treeTable;
    }


// on Expand nodes
    private void expandTreeTable() {
         if (this.treeTable!= null) {
             disclosedTreeRowKeySet = new RowKeySetImpl();
             CollectionModel model = (CollectionModel)treeTable.getValue();
             JUCtrlHierBinding treeBinding = (JUCtrlHierBinding)model.getWrappedData();
             JUCtrlHierNodeBinding rootNode = treeBinding.getRootNodeBinding();
             disclosedTreeRowKeySet = treeTable.getDisclosedRowKeys();
             if (disclosedTreeRowKeySet == null) {
                 disclosedTreeRowKeySet = new RowKeySetImpl();
             }
             List<JUCtrlHierNodeBinding> firstLevelChildren = rootNode.getChildren();
             for (JUCtrlHierNodeBinding node : firstLevelChildren) {
                 ArrayList list = new ArrayList();
                 list.add(node.getRowKey());
                 disclosedTreeRowKeySet.add(list);
//to expand children nodes
expandTreeChildrenNode(soTreeTableBind, node, list);

             }
             treeTable.setDisclosedRowKeys(disclosedTreeRowKeySet);
         }
     AdfFacesContext.getCurrentInstance().addPartialTarget(treeTable);
}



//to expand children nodes
 private void expandTreeChildrenNode(RichTreeTable rt, JUCtrlHierNodeBinding node, List<Key> parentRowKey) {
        ArrayList children = node.getChildren();
        List<Key> rowKey;
        if (children != null) {
            for (int i = 0; i < children.size(); i++) {
                rowKey = new ArrayList<Key>();
                rowKey.addAll(parentRowKey);
                rowKey.add(((JUCtrlHierNodeBinding)children.get(i)).getRowKey());
                disclosedTreeRowKeySet.add(rowKey);
                if (((JUCtrlHierNodeBinding)(children.get(i))).getChildren() == null)
                    continue;
                expandTreeChildrenNode(rt, (JUCtrlHierNodeBinding)(node.getChildren().get(i)), rowKey);
            }
        }
    }

// on Collapse nodes  

    public String onCollapse() {
        treeTable.getDisclosedRowKeys().clear();
        AdfFacesContext.getCurrentInstance().addPartialTarget(treeTable);
        return null;
    }

// make sure you don't have immediate property set for the treeTable

Thursday, February 7, 2013

CreateWithParams (Set Default Values for newly created row in VO)

Pre-Populate Primary Key Value thru EOImpl when creating a new row in adf


 import oracle.jbo.server.SequenceImpl;
// include create method while creating EOImpl

 protected void create(AttributeList attributeList) {
        super.create(attributeList);
        SequenceImpl sequence=new SequenceImpl("Table_Seq",getDBTransaction());
                setPrimaryKeyId(sequence.getSequenceNumber());
            // This sets the primary key value for the newly created row
    }


One more way to create a sequence using Database Trigger:
http://sathyam-soa.blogspot.com/2012/07/adf-db-sequence-using-db-trigger.html


Another way is to

Have this expression defined at EO Attribute - >

(new oracle.jbo.server.SequenceImpl("Table_SEQ",adf.object.
getDBTransaction())).getSequenceNumber()

https://tompeez.wordpress.com/2011/09/02/using-groovy-expression-to-set-a-primary-key-with-a-sequence-number/

Monday, February 4, 2013

Radio Button Value Change Listener Method for an attribute with (Yes,No LOV)


    public void onRadioSelectValueChange(ValueChangeEvent valueChangeEvent) {
        // Add event code here...

        if (valueChangeEvent.getNewValue() != null &&
             valueChangeEvent.getNewValue().toString().equals("0")) {
 
     //  Enters the loop  if NO is selected    

       }

Type-Casting UIComponent to get properties of it in backing bean

Set disable=true for  UIComponent in backing bean

       {


        RichShowDetailItem component =
            (RichShowDetailItem)JSFUtils.findComponentInRoot("showDetailTab");

        if (displayTab) {
            component.setDisabled(Boolean.FALSE);
        } else {
            component.setDisabled(Boolean.TRUE);

        }
        AdfFacesContext.getCurrentInstance().addPartialTarget(component);

Know Look and Feel for various UIComponents in ADF including their attributes

Panel Form Layout in another Panel Form doesn't work

This works

af:SubForm
      |_PanelStretchLayout(center)
                  |_-PanelGroupLayout(scroll)
                                |_ -PanelBox/Panel Header
                                                |_ Panel Form Layout(can use fieldWidth=66% labelWidth=34%)

Best Practices
http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_42/jdtut_11r2_42.html                                                    

UIComponents Allignment - Margins and Width

margin-left:35px //this property leaves left margin for the component
margin-top:5px // top margin
width:457px; // width 

you can also mention values in %