[ 
https://jira.codehaus.org/browse/DISPL-550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=287921#comment-287921
 ] 

Pietro Martinelli commented on DISPL-550:
-----------------------------------------

What about resolving this issue by changing DisplaytagColumnDecorator.decorate 
method's signature?
Something like

public Object decorate(Object columnValue, Object currentRowObject, PageContext 
pageContext, MediaTypeEnum media) ?

This manner column decorators can access current row object and displaytag 
internal data structure's lifecycle can remain unchanged.

But column decorators are used for totals cell formatting, too: it may look 
ugly pass currentRowObject == null when decorating header/footer cells. An 
alternative solution may consist in adding two methods to 
DisplaytagColumnDecorator interface:
public Object decorate(Object columnValue, Object currentRowObject, PageContext 
pageContext, MediaTypeEnum media)
public Object decorateTotals/Headers(Object columnValue, PageContext 
pageContext, MediaTypeEnum media)

A further alternative would be to pass to decorate method something like 
DecorableCell interface:

public interface DecorableCell {
  Object getCellValue();
  Integer getIterationIndex();
  Object getCurrentRowObject();
  boolean isBodyCell();
}

I've developed a solution hypotesis following the first proposal and it seems 
work fine.
                
> uid always returns the same object in column decorators
> -------------------------------------------------------
>
>                 Key: DISPL-550
>                 URL: https://jira.codehaus.org/browse/DISPL-550
>             Project: DisplayTag
>          Issue Type: Bug
>          Components: Decorators
>    Affects Versions: 1.1.1
>            Reporter: Thomas Queste
>            Priority: Critical
>             Fix For: 1.3
>
>
> Using the uid property of the table tag ("<display:table uid="row">") does 
> not set the current row object in the page scope. It just put the last table 
> row in pageScope.
> Here is an extract of the org.displaytag.tags.TableTag.doIteration() on line 
> 784 :
> if (this.tableIterator.hasNext())
> {
>   Object iteratedObject = this.tableIterator.next();
>   [...]
>   this.pageContext.setAttribute(getUid(), iteratedObject);
> So when the JSP is rendered, the iterator is called. For each table line, the 
> iteratedObject overwrites the previous row. Then, after all row have been 
> read, the column decorators are called. So If a decorator need the current 
> row object, accessed using the provided pageContext, it will only find the 
> last row object.
> The Javadoc for "uid" is : "The object representing the current row is also 
> added to the pageContext under this name and the current row number is added 
> using the key uid_rowNum." So in a column decorator, using pageContext, we 
> can presume to have access to the current row object. This is not the case : 
> the last table row is the only object in pageScope.
> Example of a column decorator which does not have access to its current row 
> object :
> public class WorkflowStepColumnDecorator implements DisplaytagColumnDecorator 
> {
>   public Object decorate(Object columnValue, PageContext pageContext, 
> MediaTypeEnum media) throws DecoratorException {
>     Object row = pageContext.getAttribute("row");
>     // row is not the current row, it is the last table's row
>   }
> }
> JSP code :
> <display:table uid="row" name="users">
>   <display:column decorator="example.MyColumnDecorator "/>
> </display:table>

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
displaytag-devel mailing list
displaytag-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-devel

Reply via email to