Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Custom tags help

 
sebastian pettersson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to create a custom tag that generates the code for an HTML table in this manner:


Here the tag draws a table of no more than 3 coloumns and as many rows as it takes to include all items. And in each cell of the table the value of currentBean.aProperty is printed.

The tag is defined through a tag file:



So the table generating code works, i've come that far. What doesn't work is the line: "${currentBean.aProperty}" in the jsp code. This Exception is thrown:

javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to find a value for "aProperty" in object of class "java.lang.String" using operator "."


So apparently the container sees currentBean as a String object instead of a bean. If I change the EL expression to "${currentBean}" no exception is thrown and it evaluates to the fully specified classname of currentBean.

Can anyone help to get it working like i want it too with code like the first code snippet?

Thanks in advance,

Sebastian
[ April 10, 2005: Message edited by: sebastian pettersson ]
 
seb petterson
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, so now i realize that the value of the variable "items", as it is declared in the jsp, is receieved as a String in the tag. And the forEach loop is probably just iterating over a set of substring elements separated by some token in the Collection's toString() value. Hence the call throwing the exception looks something like this:

So the question is how to define a custom tag (through a tag file preferably) that takes a bean (or any non-String value) variable.

Any feedback is appreciated, even if you don't know the answer.

Thanks.
 
sebastian pettersson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matter resolved:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic