seam richface tree

guoweia19850 2010-03-05 11:45:25
大家好,我用richface3.3.2,现在要使用Richface的Tree组件,上网看了一个例子,在Tomcat上可以运行成功,可是放在Seam工程里发布在JBoss上总是报错。Seam和Richface我都已经配置好了没有报错,RIchface的包已经导入到EAR工程里了,可是还是一直报错。说什么PROXY出错,就算我注释了所有的代码还是报错,希望哪位高手可以指点。本人初学,Seam不是太懂。
源代码如下。
tree.seam
<h:panelGrid columns="2" width="100%" columnClasses="col1,col2">

<rich:tree style="width:300px" nodeSelectListener="#{simpleTreeBean.processSelection}"
reRender="selectedNode" ajaxSubmitSelection="true" switchType="client"
value="#{simpleTreeBean.treeNode}" var="item" ajaxKeys="#{null}">
</rich:tree>

<h:outputText escape="false" value="Selected Node: #{simpleTreeBean.nodeTitle}" id="selectedNode" />

</h:panelGrid>


simpleTreeBean.java
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import javax.ejb.Stateless;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;


import org.richfaces.component.UITree;
import org.richfaces.component.html.HtmlTree;
import org.richfaces.event.NodeSelectedEvent;
import org.richfaces.model.TreeNode;
import org.richfaces.model.TreeNodeImpl;


public class SimpleTreeBean {

private TreeNode rootNode = null;
private List<String> selectedNodeChildren = new ArrayList<String>();

private String nodeTitle;
private static final String DATA_PATH = "d:\\1.properties";


private void loadTree() {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
InputStream dataStream = null;
try {
dataStream=new FileInputStream(DATA_PATH);
Properties properties = new Properties();
properties.load(dataStream);

rootNode = new TreeNodeImpl();
TreeNodeImpl child1Node = new TreeNodeImpl();
child1Node.setData("name_1");
rootNode.addChild(1, child1Node);

TreeNodeImpl leaf = new TreeNodeImpl();
leaf.setData("name_1_1");
child1Node.addChild(1, leaf);

leaf = new TreeNodeImpl();
leaf.setData("name_1_2");
child1Node.addChild(2, leaf);


TreeNodeImpl child2Node = new TreeNodeImpl();
child2Node.setData("name_2");
rootNode.addChild(2, child2Node);
TreeNodeImpl child3Node = new TreeNodeImpl();
child3Node.setData("name_3");
rootNode.addChild(3, child3Node);
TreeNodeImpl child4Node = new TreeNodeImpl();
child4Node.setData("name_4");
rootNode.addChild(4, child4Node);
TreeNodeImpl child5Node = new TreeNodeImpl();
child5Node.setData("name_5");
rootNode.addChild(5, child5Node);

} catch (IOException e) {
throw new FacesException(e.getMessage(), e);
} finally {
if (dataStream != null) {
try {
dataStream.close();
} catch (IOException e) {
externalContext.log(e.getMessage(), e);
}
}
}
}

public void processSelection(NodeSelectedEvent event) {
HtmlTree tree = (HtmlTree) event.getComponent();
nodeTitle = (String) tree.getRowData();
selectedNodeChildren.clear();
// TreeNode currentNode = tree.getModelTreeNode(tree.getRowKey());
TreeNode currentNode = tree.getTreeNode(tree.getRowKey());
if (currentNode.isLeaf()){
selectedNodeChildren.add((String)currentNode.getData());
}else
{
Iterator<Map.Entry<Object, TreeNode>> it = currentNode.getChildren();
while (it!=null &&it.hasNext()) {
Map.Entry<Object, TreeNode> entry = it.next();
selectedNodeChildren.add(entry.getValue().getData().toString());
}
}
}

public TreeNode getTreeNode() {
if (rootNode == null) {
loadTree();
}

return rootNode;
}

public void setTreeNode() {

}


public String getNodeTitle() {
return nodeTitle;
}

public void setNodeTitle(String nodeTitle) {
this.nodeTitle = nodeTitle;
}

}

原来是在faces-config.xml中声明ManagesBean的,发布在Tomcat下运行正常。现在放到Seam工程里,发布到JBoss下就总是出错。希望高手可以指点啊。
...全文
144 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xzy_ysx 2010-03-12
  • 打赏
  • 举报
回复
没有异常信息怎么看?
SEAM可以看作是JSF的增强框架,这里应该跟seam没有关系,好像是jboss的问题
guoweia19850 2010-03-05
  • 打赏
  • 举报
回复
关键是不知道如何使用Seam的方式,来运行Richface Tree,希望有高手指点啊。跪谢。

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