• 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

Can I use a same Bean for this JSP ?

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my JSP, it looks like
****************
<% String age = session.getAttribute("Age").toString();
String choice;
if(age.equals("senior")) choice = "MULTIPLE";
else choice = "SINGLE"; %>

<SELECT NAME="ITEMS" <%= choice %>>
<OPTION VALUE="item1">item1
<OPTION ...
...
</SELECT>
*****************

It may have some typo here. But the point is this JSP page can dynamically ask user to pick one or more items (sometimes one, sometimes more, depending on if you are senior member). Now suppose we have a "FormBean" matching this JSP, should I

1) create two "FormBean" class, in first one I put "private String item;" and in second class I put "private Collection item;" ?
2) or should I ONLY create one "FormBean" class and just put "private Collection item" ? The single item case should be covered by it anyway.

I guess I should take approach 2), is that right ?
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess you're right. But I have never tried that.
 
steve francisco
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can someone give me a sure answer ?
 
reply
    Bookmark Topic Watch Topic
  • New Topic