You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by wiki <wa...@hotmail.com> on 2008/02/07 17:45:01 UTC
how to save CheckBoxMultipleChoice values into database
Hi I have a class of MultipleChoiceSingleSelectquestion which has one to many
relationship with Answers in Hibernate
here is the code to display questions with list of answers
public class ViewQuestions extends AuthenticatedWebPage {
private static final int ITEM_PER_PATE = 1;
/**
* Creates a new instance of ViewBooks
*/
public ViewQuestions(Questionaire qaire) {
Border border = new QuestionaireBorder("questionBorder");
add(border);
final QuestionsDataProvider dataProvider = new
QuestionsDataProvider(qaire);
DataView questionView = new QuestionDataView("questions",
dataProvider);
questionView.setItemsPerPage(ITEM_PER_PATE);
border.add(questionView);
border.add(new CustomPagingNavigator("navigator", questionView));
}
class QuestionDataView extends DataView {
public QuestionDataView(String id, IDataProvider dataProvider) {
super(id, dataProvider);
}
protected void populateItem(Item item) {
MCSSQuestion question = (MCSSQuestion) item.getModelObject();
item.setModel(new CompoundPropertyModel(question));
item.add(new Label("mcssquestionid"));
item.add(new Label("questiontext"));
item.add(new Label("questionaire.Title"));
List<MCSSAns> a=question.getMcssans();
ChoiceRenderer renderer= new ChoiceRenderer("ansbody");
Form form=new Form("form");
form.add(new CheckBoxMultipleChoice("mcssans",new
PropertyModel(question,"mcssans"),a,renderer));
item.add(form);
}
@Override
protected Item newItem(final String id, int index, final IModel
model) {
return new OddEvenItem(id, index, model);
}
}
The problem is How to select an answer from lists of answer and save it to
the database class.I have a class Selected answer in database but don't know
how wicket will save to the database.I went through wicket stuff examples
but I couldn't find List with one to Many relationship
--
View this message in context: http://www.nabble.com/how-to-save-CheckBoxMultipleChoice-values-into-database-tp15337939p15337939.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