yeah, so, if you move the stuff around like they should be moved around and then submit the form, then /after/ the palette component has been rendered in the "rewind" stage of the submission, your collection should be updated; where are you checking the collection size?
Robert Dan wrote: > oops i think i spoke too soon... > so when u click on the select/deselect btns in the palette wouldnt those > update the collection that is being referred by the selected property? > (visit.user.spokenLanguages from the eg below) > i do a get on this collection and i dont see any changes to its size? > i swear my code is ditto to what rob has in his example :) > >> From: "Dan " <[EMAIL PROTECTED]> >> Reply-To: "Tapestry users" <[email protected]> >> To: [email protected] >> Subject: Re: Multiple Select >> Date: Thu, 14 Jul 2005 18:47:30 +0000 >> >> Ahh...i understand my mistake. thanks so much rob. ur help is invaluable! >> i had my code setup exactly the same...but heres wat i wasnt paying >> attn to: >> i was trying to add "instances" to the selected list which were "not" >> part of the model...and thus they would never appear! >> rocking! its works dude! ;) >> >> >>> From: Robert Zeigler <[EMAIL PROTECTED]> >>> Reply-To: "Tapestry users" <[email protected]> >>> To: Tapestry users <[email protected]> >>> Subject: Re: Multiple Select >>> Date: Thu, 14 Jul 2005 13:05:38 -0500 >>> >>> Dan wrote: >>> > hmm..i dont recognize the link though, between overriding equals and >>> > initializing the selected List ? >>> > maybe i m not on the same page as u :( i assume u r referring to >>> > overriding equals of the objects(model) inside the list? if thats the >>> > case, i already ve done that. could you please elaborate more? >>> >>> So, you've got your palette component... >>> parameter: selected, and model... >>> model contains the list of all possible selected values, right? >>> So... using the ListPropertySelectionModel, I'll put together a quick >>> example... something like: >>> >>> public class User { >>> public List getSpokenLanguages() { >>> ... >>> } >>> public void addToSpokenLanguages(Language l) { >>> getSpokenLanguages().add(l); >>> } >>> ... >>> } >>> >>> public class Language implements NamedListItem { >>> private String name; >>> >>> public String getItemName() { >>> return name; >>> } >>> >>> public Language(String name) { >>> this.name=name; >>> } >>> } >>> >>> template: >>> >>> ... >>> <select jwcid="@contrib:Palette" >>> selected="ognl:visit.user.spokenLanguages" model="ognl:languageModel"/> >>> >>> page.java: >>> ... >>> IPropertySelectionModel languageModel=null; >>> public IPropertySelectionModel getLanguageModel() { >>> if (languageModel == null) { >>> List languages = new ArrayList(); >>> languages.add(new Language("English")); >>> languages.add(new Language("French")); >>> languages.add(new Language("Japanese")); >>> } >>> return languageModel; >>> } >>> >>> >>> So... then the question is... suppose that you need to have some >>> languages preselected... >>> The first key is to have those languages in the list returned by >>> "getSpokenLanguages". Now, suppose that you know that every user >>> of your particular system at least speaks english, so, in your init >>> code for the user, you do something like: >>> >>> this.addToSpokenLanguages(new Language("English")); >>> >>> Now when you hit the palette page, "English" will NOT be in the selected >>> page still. Because the "English" instance in the "SpokenLanguages" >>> list is different than the instance in the model. So, the second >>> key is to make sure that equals returns true when it should. >>> (Or else, the second key is to ensure that the instances actually are >>> the same. :) >>> >>> So, going back to the language class... >>> >>> public class Language ... { >>> ... >>> public boolean equals(Object o) { >>> return o!=null && o instanceof Language && >>> ((Language)o).getItemName().equals(this.name); >>> } >>> } >>> >>> With that addition, and with the bit of init code above (add english to >>> the spoken language list), then when you hit the page with the palette >>> component, "English" will be selected. >>> >>> Robert >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >> >> _________________________________________________________________ >> Express yourself instantly with MSN Messenger! Download today - it's >> FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> > > _________________________________________________________________ > Express yourself instantly with MSN Messenger! Download today - it's > FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ > > > --------------------------------------------------------------------- > 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]
