• 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

Access DAO Attributes?

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all,

I am trying to set up a Struts 2 project that has tables with dynamic columns (i.e., the user may add and remove fields from the table). As it is I load all of the fields and their values into the class' Attributes, but I am having a hard time figuring out if there is a Struts tag with which I can access the Attributes object from my JSP page. I believe I might be able to accomplish the same thing by loading the values into an Iterator and using the Struts iterator tag, but I was hoping to deal directly with the Attributes object.

Anyone have any ideas?


-TennSeven
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have a good idea of your class structure here. Is Attributes a single object that stores all the database information, or is there a class structure that contains many instances of Attributres?
 
J Ellis
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Attributes is a single object that stores all of the key/value pairs for a single instance from the table. For instance, if the table was "Employees" one Employee instance (taken from the iteration of all instances in the table) would have one Attributes object whose toString() output would like like this:



If these were discrete variables in the instance class I could access them like this:
But I want the user to be able to add, say, a "phoneNumber" column to the "Employees" table, and so I cannot rely on variables to hold the values but instead need something flexible, like the Attributes object.
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using java.util.jar.Attributes? The iterator tag says it works with java.util.Map. Attributes implements Map. It should just work. See an example here.
 
reply
    Bookmark Topic Watch Topic
  • New Topic