Read and respond to this message at: 
https://sourceforge.net/forum/message.php?msg_id=3578601
By: andrewfannin

Export and TableDecorator
I'm not sure if this is an issue or a setting I'm missing somewhere ... any
insight would be appreciated.

displaytag 1.1 :
During an excel table export, I have received java.lang.NoSuchMethodException:
Unknown property 'viewUserId', thrown from PropertyUtils. getProperty() which
is being used by the report generator class () .

The problem is that the TableDecorator for this particular table is not being
used to access the property values, thus, as in this case, an exeception is
thrown because the property 'viewUserId' does not exist on the naked row object.

Doing a little investigation into where the TableDecorator is set leads one to

TableTag.doEndTag():



        // TableDecorator tableDecorator
= DecoratorFactory.loadTableDecorator(this.decoratorName);
        String tableDecoratorName = null;
        Object previousMediaType
= this.pageContext.getAttribute(PAGE_ATTRIBUTE_MEDIA);
        if (MediaTypeEnum.HTML.equals(this.currentMediaType)
            && (previousMediaType == null
|| MediaTypeEnum.HTML.equals(previousMediaType)))
        {
            tableDecoratorName = this.decoratorName;
        }
        else if (!MediaTypeEnum.HTML.equals(this.currentMediaType))
        {
            tableDecoratorName
= this.properties.getExportDecoratorName(this.currentMediaType);
        }
        TableDecorator tableDecorator
= this.properties.getDecoratorFactoryInstance().loadTableDecorator(
            this.pageContext,
            tableDecoratorName);

        if (tableDecorator != null)
        {
            tableDecorator.init(this.pageContext, this.list, this.tableModel);
            this.tableModel.setTableDecorator(tableDecorator);
        }


You can see here that if the "currentMediaType" is HTML  (and the 
"previousMediaType"
is null or HTML)*,
then use the "tableDecoratorName" specified by the tag attribute(decorator="")
in the JSP.

The proper TableDecorator is returned and everything works as expected.

If the "currentMediaType" is Not HTML, for example "excel" or "pdf", then you
can see the "tableDecoratorName" is pulled from, ultimately the 
displaytag.properties
file.

The key getExportDecoratorName(String mediaType) uses, 
ends up being
 
export."mediaType".decorator   , or in this example
export.excel.decorator

or null if this property doesn't exist (as it does not by default).

This is where I have become confused about the programmers intentions.
If, for example, I set the property

export.excel.decorator=com.myco.decorators.UserTableDecorator

all tables attempting to exported in excel would use the same 
UserTableDecorator,
would they not?
Which only works if UserTableDecorator is the only Decorator.

What is export.excel.decorator used for?

If it's used as a runtime replacement for the TableDecorator, obviously it needs
to be by table.

I would prefer to use the <displaytag:column media="" attribute to define export
tables and have it pick up the same TableDecorator used to generate the HTML
view; allowing me to just add new virtual properties to the same TableDecorator.

Any insight would be helpful to where to go with this (i.e. workaround
vs. patch)

Thanks
andrew

______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit: 
https://sourceforge.net/forum/unmonitor.php?forum_id=249317


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
displaytag-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to