• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access DAO Attributes?

 
J Ellis
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • 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
 
Joe Ess
Bartender
Posts: 9295
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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: 9295
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic