Well, I got it figured out. Interestingly enough, setSelectedList gets
called just fine, and list is indeed populated with options I selected.
Yet.... checkboxes still would come "unchecked". So I checked source of
MultiplePropertySelection to see what condition it is using from
selectedList to determine if item is checked. Sure enough, lines 138-139
make it clear:

138                // Try to find the option in the list and if yes,
then it is checked.
139                boolean optionSelected = selectedList.contains(option);

Thank God for the source! Without looking at it I would have never known
that objects in selected list must be comparable with equals. Since I never
overwrote equals optionSelected was always false, and so nothing came back
checked. So in the end it came down to incomplete documentation. From a
newbie perspective, I expected to use the component by reading its spec in
the component reference. I got close, but the reference has no mention of
anything regarding what are the specs of objects stored in the selectedList.
I think updating documentation to mention this would help newcommers with
this piece.

Thanks much for your help. It helped me figure it out much quicker ;-)

Regards,
Adam

On 2/3/06, Geoff Longman <[EMAIL PROTECTED]> wrote:
>
> We had a problem with MPS a day ago. Unlike most Tapestry components,
> MPS does not push the list back during the rewind. It takes pulls the
> list in during rewind, populates it and that's it. So, if you don't do
> something with the list after the rewind it will be lost at the end of
> the request.
>
> We had something like this (Tap3 notation):
>
> Note the page setup is a but unusual but it helped track down the problem.
>
> private List list;
>
> public List getList() {
>   if (list == null)
>      return new ArrayList();
> return list;
> }
>
> public void setList(List list) {
>   this.list = list;
> }
>
> <span jwcid="@contrib:MultiplePropertySelection"
> model="--our model---"
>                      selectedList="ognl:list">
>
> We noticed that setList() was never being called. Looking into the
> code of MPS we saw that indeed the component never pushes the list
> back out.
>
> the fix for us was to delete setList() - never called and change getList()
> this:
>
> public List getList() {
>   if (list == null)
>      list = new ArrayList();
> return list;
> }
>
> in the old version of getList() nobody had a reference to the new
> ArrayList() and list was always null.
>
> Hope that helps a bit.
>
> Geoff
>
> On 2/3/06, Chris Chiappone <[EMAIL PROTECTED]> wrote:
> > Here is what I have that seems to work.
> >
> > page.html
> >
> > <span jwcid="@contrib:MultiplePropertySelection"
> > model="ognl:@[EMAIL PROTECTED]"
> >                       selectedList="ognl:appList">
> >
> > page.java
> >
> >         public static IPropertySelectionModel APPTYPES = new
> > StringPropertySelectionModel(
> >                         SelectionModelBuilder.getAllApplicationTypeNames
> (false));
> >
> >
> >         public abstract List getAppList();
> >
> >         public abstract void setAppList(List appList);
> >
> >         public void pageBeginRender(PageEvent event) {
> >
> >                 if (getAppList() == null) {
> >                         setAppList(new ArrayList());
> >                 }
> >
> >         }
> >
> > On 2/3/06, Adam Zimowski <[EMAIL PROTECTED]> wrote:
> > > I commented out setting list to null in initialize and still have same
> > > problem.  I set it to null in initialize so that when page is returned
> to
> > > pool the state is clean.  I tried looking for a good quick working
> example,
> > > but can't find it anywhere.
> > >
> > > On 2/3/06, Chris Chiappone <[EMAIL PROTECTED]> wrote:
> > > >
> > > > I think it has to do with the fact you are setting the selectedList
> to
> > > > null in initialize.
> > > > So during form rewind its actually gettting reset.
> > > >
> > > > On 2/3/06, Adam Zimowski <[EMAIL PROTECTED]> wrote:
> > > > > Hi. I'm a tapestry newbie... I'm trying to implement a group of
> > > > checkboxes
> > > > > where at least one option is required. I'm thinking of using
> > > > > MultiplePropertySelection from contib library, but I can't find a
> good
> > > > > example of it working. I tried based on the basic documentation,
> and
> > > > while I
> > > > > got the group of checkboxes to render based on my
> > > > IPropertySelectionModel
> > > > > when I submit the form any checkbox selections I made are not
> > > > remembered:
> > > > >
> > > > >    <component id="test" type="contrib:MultiplePropertySelection">
> > > > >        <binding name="selectedList" value="selectedList"/>
> > > > >        <binding name="model" value="model"/>
> > > > >    </component>
> > > > >
> > > > > ------ relevant part from Page class:
> > > > >
> > > > >      private List<CheckboxEntity> selectedList;
> > > > >      public abstract List<CheckboxEntity> getSelectedList();
> > > > >      public abstract void setSelectedList(List<CheckboxEntity>
> aList);
> > > > >
> > > > >      public void initialize() {
> > > > >          if(_pLog.isDebugEnabled()) _pLog.debug("");
> > > > >          selectedList = null;
> > > > >      }
> > > > >
> > > > >    public IPropertySelectionModel getModel() {
> > > > >        _pLog.debug("");
> > > > >        return new SimpleEntitySelectionModel();
> > > > >    }
> > > > >
> > > > > The SimpleEntitySelectionModel connects to the database and
> retrieves
> > > > > checkbox info. It works in that I see checkboxes render based on
> what's
> > > > in
> > > > > the database.
> > > > >
> > > > > Perhaps anybody has a quick practical example of the whole thing?
> > > > >
> > > > > Regards,
> > > > > Adam Zimowski
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > ~chris
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail:
> [EMAIL PROTECTED]
> > > >
> > > >
> > >
> > >
> >
> >
> > --
> > ~chris
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> The Spindle guy.          http://spindle.sf.net
> Get help with Spindle:
> http://lists.sourceforge.net/mailman/listinfo/spindle-user
> Blog:                     http://jroller.com/page/glongman
> Feature Updates:          http://spindle.sf.net/updates
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to