Re: Setting a relevant value for radio buttons without using RadioChoice

2008-12-15 Thread ArchieC

Thanks thats taught me something about radio groups that I wasn't able to
find in the books I have. Your example was very helpful.


Michael O'Cleirigh wrote:
 
 Hi ArchieC,
 
 The way RadioGroup works is that it renders to a hidden field and stores 
 the selected value of the selected Radio.
 
 i.e. the rendered markup is not that relevant and the model object for 
 the selected radio will be placed into the model for the RadioGroup when 
 the form submits.
 
 This is how I've used it:
 
 RadioGroup group = new RadioGroup (group, new Model());
 
 
 Radio apple = new Radio (apple, new Model (Fruit.APPLE));
 
 Radio orange = new Radio (orange, new Model (Fruit.ORANGE));
 
 
 group.setModelObject (Fruit.APPLE);
 
 Here by default the first radio is selected.
 
 When the form submits group.getModelObject() will return either 
 Fruit.APPLE or Fruit.ORANGE depending on the selected radio button
 
 In your case the RadioGroup will have as its model Object the value of 
 the selected radio.getModelObject() so whatever the value of user is 
 coming from the PropertyModel() for the selected option.
 
 Regards,
 
 Mike
 
 
 
 RadioGroup group=new RadioGroup(group, new Model(id));
 final ArrayList SelectOptionLevel selectOptionLevel =
 getDdcChoices();
 ListView persons=new ListView(persons, selectOptionLevel) {
 /**
  * 
  */
  private static final long serialVersionUID = 1L;
   

 protected void populateItem(ListItem item) {
 SelectOptionLevel option = (SelectOptionLevel)
 item.getModelObject();
 
 //Exampe of Icon  setting
 item.add(new Label(levelImage,  img
 src='images/icons/icon1.gif'/).setEscapeModelStrings(false));
  
 Radio radio = new Radio(
 radio, 
 new PropertyModel(modelObject, user)   

 ~~ Need to set the value of the radio to
  

 my option.getValue() value.
 );
 item.add(radio);
 item.add(new Label(name, option.getLabel()));
 }
 };
 group.add(persons);
 add(group);

 Apart from not getting a value it all looks great just as I want.
   
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Setting-a-relevant-value-for-radio-buttons-without-using-RadioChoice-tp20978297p21010152.html
Sent from the Wicket - User 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: Setting a relevant value for radio buttons without using RadioChoice

2008-12-15 Thread ArchieC

Thanks Mike, thats just what I needed and works perfectly. Thanks for
explaining it to me.

Archie


-- 
View this message in context: 
http://www.nabble.com/Setting-a-relevant-value-for-radio-buttons-without-using-RadioChoice-tp20978297p21010170.html
Sent from the Wicket - User 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: Setting a relevant value for radio buttons without using RadioChoice

2008-12-15 Thread Nino Saturnino Martinez Vazquez Wael

Hmmm but why not just do it with a LDM? Im a bit puzzled, heres what I do:

RadioGroupEventType eventTypeRadioGroup = new RadioGroupEventType(
   eventType);
   eventTypeRadioGroup.setLabel(new ModelString(Type of 
Event));


   ListViewEventType eventTypesListView = new 
