[
http://jira.codehaus.org/browse/DISPL-302?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
[EMAIL PROTECTED] deleted DISPL-302:
------------------------------------
> Adding the ability of a TableDecorator to decorate all cells in a row using a
> single method
> -------------------------------------------------------------------------------------------
>
> Key: DISPL-302
> URL: http://jira.codehaus.org/browse/DISPL-302
> Project: DisplayTag
> Issue Type: Improvement
> Components: Decorators
> Affects Versions: 1.1
> Reporter: Eric Taix
> Fix For: TBD
>
> Attachments: TableDecorator.java
>
>
> I wanted my TableDecorator to be able to decorate all cells in a row in a
> single method (adding the same link for all cells) - I did'nt want to
> override all properties of my bean which is a bad idea because you have to
> change your decorator each time your add (or remove) a property whereas
> So i added 2 methods in TableDecorator:
> public Object startCell(String propertyName)
> public Object endCell(String propertyName)
> By default these methods return null in abstract TableDecorator class.
> And I modified Column model like this :
> public Object getValue(boolean decorated) throws ObjectLookupException,
> DecoratorException
> {
> TableDecorator tableDecorator =
> this.row.getParentTable().getTableDecorator();
> // Patch (Eric Taix): Get the table decorator if exist and get the
> start of cell object
> Object start = "";
> if (tableDecorator != null) {
> if (this.header.getBeanPropertyName() != null) {
> Object objStart =
> tableDecorator.startCell(this.header.getBeanPropertyName());
> start = (objStart != null ? objStart : "");
> }
> }
> Object object = null;
> // a static value has been set?
> if (this.cell.getStaticValue() != null)
> {
> object = this.cell.getStaticValue();
> }
> else if (this.header.getBeanPropertyName() != null)
> {
> // if a decorator has been set, and if decorator has a getter for
> the requested property only, check
> // decorator
> if (decorated
> && this.row.getParentTable().getTableDecorator() != null
> &&
> this.row.getParentTable().getTableDecorator().hasGetterFor(this.header.getBeanPropertyName()))
> {
> object = LookupUtil.getBeanProperty(tableDecorator,
> this.header
> .getBeanPropertyName());
> }
> else
> {
> // else check underlining object
> object = LookupUtil.getBeanProperty(this.row.getObject(),
> this.header.getBeanPropertyName());
> }
> }
> DisplaytagColumnDecorator[] decorators =
> this.header.getColumnDecorators();
> if (decorated)
> {
> for (int j = 0; j < decorators.length; j++)
> {
> object = decorators[j].decorate(object,
> row.getParentTable().getPageContext(), row
> .getParentTable()
> .getMedia());
> }
> }
> if (object == null || "null".equals(object)) //$NON-NLS-1$
> {
> if (!this.header.getShowNulls())
> {
> object = TagConstants.EMPTY_STRING;
> }
> }
> // Patch (Eric Taix) : Get the table decorator if exist and get the
> end of cell object
> Object end = "";
> if (tableDecorator != null) {
> if (this.header.getBeanPropertyName() != null) {
> Object objEnd =
> tableDecorator.endCell(this.header.getBeanPropertyName());
> end = (objEnd != null ? objEnd : "");
> }
> }
> StringBuffer result = new StringBuffer();
> result.append(ObjectUtils.toString(start));
> result.append(ObjectUtils.toString(object));
> result.append(ObjectUtils.toString(end));
> return result;
> }
> I think it's a good improvement, because it give us the ability to decorate
> cells without implementing a getter for each properties.
> In attached files, you'll find TableDecorator and Colum modified classes.
> Hope it help community
--
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
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
displaytag-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-devel