Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Custom tag parameter

 
Tha�s Manfrim Firmino
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I created a new taglib and I'm experiencing the problem that I'm sending a object as parameter but in runtime the server complains I'm sending a string. In other words, my taglib doesn't get the object itself but get it as string. I have other taglibs in the same jsp that accept objects as parameter, but this is the only custom taglib I have so it's probably some config problem. See the code below:
jsp:
<c:forEach var="category" items="${category2.resultList}">
<trcat:isEntryFromCategory entry="${category}"
topCategoryId="${WCParam.topCategoryId}">

...
.tld:
<tag>
<name>isEntryFromCategory</name>
<tag-class>com.bms.trade.utils.taglibs.CatentryComparator</tag-class>
<body-content>JSP</body-content>
<description>Verifies if a catentry record belongs to a category (also reffered as catalog)</description>
<attribute>
<name>entry</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<type>com.ibm.commerce.catalog.beans.CatalogEntryDataBean</type>
</attribute>
<attribute>
<name>topCategoryId</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>

taglib class:
public class CatentryComparator extends TagSupport{
private CatalogEntryDataBean entry;
private String topCategoryId;
...
public void setEntry(CatalogEntryDataBean bean) {
entry = bean;
}


public void setTopCategoryId(String string) {
System.out.println("new top category id -> " + string);
topCategoryId = string;
}
...

}
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64829
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You didn't show us the most important part of the equation: how are you using the custom tag on the JSP?

P.S. Please be sure to use UBB code tags when posting code. Please read this for more information.
 
Tha�s Manfrim Firmino
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I don't know what you mean. I posted how I called the tag in the .jsp, the .tld info and the taglib class set for that attribute....

My new tag is

Anyway, I'm inserting a bigger piece of the jsp if it helps. Thanks!

the complete tld is:


[ August 15, 2007: Message edited by: Bear Bibeault ]
[ August 15, 2007: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64829
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Thais Manfrim:
Sorry, I don't know what you mean. I posted how I called the tag in the .jsp


I missed among all the clutter. That's another reason tobe sure to uss the CODE tags. It makes the code stand out as well as preserve its formatting.

Anyway, I'm inserting a bigger piece of the jsp if it helps.


I edited it as all the leading whitespace was making this post unreadable. Please take care when posting code. Removing all that unnecessary whitespace should be easy in any code editor.

<c:forEach var="category" items="${category2.resultList}">


What is the type of the entries in the list returned by category2.resultList?
 
Tha�s Manfrim Firmino
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's returning a com.ibm.commerce.catalog.beans.CatalogEntryDataBean. It's a class from Websphere Commerce.
 
Tha�s Manfrim Firmino
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that with both parameters I'm having problems (the ${WCParam.topCategoryId} evaluates to a string). The system is not considering ${catentry} or ${WCParam.topCategoryId} as a EL expression that needs being evaluated, but it is considering a string literal.
But I now this JSP accept EL because there are other taglibs using it...the problem is related to my taglib, which makes me wonder if there is something else missing in the .tld...
 
Tha�s Manfrim Firmino
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,
I believe I found the problem...the JSP 1.2 doesn't understand EL, so I need to use some additional feature (org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager.evaluate()) in my taglib class to convert the EL expression to the value I need...
Thank you a lot for your help!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic