Passing tree info
jeronimo.azevedo Oct 15, 2008 10:59 AMHi,
I have tree and on the last leaf I have a context menu. I need to pass the node value to my Bean so that I can used in a database query. I have tried actionParameter but no success
<rich:treeNodesAdaptor var="dslam" nodes="#{switch.dslams}">
<rich:treeNode id="dslam">
<h:commandLink id="caption" value="#{dslam.name}" />
<rich:contextMenu id ="contextmenu" event="oncontextmenu" attachTo="dslam" submitMode="ajax">
<rich:menuItem submitMode="ajax" value="Audit" ajaxSingle="true" action="#{simpleDslamTree.audit}" id="audit">
<a4j:actionparam value="{dslam}" assignTo="#{simpleDslamTree.selectedDslam}" />
</rich:menuItem>
<rich:menuItem value="Delete" onclick="" id="delete"/>
</rich:contextMenu>
</rich:treeNode>
</rich:treeNodesAdaptor>
My SimpleDslamTree bean code
@Name("simpleDslamTree")
@Scope(ScopeType.CONVERSATION)
public class SimpleDslamTree {
@In
private EntityManager entityManager;
@Logger
private Log log;
@DataModel
private List<Central> rootNode = null;
private Dslam dslam;
private void loadTree() {
rootNode = entityManager.createQuery("select c from Central c order by c.id").getResultList();
}
public List<Central> getTreeNode() {
if (rootNode == null) {
loadTree();
}
return rootNode;
}
public void setTreeNode(List<Central> rootNode) {
this.rootNode = rootNode;
}
public void audit(ActionEvent event) {
UIMenuItem tree = (UIMenuItem)event.getComponent();
log.info("Node: "+event.getComponent());
log.info("ActionEvent Running Audit on ...");
}
public void audit() {
log.info("Get Running Audit on ...");
log.info("Dslam: "+ dslam);
}
public void process(NodeSelectedEvent event) {
log.info(event.getComponent());
}
public Dslam getSelectedDslam() {
log.info("GET Dslam: "+ dslam);
return dslam;
}
public void SelectedDslam(Dslam dslam) {
log.info("SET Dslam: "+ dslam);
this.dslam = dslam;
}
}
Any idea how I could do it?
Thanks
Jeornimo