aspose file tools*
The moose likes Struts and the fly likes problem with displaytag and basicDynaBean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem with displaytag and basicDynaBean" Watch "problem with displaytag and basicDynaBean" New topic
Author

problem with displaytag and basicDynaBean

Joel Sand
Greenhorn

Joined: Feb 25, 2009
Posts: 8
Hi,

I'm trying to make a table containing courses (w. displaytag). Each course should have its own color (red, green etc.) displayed before course name e.g.

[red] math
[blue] english
...

my action is retrieving a rowSetDynaClass (from a DB) with the fields [color, course_name] and distributes it through getMySubjects()

my JSP code looks like this:



My problem is that I want to have a small image icon for the corresponding color in the first column.
I can print the color text perfectly by the line <display:column title="Color" property="color"> but then I couldnt make it an image.

My idea was to access it as an implicit object according to: displaytag example
Since the dynabean is put in the page scope I access it with:
<s:url value="%{#attr.item}"/>
this would output the beans name e.g. org.apache.commons.beanutils.BasicDynaBean@133650d in the column.
sadly adding the prefix:
<s:url value="%{#attr.item.color}"/>
outputs nothing.

So my question is; what am I doing wrong here? is it a simple syntax error or am I using the wrong approach?
All suggestions are appreciated!

/Joel
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'd probably just try accessing it using the get() method first; #attr.item.get('color') and see if that works. Since it's not a map, and has no color property, I don't think OGNL would have any idea of how to access arbitrary properties. #attr.item.map.color or #attr.item.map['color'] might work, however, since getMap() returns an actual map.
Joel Sand
Greenhorn

Joined: Feb 25, 2009
Posts: 8
David, you just made my day!

worked like a charm!
I can't thank you enough, good day to you!

/Joel
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I *knew* my BasicDynaBean chops would come in handy some day!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with displaytag and basicDynaBean