nauke. wrote:
> Hi,
>
> I have a list of names like:
>
> List<String> names;
>
> I want to display this in a table as links on my JSP page.
> I did this:
>
> (JSP file)
>
> <%@ taglib uri="/tags/struts-displaytag" prefix="displaytag" %>
>
> <displaytag:table id="nameslist" name="requestScope.names" class="sr" 
> requestURI="" pagesize="50" decorator="NamesDecorator">
>     <displaytag:setProperty name="paging.banner.placement" 
> value="bottom"/>
>     <displaytag:setProperty name="basic.empty.showtable" value="true"/>
> </displaytag:table>
>
> (NameDecorator class)
>
> package myproject.decorators;
>
> import org.apache.log4j.Logger;
> import org.displaytag.decorator.TableDecorator;
>
> public class NamesDecorator extends TableDecorator {
>    
>     private static final Logger log = 
> Logger.getLogger(NamesDecorator.class);
>    
>     public String displayNames() {
>         log.info <http://log.info>("do i get here?");
>         String name = (String) getCurrentRowObject();
>         StringBuilder link = new StringBuilder();
>         link.append("<a href=\"mylink\">");
>         link.append(name);
>         link.append("</a>");
>         return link.toString();
>     }
> }
>
> The table displays fine but the names are not being generated as links.
> It appears I never even get to the decorator ...
>
> All the examples on the net do it just like this, what am I doing wrong?

Do they?

First of all you need to give the fully qualified class name to the 
decorator attribute of the display:table tag or it won't know where the 
decorator is.

Secondly "... before it starts processing a particular row, it gives the 
object for that row to the decorator, then as the various properties 
*getXXX()* [my emphasis] methods - the decorator will be called first 
and if the decorator doesn't implement the given property, the method 
will be called on the original object in your List."

<http://displaytag.homeip.net/displaytag-examples-1.2/example-decorator.jsp>

Thirdly I think you'll need to explicitly define a column otherwise 
DisplayTag won't know what the column is called:

<display:column property="name" />

Ed!

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
displaytag-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to