All decorators have a getCurrentRowObject() method that will return the object 
that makes up each row. Cast the result of the method to whatever Class it 
really is, and then call methods on it.

-----Original Message-----
From: RogerV [mailto:[email protected]] 
Sent: Thursday, March 31, 2011 4:14 AM
To: [email protected]
Subject: Re: [displaytag-user] DisplaytagColumnDecorator returns wrong row 
object


Sorry,

The interface I was using to post through Nabble removed a chunk of my message 
- I'll try again

I'm using Struts 2.2.1 with DisplayTag 1.2. I've got a simple jsp page that 
contains -

    <display:table name="${functions}" uid="row" pagesize="20"
requestURI="">
    <display:setProperty name="paging.banner.placement" value="bottom" />
    <display:column property="description"/>
    <display:column title=""  
decorator="com.myApp.genesis.admin.tableDecorators.EditOrDeleteDecorator"/>
    </display:table>

and my decorator is as follows;

    public class EditOrDeleteDecorator implements DisplaytagColumnDecorator {

        @Override
        public Object decorate(Object arg0, PageContext context, MediaTypeEnum
arg2)
                        throws DecoratorException {
                
                IdsFunction function = (IdsFunction) 
context.getAttribute("row");
                
                return "&lt;a href=\"edit-function?id=" + function.getId() 
"\"&gt;Edit&lt;/a&gt; | "
                + "&lt;a href=\"delete-function?id=" + function.getId() 
"\"&gt;Delete&lt;/a&gt; | "
                + "&lt;a href=\"list-service-definitions?id=" + 
function.getId() "\"&gt;Definitions&lt;/a&gt;";

        }

    }

Debugging the decorator shows that context.getAttribute("row") does indeed 
return an IdsFunction object, but on each iteration it's always the same 
IdsFunction object and it's the last IdsFunction instance in the list. I was 
expecting to be handed each row object in turn.

The rendered JSP displays the row objects correctly, with each member of the 
list displayed but obviously the URL's all point to the last member in the list.

What am I missing?

Regards


--
View this message in context: 
http://old.nabble.com/DisplaytagColumnDecorator-returns-wrong-row-object-tp31275210p31284166.html
Sent from the DisplayTag - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
displaytag-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user

------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
displaytag-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to