Huh...funny you mention this.

I just found the same thing, but I identified a solution, at least for us.

I had a JSP with several tables, and one implemented a TableDecorator. I kept 
getting an error trying to resolve a property of an object that wasn't involved 
in THAT table at all, but was a property of a table that appeared higher on the 
page. What I discovered was that the first table used the NAME attribute to 
refer to the name of the collection for that table, whereas all the rest of the 
tables on that page used the NAME attribute to refer to the collection itself. 
When I changed the NAME attribute on the first table to the actual collection, 
the problem on the other table went away.

So, check to see if you are using the NAME attribute to refer to the 
collections, or the names of the collections.

HTH...

Paul

From: Rick.Wellman [mailto:rick.well...@kiewit.com]
Sent: Tuesday, December 08, 2009 1:39 PM
To: displaytag-user@lists.sourceforge.net
Subject: Re: [displaytag-user] Possible Bug in TableDecorator

I have included two things below:
[1] The table definition as requested
[2] A snippet from a custom class that I wrote as explained next.

(Quick disclaimer:  I am using JAR 1.1.1 though I did try to drop test the 
latest version of the JAR.   The rest of this email refers to the source code 
which I got off one of the web source repositories, Koders Search, and I have 
not done complete due diligence in reconciling versions of code to JAR.)
So basically I feel that I have verified the behavior at least.  As my original 
email states, it seems you can only use properties that belong to the 
underlying object.  I guess that is fine for now as long as I understand that.  
It does not seem as useful but at least I know what to expect.

So, for what it is worth, I have at least solved my problem temporarily by 
writing a custom Decorator modeled after the total decorator in the JAR.  I 
ended up overriding the evaluate method from the base Decorator class which I 
included in [2] below.  It is pretty simple and it seems to work though I have 
not done a lot of testing against it.  I will update this thread if I find out 
more.

I am still curious as to the take that others have on this "feature".   My 
observations are not really a complaint, just trying to flush out my own 
understanding and contribute to the process of open-source.  If I get to spend 
much more time on this I may even post a proposed patch or something. :)

Thanks all.

Attachment 1:
[Note:  I know that these have a body and a property.  A mere artifact of the 
various things I tried along the way.  From my testing, apparently the property 
value trumps the tag body so it is merely "misleading" and does not cause a 
bug.]
<display:table
    htmlId="displaytable"
    decorator="totalsDecorator"
    export="false"
    requestURI="home.kpe" excludedParams="*"
    cellpadding="5px" cellspacing="0px"
    name="contractList" uid="contract"
    >

    <display:column title="Contract"     sortable="false" 
sortProperty="contractNo"><span 
title="${contract.contractDesc}">${contract.contractNo}</span></display:column>
    <display:column title="Deliv."       sortable="false" class="alignRight"    
                        property="reviewTime"      total="true" 
format="{0,number,integer}">${fn:length(contract.delivs)}</display:column>
    <display:column title="Pending"      sortable="false" class="alignRight 
borderLeft alertInfoBg"     property="projId"          total="true" 
format="{0,number,integer}">${exp:getCountPendingDeliverables(contract)}</display:column>
    <display:column title="Waiting"      sortable="false" class="alignRight 
borderLeft alertMinorBg"    property="vendorId"          total="true" 
format="{0,number,integer}">${exp:getCountWaitingDeliverables(contract)}</display:column>
    <display:column title="Due"          sortable="false" class="alignRight 
borderLeft alertMajorBg"    property="disciplineId"          total="true" 
format="{0,number,integer}">-</display:column>
    <display:column title="Late"         sortable="false" class="alignRight 
borderLeft alertCriticalBg" property="assignedFl"          total="true" 
format="{0,number,integer}">${exp:getCountLateDeliverables(contract)}</display:column>
    <display:column title="Received"     sortable="false" class="alignRight 
borderLeft alertMinorBg"    property="leadId"          total="true" 
format="{0,number,integer}">${exp:getCountReceivedDeliverables(contract)}</display:column>
    <display:column title="Complete"     sortable="false" class="alignRight 
borderLeft alertNormalBg"   property="altLeadId"          total="true" 
format="{0,number,integer}">${exp:getCountCompleteDeliverables(contract)}</display:column>

</display:table>

Attachment 2:
[Note: CheckedExceptionWrapper is a custom class that we use.]
    public Object evaluate(String name) {
        Object o = null; // super.evaluate(name);

        if (this.hasGetterFor(name)) {
            try {
                o = LookupUtil.getBeanProperty(this, name);
            } catch (ObjectLookupException e) {
                throw new CheckedExceptionWrapper(name, e);
            }
        } else {
            // else check underlining object
            o = super.evaluate(name);
        }

        return o;
    }

------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
displaytag-user mailing list
displaytag-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to