This discussion is archived
2 Replies Latest reply: Feb 5, 2013 10:31 PM by 952174 RSS

Check/Uncheck issue in ADF Tree

952174 Newbie
Currently Being Moderated
Hi,

I am using JDev 11.1.1.5.0. Iam trying to create a ADF Tree from Single VO object with self-reference with check box option. Iam able to create required ADF tree with checkbox option. Some how, unable to provide select-deselect functionality. I mean, if we select any node from the tree, all the sub nodes (till leaf node) should be in select state. Only one node in select state. Rest are not updating.

Tried to find in JDev forum. Could not able to find suitable topic.

Tried to implement the process given in the below URL..But no use !!!
http://andrejusb.blogspot.in/2011/12/adf-tree-how-to-autoselectdeselect.html

Created two transient attributes at VO level
checkboxConfirmed - Boolean..It's value will dependent on checkboxConfirmedStatus attribute, which is of type String.

Finally I am trying to provide technical details what I did so far. It might be lengthy :)

Following is the JSPX page code
===============================
<f:view>
<af:document id="d1">
<af:messages id="m1"/>
<af:form id="f1">
<af:tree value="#{bindings.HierLinks1.treeModel}" var="node"
id="t1"
binding="#{pageFlowScope.mBean.treeProp}">
<f:facet name="nodeStamp">
<af:group id="g1">
<af:selectBooleanCheckbox
label="Label 1"
id="sbc1"
value="#{node.checkboxConfirmed}"
autoSubmit="true"
valueChangeListener="#{pageFlowScope.mBean.checkBoxChange}"
/>
<af:outputText value="#{node.ChildItemId}" id="ot1"/>
</af:group>
</f:facet>
</af:tree>
</af:form>
</af:document>
</f:view>

mBean code goes as follows:
public void checkBoxChange(ValueChangeEvent valueChangeEvent) {
System.out.println("Start checkBoxChange ");
System.out.println("OLD VALUE:"+valueChangeEvent.getOldValue());
System.out.println("NEW VALUE:"+valueChangeEvent.getNewValue());


DCIteratorBinding dcIb = ADFUtils.findIterator("HierLinks1Iterator");
HierLinksVORowImpl parent = (HierLinksVORowImpl)dcIb.getCurrentRow();
RowIterator ri = parent.getLeafHierLinks();
// parent.setAttribute("checkboxConfirmedStatus", "Y");
//RowSetIterator ri = parent.getRowSet();
Boolean check = (Boolean)valueChangeEvent.getNewValue();

while(ri.hasNext()){
LeafHierLinksVORowImpl leaf = (LeafHierLinksVORowImpl)ri.next();
System.out.println("Leaf ChildItemId"+leaf.getAttribute("ChildItemId"));
if (check == true) {
parent.setAttribute("checkboxConfirmedStatus", "Y");
leaf.setAttribute("checkboxConfirmedStatus", "Y");
}
else{
parent.setAttribute("checkboxConfirmedStatus", "Y");
leaf.setAttribute("checkboxConfirmedStatus", "N");
}
System.out.println("Leaf checkboxFlag 222"+leaf.getAttribute("checkboxConfirmed"));
}


/*
     Tried to iterate the tree in another approach.
if( (Boolean)(valueChangeEvent.getOldValue()) != null) {
Boolean check = (Boolean) valueChangeEvent.getNewValue();

RichTree navTree = this.getTreeProp();
CollectionModel model = (CollectionModel)navTree.getValue();
JUCtrlHierBinding treeBinding = (JUCtrlHierBinding)model.getWrappedData();
JUCtrlHierNodeBinding currentSelectedNode = (JUCtrlHierNodeBinding)navTree.getRowData();
List<JUCtrlHierNodeBinding> children = currentSelectedNode.getChildren();
if (children != null) {
for (JUCtrlHierNodeBinding _node : children) {
//Each child search returns node check status
Row nodeRow = _node.getRow();
if (nodeRow != null) {
//_node.setAttribute("checkboxConfirmedStatus",true);
String childId = (String)_node.getAttribute("ChildItemId");
System.out.println("CHILDID"+childId);
String[] atts = (String[]) _node.getAttributeNames();
System.out.println(Arrays.asList(atts));
System.out.println("CHECK"+check );
if(check == true){
_node.setAttribute("checkboxConfirmedStatus","Y");
}
else{
_node.setAttribute("checkboxConfirmedStatus","N");
}
System.out.println("Check Status"+_node.getAttribute("checkboxConfirmed") );
}else{
System.out.println("NODE ROW NULL");
}
} //End of for loop
}
else{
System.out.println("children NULL");
}
}
else{
System.out.println("OLD VALUE NULL");
}

//refreshSelectedRows();
*/
System.out.println("End checkBoxChange ");
}


Iam suspecting, in JSPX page value="#{node.checkboxConfirmed}" is updating the checkbox status.

Could please help me on this?
Thanks in advance,
Samba.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points