aspose file tools*
The moose likes JSP and the fly likes Custom tag parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Custom tag parameter" Watch "Custom tag parameter" New topic
Author

Custom tag parameter

Tha�s Manfrim Firmino
Ranch Hand

Joined: Apr 12, 2004
Posts: 48
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;
}
...

}


Tha�s M. K. M. Firmino
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61421
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Tha�s Manfrim Firmino
Ranch Hand

Joined: Apr 12, 2004
Posts: 48
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

Joined: Jan 10, 2002
Posts: 61421
    
  67

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

Joined: Apr 12, 2004
Posts: 48
It's returning a com.ibm.commerce.catalog.beans.CatalogEntryDataBean. It's a class from Websphere Commerce.
Tha�s Manfrim Firmino
Ranch Hand

Joined: Apr 12, 2004
Posts: 48
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

Joined: Apr 12, 2004
Posts: 48
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Custom tag parameter