Hi,

I have been looking at how to set the value of a radio input field to a value of my choosing.
If I use the Radio and Radio Group code as shown here: 
http://pastebin.com/m40b9b073
I get html such as

<input wicket:id="radio" type="radio" value="radio2" name="selectionGroup"/> <input wicket:id="radio" type="radio" value="radio3" name="selectionGroup"/>
...

whereas I was hoping to get

<input wicket:id="radio" type="radio" value="http://bblfish.net/people/henry/card#me " name="selectionGroup"/>

Searching the web I found the thread "Setting a relevant value for radio buttons without using RadioChoice" from December 2008 ( http://tinyurl.com/cpfj49 ) I came to understand that RadioGroup saves all the mapping itself. I would rather it did not, reducing the load on the server, as I am using URLs as primary keys. This more RESTful and I think clearner.

So if I cannot set this using the Radio component I thought perhaps I can use an AttributeModifier with code like the following:

class ChoiceForm extends Form {

   ChoiceForm(String string, List<Agent> agents) {
      super(string);
      ListView persons;
      add(persons=new ListView("person", agents) {

         @Override
         protected void populateItem(ListItem item) {
            Agent agt = (Agent) item.getModelObject();
Component radio = item.get("radio"); //this is wrong! looking for solution radio.add(new AttributeModifier("value",new Model(agt.getWebID().toString())));
            item.add(new Label("name", agt.getName()));
            item.add(new Label("uri", agt.getWebID().toString()));
         }
      });
      persons.setReuseItems(true);
   }
}

I am not sure how one can get a component in the populateItem function so that one can then
change the attribute for it.

The html I am trying to work with is this:

<form wicket:id="select">
  <input type="submit" name="Select"/>
  <span wicket:id="selectionGroup">
  <span wicket:id="person">
    <p>
<input wicket:id="radio" type="radio" value="http://bblfish.net/people/henry/card#me "/>
    <table>
      <tr><td>Name</td><td wicket:id="name">Henry Story</td></tr>
<tr><td>URI</td><td wicket:id="uri">http://bblfish.net/people/henry/card#me </td></tr>
    </table>
    </p>
  </span>
  </span>
  <input type="submit" name="Select"/>
 </form>

Any suggestions as to where I should look for more information. I have searched all over the internet and Wicket In Action, but without success.

        Henry Story

Blog: http://blogs.sun.com/bblfish


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to