Em Mon, 02 Mar 2009 17:19:03 -0300, Jorge Merlino
<jorge.merl...@ipcontact.com.uy> escreveu:
I'm trying use the tapestry tree component found in
http://wiki.apache.org/tapestry/Tapestry5TreeComponent
but I'm stuck with a very strange exception which is this:
By the way, that wiki page does not follow the Tapestry best practices
about two issues:
1) JavaScript: intead of using <script> tags in components, you should use
RenderSupport.
http://wiki.apache.org/tapestry/Tapestry5AndJavaScriptExplained couldn't
explain it better.
2) Programatically generating HTML in a component: you should
MarkupWriter.writeRaw() just when element() is not enough (it it is enough
99.9999% of the time). element() guaranties that you generate valid markup.
Short and simple example:
@BeforeRenderTemplate
public boolean render(MarkupWriter writer) {
if (message != null && message.trim().length() > 0) {
writer.element("div", "class", "t-crud-message"); // <div
class="t-crud-message">
writer.element("p"); // <p>
writer.write(message); // message
writer.end(); // </p>
writer.end(); // </div>
}
return false;
}
java.lang.ClassCastException:
uy.com.ipcontact.webjastconf.components.TreeNode cannot be cast to
uy.com.ipcontact.webjastconf.components.TreeNode
Java is trying to cast an object to its same class and failing to do so!
This works if I create the TreeNode object
in the tapestry page class but does not If I create the TreeNode objects
in another class and return them to
the page class via a procedure return value.
Here is some more context for the exception if it helps.
Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException:
Failure reading parameter 'source' of component Index:tree_0:
uy.com.ipcontact.webjastconf.components.TreeNo
de cannot be cast to uy.com.ipcontact.webjastconf.components.TreeNode
[at context:Index.tml, line 3, column 73]
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:932)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$200(ComponentPageElementImpl.java:50)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$13.render(ComponentPageElementImpl.java:499)
at
org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
... 64 more
Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException:
Failure reading parameter 'source' of component Index:tree_0:
uy.com.ipcontact.webjastconf.components.TreeNo
de cannot be cast to uy.com.ipcontact.webjastconf.components.TreeNode
[at context:Index.tml, line 3, column 73]
at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.readParameter(InternalComponentResourcesImpl.java:290)
at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.readParameter(InternalComponentResourcesImpl.java:315)
at
uy.com.ipcontact.webjastconf.components.Tree._$read_parameter_source(Tree.java)
at
uy.com.ipcontact.webjastconf.components.Tree.setupRender(Tree.java:55)
at uy.com.ipcontact.webjastconf.components.Tree.setupRender(Tree.java)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$13$1.run(ComponentPageElementImpl.java:495)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:917)
... 67 more
Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException:
uy.com.ipcontact.webjastconf.components.TreeNode cannot be cast to
uy.com.ipcontact.webjastconf.components.T
reeNode [at context:Index.tml, line 3, column 73]
at
org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:57)
at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.readParameter(InternalComponentResourcesImpl.java:284)
... 73 more
Caused by: java.lang.ClassCastException:
uy.com.ipcontact.webjastconf.components.TreeNode cannot be cast to
uy.com.ipcontact.webjastconf.components.TreeNode
at uy.com.ipcontact.webjastconf.pages.Index.getTreeNodes(Index.java:46)
at $PropertyConduit_11fc8c4abe7.get($PropertyConduit_11fc8c4abe7.java)
at
org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:53)
... 74 more
Thank you for your time
Best regards
Jorge
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
Consultor, desenvolvedor e instrutor em Java
http://www.arsmachina.com.br/thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org