Hi, On Thu, Jun 12, 2008 at 4:30 PM, kukudas <[EMAIL PROTECTED]> wrote: > Hi, thanks for your reply i think i did it right but still getting an > exception: > this is how it works when i do a textfield and enter the value by my hand: > <s:textfield id="athy" label="Rolle" name="a.Auth"/> > > And this is when i try doing it with the s:select > <s:select name="a.Auth" list="authorities" label="Choose" listValue="athy"/> > > i have getter/setter for a in my ActionClass. a is a Object from another > Class lets call it Athy. authorities is a list in my ActionClass which has > getter/setter too. and athy is the string from the Class Athy(where i make > the "a" object from). the list and listValue thing is working because i get > the right values populated the thing which doesnt work is the name attribute > "a.Auth". Its Strange that in a textfield when i send the value it works .. > > The items in the list are populated but when i select something and push > submit i get this error: > java.util.NoSuchElementException
Well, that's straight forward: When you press submit the browser only sends the string representation of the object to the server. As, I'm pretty sure, you don't have any type conversion of the value set in the select box to the type of your property in the action, which should be setA(Athy). You now have some options: a) Check out how type conversion works within struts2/xwork [1] and write an appropriate type converter. This options is only viable from my point of view when Arty is just a simple class and no entity. I think reading entities from the database or taking similar actions in a type converter is no good practice, but I might be wrong here. b) Intercept the action invocation on the way and create/inject the object from the interceptor into the action, maybe with some annotation or interface on the action class which marks for the interceptor to take action on this invocation. c) Set the String parameter which was selected into the action (by providing an appropriate setter taking a String) and do the work of converting the action there. I usually discourage from this, as conversion code does IMO not belong to the action. Bye -Ralf [1] http://struts.apache.org/2.x/docs/type-conversion.html > Jim Kiley wrote: >> >> The s:select tag doesn't have much to do with the namespace. >> >> What you'll want to do is something like this: >> >> <s:form action="myAction"> >> <s:select name="myProperty" list="backingList" listKey="field1" >> listValue="field2" label="Choose a thing"/> >> <s:submit /> >> </s:form> >> >> Then you just have to make sure that your action ('myAction') has getters >> and setters for 'myProperty', a getter for 'backingList', and that each >> element of 'backingList' has fields 'field1' and 'field2', both of which >> have public getters. >> >> Does this help? >> >> jk >> >> On Thu, Jun 12, 2008 at 9:34 AM, kukudas <[EMAIL PROTECTED]> wrote: >> >>> >>> hi, >>> >>> basicly i can't find any working example, howto set the value which was >>> choosen into a variable so i can use this in my beans. i've tryied using >>> the >>> namespace which didn't work. >>> someone can provide me with an working example would be awesome thanks. >>> >>> greets >>> >>> kuku >>> -- >>> View this message in context: >>> http://www.nabble.com/Struts-2-s%3Aselect-question-tp17800089p17800089.html >>> Sent from the Struts - User mailing list archive at Nabble.com. >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >>> >> >> >> -- >> Jim Kiley >> Technical Consultant | Summa >> [p] 412.258.3346 [m] 412.445.1729 >> http://www.summa-tech.com >> >> > > -- > View this message in context: > http://www.nabble.com/Struts-2-s%3Aselect-question-tp17800089p17801387.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]