[jboss-user] [JBoss Seam] - Re: JBoss Seam + Facelets + Richfaces Tree error
kot.filemon
do-not-reply at jboss.com
Mon Mar 19 15:33:49 EDT 2007
I have different error but the component is the same aswell as configuration.
from: http://jboss.com/index.html?module=bb&op=viewtopic&t=104440
"kot.filemon" wrote : Anyone knows what am I doing wrong?
|
| I have one simple stateful bean which passes root node to tree component. When i try to display the page i'm redirected to seam debug page and get following exception
|
|
| | 20:01:59,011 ERROR [STDERR] Mar 19, 2007 8:01:59 PM com.sun.facelets.FaceletViewHandler handleRenderException
| | SEVERE: Error Rendering View[/tree.xhtml]
| | java.lang.ClassCastException: richtest.tree.TreeNodeExample
| | at org.richfaces.component.AbstractTreeDataModel.setWrappedData(AbstractTreeDataModel.java:63)
| | at org.richfaces.component.UITree.createDataModel(UITree.java:477)
| | at org.ajax4jsf.ajax.repeat.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:464)
| | at org.ajax4jsf.ajax.repeat.UIDataAdaptor.setRowKey(UIDataAdaptor.java:280)
| | at org.ajax4jsf.ajax.repeat.UIDataAdaptor.setRowKey(UIDataAdaptor.java:265)
| | at org.richfaces.renderkit.TreeRendererBase.writeContent(TreeRendererBase.java:395)
| | at org.richfaces.renderkit.TreeRendererBase.encodeChildren(TreeRendererBase.java:299)
| | at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:524)
| | at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:244)
| | at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:249)
| | at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:249)
| | at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:573)
| | at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
| | at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:229)
| | at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
| | at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
| | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
| | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| | at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:234)
| | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| | at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
| | at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
| | at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
| | at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
| | at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
| | at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
| | at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
| | at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
| | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| | at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
| | at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
| | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| | at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
| | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
| | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
| | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
| | at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
| | at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
| | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
| | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
| | at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
| | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
| | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
| | at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
| | at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
| | at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
| | at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
| | at java.lang.Thread.run(Thread.java:595)
| |
|
| I checked what is AbstractTreeDataModel.setWrappedData responsilble for:
|
|
| | public final void setWrappedData(Object data) {
| | wrappedData = (TreeNode) data;
| | }
| |
|
| so, I have put a breakpoint there and checked what Object data appear to be. As expected it was my implementation of TreeNode.
|
|
| | package richtest.tree;
| |
| | import java.util.HashMap;
| | import java.util.Iterator;
| | import java.util.Map;
| |
| | import org.richfaces.component.TreeNode;
| |
| | public class TreeNodeExample implements TreeNode {
| |
| | /**
| | *
| | */
| | private static final long serialVersionUID = 1L;
| |
| | private Map<Object, TreeNode> childs;
| |
| | private TreeNode parent;
| |
| | private String name;
| |
| | public TreeNodeExample() {
| | childs = new HashMap<Object, TreeNode>();
| |
| | }
| |
| | public TreeNodeExample(String name) {
| | this();
| | this.name = name;
| |
| | }
| |
| | public TreeNodeExample(String name, TreeNode parent) {
| | this(name);
| | setParent(parent);
| |
| | }
| |
| | public void addChild(Object id, TreeNode child) {
| | getChilds().put(id, child);
| |
| | }
| |
| | public int getChildsSize() {
| | return getChilds().size();
| | }
| |
| | private Map<Object, TreeNode> getChilds() {
| | return this.childs;
| | }
| |
| | public TreeNode getChild(Object id) {
| | return (TreeNode) getChilds().get(id);
| | }
| |
| | public Iterator getChildren() {
| | return getChilds().entrySet().iterator();
| | }
| |
| | public Object getData() {
| |
| | return this;
| | }
| |
| | public TreeNode getParent() {
| | return parent;
| | }
| |
| | public boolean isLeaf() {
| | return getChilds().isEmpty();
| | }
| |
| | public void removeChild(Object id) {
| | TreeNode tmp = getChild(id);
| | tmp.setParent(null);
| | getChilds().remove(id);
| |
| | }
| |
| | public void setData(Object arg0) {
| | // not used
| |
| | }
| |
| | public void setParent(TreeNode parent) {
| | if (parent != null) {
| | TreeNodeExample ex = (TreeNodeExample) parent;
| | parent.addChild(ex.getChildsSize(), this);
| | }
| | this.parent = parent;
| |
| | }
| |
| | public String getName() {
| | return name;
| | }
| |
| | public void setName(String name) {
| | this.name = name;
| | }
| |
| | public String toString() {
| | return name;
| | }
| |
| | }
| |
|
| my page:
|
| | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
| | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| | <div xmlns="http://www.w3.org/1999/xhtml"
| | xmlns:s="http://jboss.com/products/seam/taglib"
| | xmlns:ui="http://java.sun.com/jsf/facelets"
| | xmlns:f="http://java.sun.com/jsf/core"
| | xmlns:h="http://java.sun.com/jsf/html"
| | xmlns:rich="http://richfaces.ajax4jsf.org/rich"
| | xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
| |
| |
| | <ui:composition template="/template.xhtml">
| |
| | <ui:define name="body">
| | <f:view>
| | <h:form>
| | <div>
| |
| | <rich:tree width="300" height="150"
| | value="#{treeExample.data}" var="item" nodeFace="test">
| | <rich:treeNode type="test">
| | <h:outputText value="#{item.name}" />
| | </rich:treeNode>
| | </rich:tree>
| |
| | </div>
| |
| | </h:form>
| | </f:view>
| | </ui:define>
| | </ui:composition>
| |
| | </div>
| |
|
| the template
|
| | <?xml version="1.0" encoding="utf-8"?>
| | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
| | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| | <html xmlns="http://www.w3.org/1999/xhtml"
| | xmlns:ui="http://java.sun.com/jsf/facelets"
| | xmlns:h="http://java.sun.com/jsf/html"
| | xmlns:f="http://java.sun.com/jsf/core"
| | xmlns:rich="http://richfaces.ajax4jsf.org/rich">
| | <head>
| | <meta http-equiv="Content-Type"
| | content="text/html; charset=iso-8859-1" />
| | <meta http-equiv="expires" content="0" />
| | <title>Test</title>
| |
| | <style type="text/css">
| | /* a lot of classes */
| | </style>
| |
| | </head>
| |
| | <body>
| |
| | <h:form>
| | <rich:toolBar itemSeparator="line">
| | <rich:toolBarGroup itemSeparator="grid">
| |
| | <h:commandLink value="simple" action="/slider.seam" />
| | <h:commandLink value="tree" action="/tree.seam" />
| | <h:commandLink value="table" action="/table.seam" />
| | </rich:toolBarGroup>
| |
| | </rich:toolBar>
| | </h:form>
| | <ui:insert name="body">
| | TOPNAV
| | </ui:insert>
| | </body>
| | </html>
| |
| |
|
| and the stateful bean
|
|
| | package richtest.tree;
| |
| | import javax.ejb.Remove;
| | import javax.ejb.Stateful;
| |
| | import org.jboss.seam.annotations.Destroy;
| | import org.jboss.seam.annotations.Name;
| |
| | @Stateful
| | @Name("treeExample")
| | public class TreeManager implements ITreeManager {
| |
| | private TreeNodeExample root;
| |
| | @Remove
| | @Destroy
| | public void destroy() {
| |
| | }
| |
| | public Object getData() {
| | if (root == null)
| | init();
| |
| | return root;
| | }
| |
| | private void init() {
| |
| | this.root = new TreeNodeExample("root");
| | for (int i = 0; i < 6; i++) {
| | TreeNodeExample item = new TreeNodeExample("item" + i, root);
| | }
| |
| |
| | }
| | }
| |
| |
| |
|
| with it's inteface
|
|
| | package richtest.tree;
| |
| | import javax.ejb.Local;
| |
| |
| | @Local
| | public interface ITreeManager {
| |
| | public void destroy();
| |
| |
| |
| | public Object getData();
| | }
| |
| |
|
| please, help ;)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4029461#4029461
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4029461
More information about the jboss-user
mailing list