• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting error accessing attributes in custom taglib

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using a custom taglib with an attribute. When I try to refer to the attribute in the tag, then I get an error of type:

org.apache.jasper.JasperException: jsp.error.beans.property.conversion
org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:885)
org.apache.jsp.content.includes.treetest_jsp._jspx_meth_odin_showNavTree_0(treetest_jsp.java:148)
org.apache.jsp.content.includes.treetest_jsp._jspService(treetest_jsp.java:114)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


Please help Below is some pertinent code info. Let me know if you need more.

Thanks,
Sean

--- from jsp ---
<jsp:useBean id="u" class="com.renewdata.odin.user.OdinUserBean" scope="request">
<jsp:setProperty name="u" property="email" value="tempemail" />
<jsp:setProperty name="u" property="name" value="tempname" />
</jsp:useBean>
<jsp:useBean id="bc" class="com.renewdata.odin.nav.Breadcrumb" scope="request" />

<tr><td height='100%' valign=top width=50% nowrap style='overflow:auto;'>
<odin:showNavTree user="u"/>
</td></tr>
--- end jsp ---

--- start tld ---
<tag>
<name>showNavTree</name>
<tagclass>com.company.odin.nav.ShowNavTreeTag</tagclass>
<bodycontent>empty</bodycontent>
<info>
Given the information included in the attributes, this tag builds
the navigation tree.
</info>

<attribute>
<name>breadcrumb</name>
<type>com.company.odin.nav.Breadcrumb</type>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>

<attribute>
<name>user</name>
<type>com.company.odin.user.OdinUserBean</type>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>

</tag>

--- end tld ---

--- excerpt from handler ---
public class ShowNavTreeTag extends TagSupport {
private Log avsLog;

private Breadcrumb breadcrumb;
private OdinUserBean user;


public Breadcrumb getBreadcrumb() {
return breadcrumb;
}
public void setBreadcrumb(Breadcrumb breadcrumb) {
this.breadcrumb = breadcrumb;
}
public OdinUserBean getUser() {
return user;
}
public void setUser(OdinUserBean user) {
this.user = user;
}
--- end handler ---
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could be mistaken here, but I beleive what is happening is your tag handler is attempting to covert the string "u" to type OdinUserBean. I don't beleive that you can refer to the bean you were using in that manner. Again, I must warn that I could be wrong on that.

EDIT: Note, you can try to access that user bean in the tag directly, based on the value of the user att. For instance, change the user attribute type to String and retreive it from the request.
[ October 25, 2004: Message edited by: Ryan Tyer ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Sean S.",

We're pleased to have you here with us in the JSP forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
Sean Stephens
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry bout that. Name taken care of.
 
Sean Stephens
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as passing an attribute in a tag that is other than a String, the taglib tutorials I've looked at appear to say you can do that... but wello, its not like I've been successful with it either I can't figure out why they would let me define an attribute in the tld with a class other than String if I couldn't pass it as such in the tag.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

<odin:showNavTree user="u"/>



The above code is passing the String "u" as the attribute. If you want to pass the object, you need something like:

 
Sean Stephens
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That was it!

Thanks Bear!
reply
    Bookmark Topic Watch Topic
  • New Topic