// Just create a new table, which will be put into the
current cell
listItem.add(new CheckBox("selected", new
PropertyModel(listItem.getModelObject(), "selected")));
}
});
Is this the problem? (you had getModel( ) in your code)
I remember having a nested list like yours and it worked.
- karthik
On 2/10/06, Mats Norén <[EMAIL PROTECTED]> wrote:
> On 2/9/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> > try the Check/CheckGroup components. they make it really easy to work with
> > listviews, and no wrappers necessary. i believe there is an example of it
> > working with a listview in the component reference.
>
> My hierarchy looks like this:
> page
> + form
> + listview
> populateItem(
> + inner listview 1
> ... varying number
> + inner listview n
> + new CheckBox()
> in the code I do this:
> form.add(listview);
> page.add(form);
>
> Are the inner listviews automatically added to the form? If not how do
> I get hold of the form inside populateItem for the outer listView?
>
> The outer listview is an iteration of a searchResult containing Party-objects.
> Each Party-object contain 0 or more PartyContactMechanisms.
> My aim is to be able to select PartyContactMechanisms from the list
> and add them to a selectList.
>
> Looking at the example for CheckGroup it doesn't work over a nested list?
>
> Thanks for your input!
>
>
>
>
>
>
>
>
> >
> > -Igor
> >
> >
> >
> > On 2/9/06, Mats Norén <[EMAIL PROTECTED]> wrote:
> > >
> > > I'm trying to use a checkbox in a nested ListView, and I'm having
> > > trouble updating the selection.
> > > I tried the wrapper example in the wiki but it didn't work:
> > >
> > >
> > http://www.wicket-wiki.org.uk/wiki/index.php/Listview_with_checkboxes_in_a_form
> > >
> > > I'm using wicket 1.2 from february.
> > >
> > > Any suggestions?
> > >
> > > My code:
> > >
> > > ListView searchList = new ListView("rows", new PropertyModel(this,
> > > "searchResult")) {
> > > public void populateItem(final ListItem listItem) {
> > > final Party party = (Party) listItem.getModelObject();
> > >
> > > listItem.add(new Label("id",
> > Long.toString(party.getId())));
> > > listItem.add(new Label("firstname",
> > party.getFirstname()));
> > > listItem.add(new Label("lastname", party.getLastname()));
> > >
> > > List wrappedPcms = new ArrayList();
> > > for (PartyContactMechanism pcm :
> > > party.getPartyContactMechanisms()) {
> > > wrappedPcms.add(new SelectionWrapper(pcm));
> > > }
> > >
> > > // Just create a new table, which will be put into the
> > > current cell
> > > listItem.add(new ListView("contact", wrappedPcms) {
> > > public void populateItem(final ListItem listItem) {
> > > final SelectionWrapper pcm =
> > > (SelectionWrapper) listItem.getModelObject();
> > > listItem.add(new Label("value",
> > >
> > pcm.getPartyContactMechanism().getContactMechanism().getContactMechanismType().getName()));
> > > listItem.add(new CheckBox("selected", new
> > > PropertyModel(listItem.getModel(), "selected")));
> > > }
> > > });
> > > }
> > > };
> > >
> > > Form resultForm = new Form("resultForm");
> > > resultForm.add(new Button("add") {
> > > protected void onSubmit() {
> > > System.out.println(getForm().getModelObject());
> > > }
> > > });
> > > resultForm.add (searchList);
> > > add(resultForm);
> > >
> > > Where searchList is collection of Party-objects.
> > >
> > > The SelectionWrapper:
> > >
> > > private class SelectionWrapper implements Serializable {
> > > private PartyContactMechanism pcm;
> > > private Boolean selected = Boolean.FALSE;
> > >
> > > public SelectionWrapper(PartyContactMechanism
> > pcm) {
> > > this.pcm = pcm;
> > > }
> > >
> > > public Boolean getSelected() {
> > > return selected;
> > > }
> > >
> > > public void setSelected(Boolean selected) {
> > > this.selected = selected;
> > > }
> > >
> > > public PartyContactMechanism getPartyContactMechanism() {
> > > return pcm;
> > > }
> > >
> > > public void
> > setPartyContactMechanism(PartyContactMechanism pcm) {
> > > this.pcm = pcm;
> > > }
> > >
> > > public String toString() {
> > > return pcm.getId() + ": " + selected;
> > > }
> > > }
> > >
> > >
> > > -------------------------------------------------------
> > > This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> > files
> > > for problems? Stop! Download the new AJAX search engine that makes
> > > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> > >
> > http://sel.as-us.falkag.net/sel?cmdlnk&kid3432&bid#0486&dat1642
> > > _______________________________________________
> > > Wicket-user mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/wicket-user
> > >
> >
> >
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmdlnk&kid3432&bid#0486&dat1642
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user