You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
| Online: | 15 Members of 9400 |
| Forum: Seam Users |
26. Jan 2009, 11:26 America/New_York | Link |
Hi, I work with jboss seam2.0.3 and richfaces; I have a treemenu:
<rich:tree
style="width:300px"
rendred="true"
nodeSelectListener="#{menu1.processSelection}"
reRender="selectedNode"
switchType="client"
value="#{menu1.treeNode}"
ajaxKeys="#{null}"
ajaxSubmitSelection="true"
var="item">
</rich:tree>
it work very well, but I would like to be redirected to an other page when I click on a tree node, Have any body any idea??
thx
I have the same question. Does anyone have a solution?
thanks,
<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 :)
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.
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
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;
}