struts select example <s:select label="Pets" name="petIds" list="petDao.pets" listKey="id" listValue="name" multiple="true" size="3" required="true" value="%{petDao.pets.{id}}" /> list: Iterable source to populate from. If the list is a Map (key, value), the Map key will become the option 'value' parameter the Map value will become the option body.
listKey: Property of list objects to get field value from value: Preset the value of input element. toString displays yadda.yadda.payper...@dfg65 which is the generated byte code for the entire map sub in classname for PetDao yourMap name for pets and you should see the value come back Martin Gainty ______________________________________________ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Date: Tue, 11 Aug 2009 06:59:06 -0700 > From: jo...@web.de > To: user@struts.apache.org > Subject: Re: Using Map as option list source with <s:select> tag > > > I'am not sure, but I think you can access the attributes > of your bean with value.myattribute > > <s:select list="mymap" listKey="key" listValue="value.myattribute"/> > > Best Regards > > Johannes Geppert > > > Stephen Turner wrote: > > > > Hello all, > > > > I'm playing with the Struts 2 <s:select> tag, trying to use a Map as the > > backing collection for the options list. This is Struts 2.0.11. > > > > From the docs: "Iterable source to populate from. If the list is a Map > > (key, value), the Map key will become the option > > 'value' parameter and the Map value will become the option body." > > > > So I have a Map, with values of type PayPeriod, which is a simple Java > > bean. What I get in the rendered values is the String representation of > > the class ( "yadda.yadda.payper...@dfg65" ). Is it possible to code > > something in the tag to get a PayPeriod bean attribute showing as the > > rendered value? I know I can cheat by defining a toString() method in the > > bean, but I wondered if there's a cleaner way of doing this. > > > > Thanks, > > Steve > > > > -- > > Stephen Turner > > Senior Programmer/Analyst - SAIS > > MIT IS&T > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > > > > > > > ----- > --- > web: http://www.jgeppert.com > twitter: http://twitter.com/jogep > > -- > View this message in context: > http://www.nabble.com/Using-Map-as-option-list-source-with-%3Cs%3Aselect%3E-tag-tp24917991p24918231.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > _________________________________________________________________ Windows Live™: Keep your life in sync. http://windowslive.com/explore?ocid=PID23384::T:WLMTAGL:ON:WL:en-US:NF_BR_sync:082009