• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem with displaytag and basicDynaBean

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David, you just made my day!

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

/Joel
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I *knew* my BasicDynaBean chops would come in handy some day!
 
I am displeased. You are no longer allowed to read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic