This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 select tag problem

 
tyte kyat
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic