permaculture playing cards
The moose likes Struts and the fly likes Struts 2 select tag problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 select tag problem" Watch "Struts 2 select tag problem" New topic

Struts 2 select tag problem

tyte kyat
Ranch Hand

Joined: May 17, 2011
Posts: 40
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

Joined: May 17, 2011
Posts: 40
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

Joined: May 17, 2011
Posts: 40
or you can simply just do that in your jsp

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

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Struts 2 select tag problem
jQuery in Action, 3rd edition