ListViewEventType(

   eventTypeRadios, Arrays.asList(EventType.values())) {

   @Override
   protected void populateItem(ListItemEventType item) {

   item
   .add(new RadioEventType(eventType, item
   .getModel()));
   item.add(new Label(label, new ModelString(item
   .getModel().getObject().getName(;
   item.add(new IconPanel(icons, item.getModelObject()
   .getIconTypes()));

   }
   };
   eventTypesListView.setReuseItems(true);
   eventTypeRadioGroup.setRequired(true);
   eventTypeRadioGroup.add(eventTypesListView);
   add(eventTypeRadioGroup);


Hmm this might be a bad example as I don't use LDM ../ But the important 
line are :
   item.add(new RadioEventType(eventType, item.getModel()));


if you select a certain radio within a group the group will return the 
radios objectmodel...



Michael O'Cleirigh wrote:

Hi Nino,



I believe that this is not what Archie asked about, he wanted to 
place database id's in the value of the radios.. Dont know why he 
wanted to though... I might have gotten it wrongly though..


You're right that he wanted to use the database id but from his 
example there didn't seem to be any client side use of this 
information.   My thinking is that he renders a list of users denoted 
by radio buttons and he want to encode the user id (for a LDM?) as the 
value for use on the form submission processing (i.e. which user to 
work with in the next stage).


Because there is no requirement for the user id on the client side 
there is no reason to care about the value used by the Radio as it is 
just used internally by RadioGroup to know which model object to use 
when the form is submitted.


There is no need for an IChoiceRenderer in this case because the Model 
object of each Radio is never rendered.


He should just encode what he needs in the Model of each Radio and 
expect to find it in the model of the RadioGroup when the form submits.


In his example:

RadioGroup group=new RadioGroup(group, new Model(id));
   final ArrayList SelectOptionLevel selectOptionLevel =
getDdcChoices();
   ListView persons=new ListView(persons, selectOptionLevel) {
   /**
*  */
private static final long serialVersionUID = 1L;
protected void populateItem(ListItem item) {
   SelectOptionLevel option = (SelectOptionLevel)
item.getModelObject();
   //Exampe of Icon  setting
   item.add(new Label(levelImage,  img
src='images/icons/icon1.gif'/).setEscapeModelStrings(false));
Radio radio = new Radio(
   radio, new 
Model(option.getValue())  // -- this is how to wire the Radio Model

   item.add(radio);
   item.add(new Label(name, option.getLabel()));
   }
   };
   group.add(persons);
   add(group);


This will make group.getModelObject() return the option.getValue() 
(i.e the user id) for the selected view item and allow him to proceed 
to the next step.


Regards,

Mike



--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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



Setting a relevant value for radio buttons without using RadioChoice

2008-12-12 Thread ArchieC

Hi All

Im fairly new to wicket and Im going insane with an issue Im having. Ive
been doing a trawl of many forums, Wicket in action, Pro wicket, nabble,
asking questions of friendly people and trying every option I can think of
to work this out for myself using RadioChoice, RadioGroup and odd
combinations of both.

I promise Ive been trying to avoid asking this question on the forum cause
Im expecting someone to call me an idiot. So here is my question.

RadioChoice has the ability to set a value thats not the standard radio7
type value. As far as we (myself and the java developer I am working with)
can see, we cannot seem to do the same for a Radio component in a
RadioGroup. Are we barking up the wrong tree completely or is there a way to
set a value to an ID from our database (for example).

EG.
Instead of input type=radio name=group value=radio7 /

I get input type=radio name=group value=353 /  (353 being the
user_id of one of the accounts, set in option.getValue() - please see code
snippet below). 


Here is the reason we cant just use a RadioChoice. The list we are making
contains about 1000 User account names, each with a user level denoted by an
icon next to each name and radio button. RadioChoice doesnt give the option
of doing different icons (Label with IMG html in it for Icons) for each name
as setPrefix just sets one for the whole list. The list is basically acting
like a drop down box so that I can select one of the accounts for editing on
the next page.

Im really stumped by this as I cant seem to find any reference to setting
this value on a Radio component and I cant believe the creators of Wicket
would make a pointless component.

Here is my code if that helps

RadioGroup group=new RadioGroup(group, new Model(id));
final ArrayList SelectOptionLevel selectOptionLevel =
getDdcChoices();
ListView persons=new ListView(persons, selectOptionLevel) {
/**
 * 
 */
 private static final long serialVersionUID = 1L;
  

protected void populateItem(ListItem item) {
SelectOptionLevel option = (SelectOptionLevel)
item.getModelObject();

//Exampe of Icon  setting
item.add(new Label(levelImage,  img
src='images/icons/icon1.gif'/).setEscapeModelStrings(false));
 
Radio radio = new Radio(
radio, 
new PropertyModel(modelObject, user)  

~~ Need to set the value of the radio to


my option.getValue() value.
);
item.add(radio);
item.add(new Label(name, option.getLabel()));
}
};
group.add(persons);
add(group);

Apart from not getting a value it all looks great just as I want.
-- 
View this message in context: 
http://www.nabble.com/Setting-a-relevant-value-for-radio-buttons-without-using-RadioChoice-tp20978297p20978297.html
Sent from the Wicket - User 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: Setting a relevant value for radio buttons without using RadioChoice

2008-12-12 Thread Nino Saturnino Martinez Vazquez Wael

Does'nt it use a choice renderer?

ArchieC wrote:

Hi All

Im fairly new to wicket and Im going insane with an issue Im having. Ive
been doing a trawl of many forums, Wicket in action, Pro wicket, nabble,
asking questions of friendly people and trying every option I can think of
to work this out for myself using RadioChoice, RadioGroup and odd
combinations of both.

I promise Ive been trying to avoid asking this question on the forum cause
Im expecting someone to call me an idiot. So here is my question.

RadioChoice has the ability to set a value thats not the standard radio7
type value. As far as we (myself and the java developer I am working with)
can see, we cannot seem to do the same for a Radio component in a
RadioGroup. Are we barking up the wrong tree completely or is there a way to
set a value to an ID from our database (for example).

EG.
Instead of input type=radio name=group value=radio7 /

I get input type=radio name=group value=353 /  (353 being the
user_id of one of the accounts, set in option.getValue() - please see code
snippet below). 



Here is the reason we cant just use a RadioChoice. The list we are making
contains about 1000 User account names, each with a user level denoted by an
icon next to each name and radio button. RadioChoice doesnt give the option
of doing different icons (Label with IMG html in it for Icons) for each name
as setPrefix just sets one for the whole list. The list is basically acting
like a drop down box so that I can select one of the accounts for editing on
the next page.

Im really stumped by this as I cant seem to find any reference to setting
this value on a Radio component and I cant believe the creators of Wicket
would make a pointless component.

Here is my code if that helps

RadioGroup group=new RadioGroup(group, new Model(id));
final ArrayList SelectOptionLevel selectOptionLevel =
getDdcChoices();
ListView persons=new ListView(persons, selectOptionLevel) {
/**
 * 
 */

 private static final long serialVersionUID = 1L;
  


protected void populateItem(ListItem item) {
SelectOptionLevel option = (SelectOptionLevel)
item.getModelObject();

//Exampe of Icon  setting

item.add(new Label(levelImage,  img
src='images/icons/icon1.gif'/).setEscapeModelStrings(false));
 
Radio radio = new Radio(
radio, 
new PropertyModel(modelObject, user)  
~~ Need to set the value of the radio to

my option.getValue() value.

);
item.add(radio);
item.add(new Label(name, option.getLabel()));
}
};
group.add(persons);
add(group);

Apart from not getting a value it all looks great just as I want.
  


--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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



Re: Setting a relevant value for radio buttons without using RadioChoice

2008-12-12 Thread ArchieC

Erm from looking at the docs, Both Radio and RadioGroup only have an Id and
an IModel in their constructor unlike RadioChoice which has a choice
renderer.


-- 
View this message in context: 
http://www.nabble.com/Setting-a-relevant-value-for-radio-buttons-without-using-RadioChoice-tp20978297p20978462.html
Sent from the Wicket - User 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: Setting a relevant value for radio buttons without using RadioChoice

2008-12-12 Thread Nino Saturnino Martinez Vazquez Wael
Hmm it does'nt.. And you cant even overrride getValue() on radio since 
it's final... :( Come it, I posted something about the fact that radio 
uses autoIndex once regarding jmeter..


But you can override onComponentTag, I guess I'd probably roll my own 
and rip most from Radio, but let it take the optional choicerenderer..


Nino Saturnino Martinez Vazquez Wael wrote:

Does'nt it use a choice renderer?

ArchieC wrote:

Hi All

Im fairly new to wicket and Im going insane with an issue Im having. Ive
been doing a trawl of many forums, Wicket in action, Pro wicket, nabble,
asking questions of friendly people and trying every option I can 
think of

to work this out for myself using RadioChoice, RadioGroup and odd
combinations of both.

I promise Ive been trying to avoid asking this question on the forum 
cause

Im expecting someone to call me an idiot. So here is my question.

RadioChoice has the ability to set a value thats not the standard 
radio7
type value. As far as we (myself and the java developer I am working 
with)

can see, we cannot seem to do the same for a Radio component in a
RadioGroup. Are we barking up the wrong tree completely or is there a 
way to

set a value to an ID from our database (for example).

EG.
Instead of input type=radio name=group value=radio7 /

I get input type=radio name=group value=353 /  (353 being the
user_id of one of the accounts, set in option.getValue() - please see 
code

snippet below).

Here is the reason we cant just use a RadioChoice. The list we are 
making
contains about 1000 User account names, each with a user level 
denoted by an
icon next to each name and radio button. RadioChoice doesnt give the 
option
of doing different icons (Label with IMG html in it for Icons) for 
each name
as setPrefix just sets one for the whole list. The list is basically 
acting
like a drop down box so that I can select one of the accounts for 
editing on

the next page.

Im really stumped by this as I cant seem to find any reference to 
setting
this value on a Radio component and I cant believe the creators of 
Wicket

would make a pointless component.

Here is my code if that helps

RadioGroup group=new RadioGroup(group, new Model(id));
final ArrayList SelectOptionLevel selectOptionLevel =
getDdcChoices();
ListView persons=new ListView(persons, 
selectOptionLevel) {

/**
 *  */
 private static final long serialVersionUID = 1L;
 
protected void populateItem(ListItem item) {

SelectOptionLevel option = (SelectOptionLevel)
item.getModelObject();
//Exampe of Icon  setting
item.add(new Label(levelImage,  img
src='images/icons/icon1.gif'/).setEscapeModelStrings(false));
 Radio radio = new Radio(
radio, new 
PropertyModel(modelObject, user)  ~~ Need 
to set the value of the radio to

my option.getValue() value.

);
item.add(radio);
item.add(new Label(name, option.getLabel()));
}
};
group.add(persons);
add(group);

Apart from not getting a value it all looks great just as I want.
  




--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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



Re: Setting a relevant value for radio buttons without using RadioChoice

2008-12-12 Thread Michael O'Cleirigh

Hi ArchieC,

The way RadioGroup works is that it renders to a hidden field and stores 
the selected value of the selected Radio.


i.e. the rendered markup is not that relevant and the model object for 
the selected radio will be placed into the model for the RadioGroup when 
the form submits.


This is how I've used it:

RadioGroup group = new RadioGroup (group, new Model());


Radio apple = new Radio (apple, new Model (Fruit.APPLE));

Radio orange = new Radio (orange, new Model (Fruit.ORANGE));


group.setModelObject (Fruit.APPLE);

Here by default the first radio is selected.

When the form submits group.getModelObject() will return either 
Fruit.APPLE or Fruit.ORANGE depending on the selected radio button


In your case the RadioGroup will have as its model Object the value of 
the selected radio.getModelObject() so whatever the value of user is 
coming from the PropertyModel() for the selected option.


Regards,

Mike




RadioGroup group=new RadioGroup(group, new Model(id));
final ArrayList SelectOptionLevel selectOptionLevel =
getDdcChoices();
ListView persons=new ListView(persons, selectOptionLevel) {
/**
 * 
 */

 private static final long serialVersionUID = 1L;
  


protected void populateItem(ListItem item) {
SelectOptionLevel option = (SelectOptionLevel)
item.getModelObject();

//Exampe of Icon  setting

item.add(new Label(levelImage,  img
src='images/icons/icon1.gif'/).setEscapeModelStrings(false));
 
Radio radio = new Radio(
radio, 
new PropertyModel(modelObject, user)  
~~ Need to set the value of the radio to

my option.getValue() value.

);
item.add(radio);
item.add(new Label(name, option.getLabel()));
}
};
group.add(persons);
add(group);

Apart from not getting a value it all looks great just as I want.
  



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



Re: Setting a relevant value for radio buttons without using RadioChoice

2008-12-12 Thread Nino Saturnino Martinez Vazquez Wael

Hi Michael

I believe that this is not what Archie asked about, he wanted to place 
database id's in the value of the radios.. Dont know why he wanted to 
though... I might have gotten it wrongly though..


regards Nino

Michael O'Cleirigh wrote:

Hi ArchieC,

The way RadioGroup works is that it renders to a hidden field and 
stores the selected value of the selected Radio.


i.e. the rendered markup is not that relevant and the model object for 
the selected radio will be placed into the model for the RadioGroup 
when the form submits.


This is how I've used it:

RadioGroup group = new RadioGroup (group, new Model());


Radio apple = new Radio (apple, new Model (Fruit.APPLE));

Radio orange = new Radio (orange, new Model (Fruit.ORANGE));


group.setModelObject (Fruit.APPLE);

Here by default the first radio is selected.

When the form submits group.getModelObject() will return either 
Fruit.APPLE or Fruit.ORANGE depending on the selected radio button


In your case the RadioGroup will have as its model Object the value of 
the selected radio.getModelObject() so whatever the value of user is 
coming from the PropertyModel() for the selected option.


Regards,

Mike




RadioGroup group=new RadioGroup(group, new Model(id));
final ArrayList SelectOptionLevel selectOptionLevel =
getDdcChoices();
ListView persons=new ListView(persons, 
selectOptionLevel) {

/**
 *  */
 private static final long serialVersionUID = 1L;
 
protected void populateItem(ListItem item) {

SelectOptionLevel option = (SelectOptionLevel)
item.getModelObject();
//Exampe of Icon  setting
item.add(new Label(levelImage,  img
src='images/icons/icon1.gif'/).setEscapeModelStrings(false));
 Radio radio = new Radio(
radio, new 
PropertyModel(modelObject, user)  ~~ Need 
to set the value of the radio to

my option.getValue() value.

);
item.add(radio);
item.add(new Label(name, option.getLabel()));
}
};
group.add(persons);
add(group);

Apart from not getting a value it all looks great just as I want.
  



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



--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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



Re: Setting a relevant value for radio buttons without using RadioChoice

2008-12-12 Thread Michael O'Cleirigh

Hi Nino,



I believe that this is not what Archie asked about, he wanted to place 
database id's in the value of the radios.. Dont know why he wanted to 
though... I might have gotten it wrongly though..


You're right that he wanted to use the database id but from his example 
there didn't seem to be any client side use of this information.   My 
thinking is that he renders a list of users denoted by radio buttons and 
he want to encode the user id (for a LDM?) as the value for use on the 
form submission processing (i.e. which user to work with in the next stage).


Because there is no requirement for the user id on the client side there 
is no reason to care about the value used by the Radio as it is just 
used internally by RadioGroup to know which model object to use when the 
form is submitted.


There is no need for an IChoiceRenderer in this case because the Model 
object of each Radio is never rendered.


He should just encode what he needs in the Model of each Radio and 
expect to find it in the model of the RadioGroup when the form submits.


In his example:

RadioGroup group=new RadioGroup(group, new Model(id));
   final ArrayList SelectOptionLevel selectOptionLevel =
getDdcChoices();
   ListView persons=new ListView(persons, selectOptionLevel) {
   /**
*  */
private static final long serialVersionUID = 1L;
protected void populateItem(ListItem item) {
   SelectOptionLevel option = (SelectOptionLevel)
item.getModelObject();
   //Exampe of Icon  setting
   item.add(new Label(levelImage,  img
src='images/icons/icon1.gif'/).setEscapeModelStrings(false));
Radio radio = new Radio(
   radio, new 
Model(option.getValue())  // -- this is how to wire the Radio Model

   item.add(radio);
   item.add(new Label(name, option.getLabel()));
   }
   };
   group.add(persons);
   add(group);


This will make group.getModelObject() return the option.getValue() (i.e 
the user id) for the selected view item and allow him to proceed to the 
next step.


Regards,

Mike