This content has been marked as final.
Show 5 replies
-
1. Re: link in richfaces tree menu
mawen Apr 18, 2009 9:51 PM (in response to safa)I have the same question. Does anyone have a solution?
thanks,
-
2. Re: link in richfaces tree menu
kubek2k Apr 21, 2009 12:34 PM (in response to safa)<rich:tree ... var="item"> <rich:treeNode> <h:outputLink value="#{item.text}" action="#{item.action}" /> </rich:treeNode> </rich:tree>
and action is a normal jsf action with string outcome
class Item { public String action() { return "massive shouts" } }
i think it should work,
PS: massive shouts is from www.bassdrive.com :)
-
3. Re: link in richfaces tree menu
praveenk20.pk0042598.techmahindra.com Apr 29, 2009 8:36 AM (in response to safa)I have the same problem... can have full code for it.
With bean and as well as link forming in the tree.thanks in advance.
-
4. Re: link in richfaces tree menu
praveenk20.pk0042598.techmahindra.com Apr 30, 2009 12:24 PM (in response to safa)Hi,
After adding the following call with URL link
public class NodeData {
private String nodeText;
private Boolean selected = Boolean.FALSE;
private String url;
public NodeData(String nodeText,String url) {
this.nodeText = nodeText;
this.url= url;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getAction(){
System.out.println(" This is called at least "+this.url);
return this.url;
}
public String getNodeText() {
return nodeText;
}
public void setNodeText(String nodeText) {
this.nodeText = nodeText;
}
public Boolean getSelected() {
return selected;
}
public void setSelected(Boolean selected) {
this.selected = selected;
}
}
it throws following exception :
javax.servlet.ServletException: #{node.url}: javax.el.MethodNotFoundException: /provisioningTreeNew.jsp @37,90 action="#{node.url}": Method not found: com.techm.cisco.jbpm.component.tree.NodeData@36acab.url()
Please let if implemented such example.
Thanks in advance -
5. Re: link in richfaces tree menu
bikramjitsaha Jan 30, 2010 3:55 PM (in response to safa)XHTML :
Add the below tag in your XHTML page
<rich:tree value="#{TreeBean.tree()}" var="node" switchType="client" rowKeyConverter="org.richfaces.TreeRowKeyConverter" nodeSelectListener="#{TreeBean.processNodeSelection}" ajaxSubmitSelection="true" iconExpanded="true">
</rich:tree>
Backing Bean :
public TreeNodeImpl tree(){
TreeNodeImpl<String> data = new TreeNodeImpl<String>();
for (int i = 0; i < components.length; i++) {
TreeNode<String> child = new TreeNodeImpl<String>();
child.setData(components[i]);
data.addChild(components[i], child);
for (int j = 0; j < attributes[i].length; j++) {
TreeNode<String> grandChild = new TreeNodeImpl<String>();
grandChild.setData(attributes[i][j]);
child.addChild(attributes[i][j], grandChild);
}
}
return data;
Add a Listener code in your backing bean which will redirect the page to the desired url:
private Object selectedNodeData;
public String processNodeSelection(NodeSelectedEvent event) {
HtmlTree tree = ((HtmlTree) event.getComponent());
selectedNodeData = tree.getRowData();
if(selectedNodeData.equals("Periods")){
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse();
try {
response.sendRedirect("/login.seam");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "/login.seam";
}
return null;
}
public Object getSelectedNodeData() {
return selectedNodeData;
}