You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by tsuresh <su...@hotmail.com> on 2007/11/29 13:49:43 UTC
Get Value entered in CheckBoxMultipleChoice and TextFields
Hello every body,
I have got the problem again, I have a form to add new Role which has
name, description and list of permissions. Role name and description are in
text fields and permissions are as checkboxmultiplechoice, I am having
difficult time in getting the values of the checked boxes. How do I get the
list of checked values in onSubmit() method. I tried as in code shown below
but it never returned any checked value
. What should I do ? I studied the examples in wicket component ref and
cwiki examples but could not succeed to solve it.
public void roleAdd() {
List permList = new ArrayList();
Role role = new Role();
CompoundPropertyModel roleAddModel = new
CompoundPropertyModel(role);
final Form form = new RoleAddForm("roleForm",roleAddModel);
add(form);
final TextField roleComp = new TextField("name");
final TextArea desComp = new TextArea("description");
try{
permList = p.list();
}catch(SQLException e){
String err = e.getMessage();
}
permComp = new CheckBoxMultipleChoice("permList",permList);
permComp.setModel(new Model());
form.add(roleComp);
form.add(desComp);
form.add(permComp);
}
class RoleAddForm extends Form{
public RoleAddForm(String id, IModel model){
super(id,model);
}
@Override
public void onSubmit() {
Role newRole = (Role)getModelObject();
Role r = new Role(); // Role to a be added
r.setName(newRole.getName());
r.setDescription(newRole.getDescription());
List perms;
perms = (List) model.getObject(permComp);
....................
....................
}
thanks
--
View this message in context: http://www.nabble.com/Get-Value-entered-in--CheckBoxMultipleChoice--and-TextFields-tf4896987.html#a14025061
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: Get Value entered in CheckBoxMultipleChoice and TextFields
Posted by Dipu Seminlal <di...@googlemail.com>.
take a look at the CheckBoxMultipleChoicePage in the wicket examples,
that will give you the idea, i have not used it myself though.
regards
-dipu
On Nov 29, 2007 12:49 PM, tsuresh <su...@hotmail.com> wrote:
>
> Hello every body,
> I have got the problem again, I have a form to add new Role which has
> name, description and list of permissions. Role name and description are
> in
> text fields and permissions are as checkboxmultiplechoice, I am having
> difficult time in getting the values of the checked boxes. How do I get
> the
> list of checked values in onSubmit() method. I tried as in code shown
> below
> but it never returned any checked value
> . What should I do ? I studied the examples in wicket component ref and
> cwiki examples but could not succeed to solve it.
>
> public void roleAdd() {
> List permList = new ArrayList();
> Role role = new Role();
> CompoundPropertyModel roleAddModel = new
> CompoundPropertyModel(role);
> final Form form = new RoleAddForm("roleForm",roleAddModel);
>
> add(form);
> final TextField roleComp = new TextField("name");
> final TextArea desComp = new TextArea("description");
> try{
> permList = p.list();
> }catch(SQLException e){
> String err = e.getMessage();
> }
> permComp = new CheckBoxMultipleChoice("permList",permList);
> permComp.setModel(new Model());
> form.add(roleComp);
> form.add(desComp);
> form.add(permComp);
> }
>
> class RoleAddForm extends Form{
> public RoleAddForm(String id, IModel model){
> super(id,model);
> }
> @Override
> public void onSubmit() {
> Role newRole = (Role)getModelObject();
> Role r = new Role(); // Role to a be added
> r.setName(newRole.getName());
> r.setDescription(newRole.getDescription());
> List perms;
> perms = (List) model.getObject(permComp);
> ....................
> ....................
> }
>
> thanks
>
>
> --
> View this message in context:
> http://www.nabble.com/Get-Value-entered-in--CheckBoxMultipleChoice--and-TextFields-tf4896987.html#a14025061
> 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
>
>