You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Mohammad Salman <mo...@yahoo.com> on 2010/04/13 08:08:51 UTC

CheckGroup and ListView

I use a ListView to populate a CheckGroup with Check objects.  It works fine and all the check boxes are displayed properly.  But when I try to add a new check box to the ones previously added, I keep getting the new one along with the previous ones in duplicate.

Here is my code. (I apologize for the format of the code)


protected void addCheckGroup(
List<SelectableValue> list)
throws Exception
{
Object object = getDefaultModelObject();
checkGroupSelectableValues = new CheckGroup<SelectableValue>("selectedValues");
//checkGroupSelectableValues.add(new CheckGroupSelectors("groupSelector"));
selectableValues = new ListView<SelectableValue>("selections", list)
{

            /**
             * 
             */
            private static final long serialVersionUID = 1L;

@Override
            protected void populateItem(
                ListItem<SelectableValue> item)
            {
            item.add(new Check<SelectableValue>("check", item.getModel()));
            item.add(new Label("value", new PropertyModel<SelectableValue>(item.getModel(), "value")));            
            }
};
checkGroupSelectableValues.add(selectableValues);
selectableValues.setOutputMarkupPlaceholderTag(true);
checkGroupSelectableValues.setRenderBodyOnly(false);
checkGroupSelectableValues.setOutputMarkupPlaceholderTag(true);

add(checkGroupSelectableValues);
}





protected void addNewSelectableValue(
AjaxRequestTarget target)
throws Exception
{
List<SelectableValue> list;  // new list with the new SelectableValue added 
selectableValues.removeAll();   // making sure to remove previous object
selectableValues.setList(list);   // Adding the new list to the ListView
checkGroupSelectableValues.removeAll();  // making sure to remove previous check boxes.
checkGroupSelectableValues.add(selectableValues);

target.addComponent(checkGroupSelectableValues);
     }

I have tried different other methods but  either I get the previous values in duplicates or the new value does not show up.

I will appreciate help in solving this issue.  Thanks

 Mohammad

Re: CheckGroup and ListView

Posted by msalman <mo...@yahoo.com>.
And it was as simple as that.  

Thank you so much. 

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/CheckGroup-and-ListView-tp1886879p2197959.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: CheckGroup and ListView

Posted by Jeremy Thomerson <je...@wickettraining.com>.
I just looked at it.  There's only one problem, and it's not your code -
it's your markup.  Remove that span that you have (<span
wicket:id="selectedValues">) and put the wicket:id on the table tag instead.
 You're butchering the markup when you try to replace a span that has rows
in it.  That's not an allowable dom structure.

--
Jeremy Thomerson
http://www.wickettraining.com



On Wed, May 12, 2010 at 12:37 PM, msalman <mo...@yahoo.com> wrote:

>
> Hi,
>
> Was any one able to test the quick start?
>
> Thanks.
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/CheckGroup-and-ListView-tp1886879p2196464.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: CheckGroup and ListView

Posted by msalman <mo...@yahoo.com>.
Hi,

Was any one able to test the quick start? 

Thanks.
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/CheckGroup-and-ListView-tp1886879p2196464.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: CheckGroup and ListView

Posted by msalman <mo...@yahoo.com>.

QuickStart project added.  BTW thanks for the instructions for creating the
quick start.  If any one else needs the instructions then they can be found
at:

http://www.jeremythomerson.com/blog/2008/11/wicket-quickstart-tutorial/#more-99

Well, I hope the quick start works for others too.

Thanks again.


http://n4.nabble.com/file/n2134528/wicket-quickstart-checkgroup.zip
wicket-quickstart-checkgroup.zip 
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/CheckGroup-and-ListView-tp1886879p2134528.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: CheckGroup and ListView

Posted by Jeremy Thomerson <je...@wickettraining.com>.
create a quickstart and post it somewhere where we can get to it and someone
will help you

--
Jeremy Thomerson
http://www.wickettraining.com



On Thu, May 6, 2010 at 7:12 PM, msalman <mo...@yahoo.com> wrote:

>
> Well, I have tried removing and then adding the ListView to the CheckGroup,
> but that does not work either.
>
> I have tried to debug this as much as I could and I do see that there are
> the right values in the java objects of ListView and the wrapped list.   To
> me it looks like that the code that creates the html or the script is not
> clearing the old values.  But that is just my guess.
>
> But hopefully I am just not doing some thing right and some one would
> please
> point that out to me.
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/CheckGroup-and-ListView-tp1886879p2133543.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: CheckGroup and ListView

Posted by msalman <mo...@yahoo.com>.
Well, I have tried removing and then adding the ListView to the CheckGroup,
but that does not work either.  

I have tried to debug this as much as I could and I do see that there are
the right values in the java objects of ListView and the wrapped list.   To
me it looks like that the code that creates the html or the script is not
clearing the old values.  But that is just my guess.  

But hopefully I am just not doing some thing right and some one would please
point that out to me.


-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/CheckGroup-and-ListView-tp1886879p2133543.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: CheckGroup and ListView

Posted by nino martinez wael <ni...@gmail.com>.
When using ajax you do have to add the listview again..

2010/5/6 msalman <mo...@yahoo.com>:
>
> Well, I have tried using ListModel as following:
>
> selectableValues = new ListView<SelectableValue>("selectableValuesList", new
> ListModel<SelectableValue>(list))
> {
> ..
> }
>
> and then:
>
>                selectableValues.getModelObject().add(new SelectableValue(newId, "value "
> + newId++));
>
>
> without any success.
>
> BTW, do I also need to set the model for the CheckGroup as following?
>
> checkGroupSelectableValues = new
> CheckGroup<SelectableValue>("selectedValues",  new
> CollectionModel<SelectableValue>(list));
>
>
> I did not need to do this in my other application but in this application if
> I don't do it then I get the model is null exception.  I thought that when I
> add the ListView Object to the CheckGroup object then the model object is
> set for CheckGroup.
>
> The bottom line is that I can not make this thing what ever I tried.
>
> Please help.  Thanks.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/CheckGroup-and-ListView-tp1886879p2133161.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: CheckGroup and ListView

Posted by msalman <mo...@yahoo.com>.
Well, I have tried using ListModel as following:

selectableValues = new ListView<SelectableValue>("selectableValuesList", new
ListModel<SelectableValue>(list))
{
..
}

and then:

		selectableValues.getModelObject().add(new SelectableValue(newId, "value "
+ newId++));


without any success.  

BTW, do I also need to set the model for the CheckGroup as following?

checkGroupSelectableValues = new
CheckGroup<SelectableValue>("selectedValues",  new
CollectionModel<SelectableValue>(list));


I did not need to do this in my other application but in this application if
I don't do it then I get the model is null exception.  I thought that when I
add the ListView Object to the CheckGroup object then the model object is
set for CheckGroup.

The bottom line is that I can not make this thing what ever I tried.

Please help.  Thanks.

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/CheckGroup-and-ListView-tp1886879p2133161.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: CheckGroup and ListView

Posted by msalman <mo...@yahoo.com>.
Oh my. I was just about to send you a special email for my problem.  But you pre-empted me.
I will try your suggestion.
 
Thanks so much
Mohammad Salman 
(510) 673-5869 c 

"Every problem has its solution(s) but there are problems with any solution"




________________________________
From: Jeremy Thomerson [via Apache Wicket] <ml...@n4.nabble.com>
To: msalman <mo...@yahoo.com>
Sent: Wed, May 5, 2010 2:08:06 PM
Subject: Re: CheckGroup and ListView

I haven't looked at it in detail, but you shouldn't be doing that 
removeAll() and setList() stuff - it comes from a lack of using Models 
properly - which is the most common mistake I see in Wicket users.  Instead, 
you should give the ListView constructor an instance of some 
IModel<List<SelectableValue>>.  Then simply add your new selectable value to 
whatever list that model is getting it's data from.  The ListView will 
auto-magically repaint everything correctly. 

-- 
Jeremy Thomerson 
http://www.wickettraining.com



On Wed, May 5, 2010 at 3:59 PM, msalman <[hidden email]> wrote: 


> 
> I have not heard anything on this one.  I will be very thankful if I can 
> get 
> some help on this one.  To help reproduce the problem I have attached 
> simple 
> code files. 
> 
> http://n4.nabble.com/file/n2131672/App.java App.java . 
> http://n4.nabble.com/file/n2131672/PageCheckGroup.html PageCheckGroup.html 
> . 
> http://n4.nabble.com/file/n2131672/PageCheckGroup.java PageCheckGroup.java 
> . 
> http://n4.nabble.com/file/n2131672/SelectableValue.javaSelectableValue.java
> . 
> 
> 
> 
> -- 
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/CheckGroup-and-ListView-tp1886879p2131672.html
> Sent from the Wicket - User mailing list archive at Nabble.com. 
> 
> --------------------------------------------------------------------- 
> To unsubscribe, e-mail: [hidden email] 
> For additional commands, e-mail: [hidden email] 
> 
> 


________________________________
 
View message @ http://apache-wicket.1842946.n4.nabble.com/CheckGroup-and-ListView-tp1886879p2131687.html 
To unsubscribe from Re: CheckGroup and ListView, click here. 

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/CheckGroup-and-ListView-tp1886879p2131697.html
Sent from the Wicket - User mailing list archive at Nabble.com.

Re: CheckGroup and ListView

Posted by Jeremy Thomerson <je...@wickettraining.com>.
I haven't looked at it in detail, but you shouldn't be doing that
removeAll() and setList() stuff - it comes from a lack of using Models
properly - which is the most common mistake I see in Wicket users.  Instead,
you should give the ListView constructor an instance of some
IModel<List<SelectableValue>>.  Then simply add your new selectable value to
whatever list that model is getting it's data from.  The ListView will
auto-magically repaint everything correctly.

--
Jeremy Thomerson
http://www.wickettraining.com



On Wed, May 5, 2010 at 3:59 PM, msalman <mo...@yahoo.com> wrote:

>
> I have not heard anything on this one.  I will be very thankful if I can
> get
> some help on this one.  To help reproduce the problem I have attached
> simple
> code files.
>
> http://n4.nabble.com/file/n2131672/App.java App.java .
> http://n4.nabble.com/file/n2131672/PageCheckGroup.html PageCheckGroup.html
> .
> http://n4.nabble.com/file/n2131672/PageCheckGroup.java PageCheckGroup.java
> .
> http://n4.nabble.com/file/n2131672/SelectableValue.javaSelectableValue.java
> .
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/CheckGroup-and-ListView-tp1886879p2131672.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: CheckGroup and ListView

Posted by msalman <mo...@yahoo.com>.
I have not heard anything on this one.  I will be very thankful if I can get
some help on this one.  To help reproduce the problem I have attached simple
code files.

http://n4.nabble.com/file/n2131672/App.java App.java .  
http://n4.nabble.com/file/n2131672/PageCheckGroup.html PageCheckGroup.html .
http://n4.nabble.com/file/n2131672/PageCheckGroup.java PageCheckGroup.java .
http://n4.nabble.com/file/n2131672/SelectableValue.java SelectableValue.java
.



-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/CheckGroup-and-ListView-tp1886879p2131672.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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