Re: Can't Ajax-Update CheckGroup with new ListView

2013-04-26 Thread Paul Bors
Why not reuse the list of check boxes, grab a hold of their models and
toggle them on and off as you wish?

See ListView.setReuseItems(true)

~ Thank you,
   Paul Bors

On Mon, Apr 22, 2013 at 10:27 AM, eugenebalt eugeneb...@yahoo.com wrote:

 Any help on this issue?



 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/Can-t-Ajax-Update-CheckGroup-with-new-ListView-tp4658090p4658162.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: Can't Ajax-Update CheckGroup with new ListView

2013-04-26 Thread eugenebalt
Paul, how would the model specify enabled/disabled status? The model contains
the values of the checkboxes.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Can-t-Ajax-Update-CheckGroup-with-new-ListView-tp4658090p4658323.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Can't Ajax-Update CheckGroup with new ListView

2013-04-26 Thread Paul Bors
Take a look at the Wicket Examples:
http://www.wicket-library.com/wicket-examples/index.html

Mainly the forminput - Basic form processing

There is a select one or more numbers (CheckGroup) and if you look at the
sourcecode from upper right corner you can view the FormInput.java.

Scroll down till you get to this section:

CheckGroupString checks = *new* CheckGroupString(numbersCheckGroup);
add(checks);
ListViewString checksList = *new* ListViewString(numbers, NUMBERS)
{
   @Override
   *protected* void populateItem(ListItemString item)
   {
 CheckString check = *new* CheckString(check, item.getModel());
 check.setLabel(item.getModel());
 item.add(check);
 item.add(*new* SimpleFormComponentLabel(number, check));
   }
}.setReuseItems(true);
checks.add(checksList);
Notice the model of the CheckGroup is a *new* CompoundPropertyModel
FormInputModel()

Now take a look at the FormInputModel and you'll see that the numbersCheckGroup
is actually nothing but a ListString numbersCheckGroup = *new* ArrayList
String(); Because this list starts as an empty list there are no check
boxes of that group selected when the page first renders. As you select
some check boxes and submit the form, wicket in turn adds those checks to
the list for you.

Don't confuse this list that's the model object for the CheckGroup with the
model object for the Check. See how in the above code a ListView is used to
render the Checks needed given the NUMBERS constants? That's what controls
how many checks you have and what value is inserted into the
numbersCheckGroup. So, if you want to add some AjaxBehavior to those Cheks,
then you'd add your behavior and to select some Checks you'd insert into
the numbersCheckGroup list the value from NUMBERS of the check you want to
have auto-checked or remove it if you want to un-check it.

Of course, now you have to figure out the same for your own domain objects.

I suggest you start by grabbing a hold of the example code and then modify
it to work with Ajax as you want it to.
Once you understand how that works, then you can implement it into your own
product.

For more on Wicket Models see:
https://cwiki.apache.org/WICKET/working-with-wicket-models.html
http://wicket.apache.org/learn/books/freeguide.html (chapter 9 and 10.10.1
Working with grouped checkboxes)

~ Thank you,
   Paul Bors

On Fri, Apr 26, 2013 at 1:22 PM, eugenebalt eugeneb...@yahoo.com wrote:

 Paul, how would the model specify enabled/disabled status? The model
 contains
 the values of the checkboxes.



 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/Can-t-Ajax-Update-CheckGroup-with-new-ListView-tp4658090p4658323.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: Can't Ajax-Update CheckGroup with new ListView

2013-04-22 Thread eugenebalt
Any help on this issue?



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Can-t-Ajax-Update-CheckGroup-with-new-ListView-tp4658090p4658162.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Can't Ajax-Update CheckGroup with new ListView

2013-04-18 Thread eugenebalt
We have an Ajax method in some component where we have to update a CheckGroup
on the form. (The update is that some checkboxes get enabled/disabled.)

We construct a new ListView object, then addOrReplace it to the checkGroup;
and finally, after that, we add the CheckGroup to target.addComponent.

What we see is that the target.addComponent actually happens first. The new
ListView construction actually follows it, based on the output, and we don't
see the new checkboxes getting enabled.

Any ideas, thanks.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Can-t-Ajax-Update-CheckGroup-with-new-ListView-tp4658090.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Can't Ajax-Update CheckGroup with new ListView

2013-04-18 Thread eugenebalt
In other words, we set the individual check box's Enabled/Disabled in
ListView.populateItem().

This populateItem() call happens after the target.addComponent(listView),
even though in the code it precedes it.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Can-t-Ajax-Update-CheckGroup-with-new-ListView-tp4658090p4658091.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Can't Ajax-Update CheckGroup with new ListView

2013-04-18 Thread eugenebalt
Here is the code. As I said, we need to selectively enable/disable certain
checkboxes in a CheckGroup as part of some other component's Ajax event.

The issue is that the Ajax update is happening *before* we get a chance to
disable the checkbox in the ListView's populateItem(). So our checkboxes
never get updated. Thanks

structureDropDown.add(new AjaxFormComponentUpdatingBehavior(onchange)
{
  // …

  final CheckGroup appsCheckGroup =
(CheckGroup)UM01SearchForm.get(apps);
  ListView appListView = new ListView(appList, appList) {

  protected void populateItem(ListItem arg0) {
Check app = new Check(app, arg0.getModel(),
appsCheckGroup);

app.setEnabled(true);

arg0.add(app);
 }
 }


appsCheckGroup.addOrReplace(appListView);
target.addComponent(appsCheckGroup.setRenderBodyOnly(false));
}




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Can-t-Ajax-Update-CheckGroup-with-new-ListView-tp4658090p4658098.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org