views:

679

answers:

3

I have a decorator specified on a displaytag table that I need to pass parameters to. The decorator adds an id attribute to the row. Currently the values I require are hardcoded.

The parameters I need are:

  • The name of the property to use as id value
  • An id prefix (usually the property used is a number and IE doesn't like ids starting with numbers)

Looking through the javadocs for displaytag, it looks like I can set a property (<displaytag:setProperty>), but there doesn't seem to be a way for me to return a general property.

A: 

Maybe you can provide a little bit more of info? Show us your decorator implementation pls.

If I got you right: You need the id of the iterated property? If you implement the

DisplaytagColumnDecorator

Interface, you can access the iterated property by

decorate(java.lang.Object columnValue, javax.servlet.jsp.PageContext pageContext, MediaTypeEnum media) 

where columValue is your property object for each row.

asrijaal
no, I want to add the id attribute to each tr that is generated by displaytag. The TableDecorator interface has a getRowId() method which does what I want, but I don't know how to pass parameters from the jsp to the decorator
Chris Gow
+1  A: 

Decorators have access to the PageContext. You can pass parameters as its attributes (for example, using <c:set .../>).

axtavt
Nice. Used it to use the same wrapper for different language in the same JSP. <c:set var="lang" value="en"/> <displaytag decorator="MarketingFileTypeWrapper" ...> <c:set var="lang" value="fr"/> <displaytag decorator="MarketingFileTypeWrapper" ...>
lemotdit
A: 

hi chris, did you find a solution ? i would like to do the same thing, pass parameters from my jsp to my decorator class.

Trickle
the answer by @axtavt was the approach I used
Chris Gow