• 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

Using a Collection or Array

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.]
hth,
bear
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear. I will probably keep it as a seperate Bean. Thanks.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic