jsf datatable inside datatable rendering problem
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   suresh_r
Posted On:   Wednesday, July 6, 2011 09:19 AM

I am creating an online survey application using JSF with IceFaces component library. The survey can have any number of questions. Each question can be any one of the types checkbox, radio button, etc with multiple options. For this, I am using a datatable to dynamically add a question to the survey. Inside that datatable, I am using another datatable to add option to the survey. Now the problem is, if I keep on click on add question button, in the outer data table, question is being added without any issue. Once I click on inner data table to add a option to any of the added questions, I am able to add. But after that, if I click again on add question button, it is not working. This is my xhtml code:    More>>

I am creating an online survey application using JSF with IceFaces component library. The survey can have any number of questions. Each question can be any one of the types checkbox, radio button, etc with multiple options.

For this, I am using a datatable to dynamically add a question to the survey. Inside that datatable, I am using another datatable to add option to the survey.

Now the problem is, if I keep on click on add question button, in the outer data table, question is being added without any issue. Once I click on inner data table to add a option to any of the added questions, I am able to add. But after that, if I click again on add question button, it is not working.

This is my xhtml code:





















This is the add question method:

public String addQuestion() {
SurveyDTO addSurveyQuestionDTO = new SurveyDTO();
questionNum = surveyQuestionList.size();
addSurveyQuestionDTO.setQuestionNum(questionNum);
surveyQuestionList.add(addSurveyQuestionDTO);
return "createSurvey";
}

This is the add option method:

public String addOption() {
FacesContext context = FacesContext.getCurrentInstance();
if (context.getExternalContext().getRequestParameterMap().get("questionNum") != null) {
String questionNum = (String) context.getExternalContext().getRequestParameterMap().get("questionNum");
int selectedQuestionNum = Integer.valueOf(questionNum);
SurveyQuestionOptionDTO surveyQuestionOptionDTO = new SurveyQuestionOptionDTO();
surveyQuestionList.get(selectedQuestionNum).getSurveyQuestionOptionList().add(surveyQuestionOptionDTO);
}
return "createSurvey";
}    <<Less
About | Sitemap | Contact