You have to give the radio group a model, that is backed by your question 
object, not only the current value of its answer:

RadioGroup answer = new RadioGroup("answer", new PropertyModel(question, 
"answer"));

Kurt R. Hoehn wrote:
> I never really know what to put in the subject, but here is my question.
>
> I'm putting together a series of questions that exist under one profile
> and they are simple yes/no radio buttons and the user clicks yes or no
> for the question.  I put together the form and it pulls and displays the
> information with out error in an edit mode, but when I submit the form
> with changes to the questions, they don't seem to make it from the form.
>
> I have been successful with a radio group outside of a listview and the
> radio buttons inside the listview, but this is the reverse of that. 
>
> Does Wicket allow this or is there a workaround to this?
>
> Here is my code:
>
> Environment:
>    Wicket 1.x branch
>    Spring
>    Hibernate
>    Java 1.5_8
>    FirebirdSql
>    Ubuntu 6.10 (linux)
>
> Domain Objects:
>
> public class Profile
> {
>     ...
>     private String identity;
>     private String name;
>     ...
> }  
>
> public class SurveyQuestion
> {
>     ...
>     private String identity;
>     private String question;
>     private Boolean answer;
>     ...
> }
>
> Wicket Page Object:
> public class SurveyPage extends WebPage
> {
>     ...
>
>     public SurveyPage()
>     {
>       Questions questions = new Questions();
>         questions.setProfile( profileDao.findProfile() );
>
> questions.setQuestions( questionDao.findQuestions(questions.getProfile()));
>         CompoundPropertyModel survey = new
> CompoundPropertyModel(questions);
>         add(new SurveyForm("surveyForm", questions));
>     }
>
>     class SurveyForm extends Form
>     {
>         public SurveyForm(String s, final IModel iModel)
>         {
>             super(s, iModel);
>
>             ...
>
>             ListView survey = new ListView("survey") {
>                 protected void populateItem(ListItem listItem) {
>                     SurveyQuestion question = (SurveyQuestion)
> listItem.getModelObject();
>
>                     listItem.add(new Label("question",
> question.getQuestion()));
>                     RadioGroup answer = new RadioGroup("answer", new
> Model(question.getAnswer()));
>                     answer.add(new Radio("true", new Model(true)));
>                     answer.add(new Radio("false", new Model(false)));
>                     listItem.add(answer);
>                 }
>             };
>
>             survey.setReuseItems(true);
>             add(survey);
>
>             ...
>         }
>
>         public void onSubmit()
>         {
>             Profile profile =
> ((Questions)getModel().getObject()).getProfile();
>
>             PageParameters parameters = new PageParameters();
>             parameters.add("identity", center.getIdentity());
>             parameters.add("ro", "true");
>             setResponsePage(SurveyPage.class, parameters );
>
>             profileDao.makePersistent(profile);
>       
>           // Doing this to see if the domain object is being updated from the
> form. 
>             for(Object survey:
> ((Questions)getModel().getObject()).getSurvey())
>             {
>                 System.out.println( "Answer:  " +
> ((ProfileSurvey)survey).getAnswer() );
>             }
>         }
>     }
> }
>
> class Questions implements Serializable
> {
>     private Profile profile;
>     private List survey;
>
>     ...
> }
>
> SurveyPage.html
>
> <form wicket:id="surveyForm">
> ...
> <table>
>     <tr wicket:id="survey">
>         <td><span wicket:id="question"></span></td>
>         <td><span wicket:id="answer">
>               <input type="radio" wicket:id="true">Yes&nbsp;<input 
> type="radio"
> wicket:id="false">No</span>
>         </td>
>     </tr>
> </table>
> ...
> </form>
>
> TIA,
>
> -kurt
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>   


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to