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.
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?
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.