You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Adam Zimowski <zi...@gmail.com> on 2006/02/03 23:37:45 UTC

MultiplePropertySelection

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

Re: MultiplePropertySelection

Posted by Adam Zimowski <zi...@gmail.com>.
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 <gl...@gmail.com> 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 <ch...@gmail.com> wrote:
> > Here is what I have that seems to work.
> >
> > page.html
> >
> > <span jwcid="@contrib:MultiplePropertySelection"
> > model="ognl:@com.atwcorp.trustedapp.view.pages.Search@APPTYPES"
> >                       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 <zi...@gmail.com> 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 <ch...@gmail.com> 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 <zi...@gmail.com> 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: tapestry-user-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> > > >
> > > >
> > >
> > >
> >
> >
> > --
> > ~chris
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>
> --
> 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: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

Re: MultiplePropertySelection

Posted by Geoff Longman <gl...@gmail.com>.
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 <ch...@gmail.com> wrote:
> Here is what I have that seems to work.
>
> page.html
>
> <span jwcid="@contrib:MultiplePropertySelection"
> model="ognl:@com.atwcorp.trustedapp.view.pages.Search@APPTYPES"
>                       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 <zi...@gmail.com> 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 <ch...@gmail.com> 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 <zi...@gmail.com> 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: tapestry-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > >
> > >
> >
> >
>
>
> --
> ~chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


--
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: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: MultiplePropertySelection

Posted by Chris Chiappone <ch...@gmail.com>.
Here is what I have that seems to work.

page.html

<span jwcid="@contrib:MultiplePropertySelection"
model="ognl:@com.atwcorp.trustedapp.view.pages.Search@APPTYPES"
                      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 <zi...@gmail.com> 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 <ch...@gmail.com> 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 <zi...@gmail.com> 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: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>


--
~chris

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: MultiplePropertySelection

Posted by Adam Zimowski <zi...@gmail.com>.
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 <ch...@gmail.com> 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 <zi...@gmail.com> 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: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

Re: MultiplePropertySelection

Posted by Chris Chiappone <ch...@gmail.com>.
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 <zi...@gmail.com> 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: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org