uid always returns the same object in column decorators
-------------------------------------------------------
Key: DISPL-550
URL: http://jira.codehaus.org/browse/DISPL-550
Project: DisplayTag
Issue Type: Bug
Components: Decorators
Affects Versions: 1.1.1
Reporter: Thomas Queste
Priority: Blocker
Fix For: 1.2
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 contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
displaytag-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-devel