File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Using a Collection or Array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Using a Collection or Array" Watch "Using a Collection or Array" New topic

Using a Collection or Array

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

I have a strange situation. I have a form and 5 of the form fields are user defined. So I have a table in my database that contains a userid and then 5 userdefined columns. The user can go into his profile and set each user defined column to be whatever he wants.
Now, when the Input Form is displayed I want to replace the User Defined n label with whatever the user has defined for his columns.
My question is basically the best approach to do this without using too many scriplets.
My first idea was to add a parameter to my UserBean that basically holds in a collection or array of some sort all 5 of these and then to use that UserBean in my JSP page to display the Labels. Is this a good idea?
My other idea was to make a seperate Bean that was UserDefinesBean and just 5 parameters, 1 for each UserDefined column, and use that bean in the JSP page. Is this a good way?
Is there a better way?
[ September 24, 2003: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63837

The choice comes down to deciding the approriate level of abstraction for the set of user-defined labels. If the labels are useless outside of the User context, there should be no issue bundling them with the User. If the labels are more autonomous, or even if they have the potential to be in the future, I'd abstract them away from the User. [Confession: in my own code I have a tendency to favor abstraction, so I'd probably keep them separate from the User context even if I didn't think they'd ever be used separately.]

[Asking smart questions] [About Bear] [Books by Bear]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Thanks Bear. I will probably keep it as a seperate Bean. Thanks.
I agree. Here's the link:
subject: Using a Collection or Array
It's not a secret anymore!