• 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

Struts 2 select tag problem

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
I am newbie to Struts 2 and I got error trying to understand and get working on select tag(struts2).

the following is my action class.



the following is my jsp page



If I change <s:select /> to <s:textfield /> the whole thing is working.(if not working error is 404) Or If I do NOT make an object of type "User", I can use <s:select />. (then I can NOT write user object to database).

I do not know where do I get wrong

1). How can I achieve it?
2). Can you recommend me a website or a book to achieve that?

thanks in advance.
 
tyte kyat
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks I got that working and for those who struggle like me can have reference ..



I just add a new method called populate() and add the String using List's add method. Do NOT forget to return a string, otherwise, it will stuck on that point.



in struts.xml, you just need to point your newly created method (populate())

and finally in the jsp page, you just prepare the normal select tag as follow



Thanks and good luck
 
tyte kyat
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
or you can simply just do that in your jsp

<s:select list="{'single','married','other'}" name="status" label="Marital Status"></s:select>

thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic