3 Replies Latest reply on Apr 30, 2008 5:00 PM by nicksan

    New to RichFaces. SubTable and Backing Bean Question.

    nicksan

      Hello All!

      Completely newbie to RichFaces here. We are using MyFaces and after some frustrations with the components we decided to go with RichFaces. So far, looks pretty good.

      I am working on creating a page with an UPDATEABLE DataTable and SubTable. I've searched for a simple tutorial on using <rich:subTable> to no avail. I did check out the RichFaces demo however the demo only has the sample JSP code and not the code for the backing bean.

      For now, it's a simple survey web page:

      I have 4 tables.
      tb_question : question_id int, question_description varchar(255)
      tb_category : category_id int, category_description varchar(255)
      tb_question_category_mapping : question_id int, category_id int
      tb_user_survey : user_id varchar(25), category_id int, question_id int, answer int (answer: 1=yes, 2=no, 3=not tested, 4=not applicable)

      I want something like this on my jsp

      Category 1
      Question 1 Answer(Radio Buttons)
      Question 2 Answer(Radio Buttons)
      Category 2
      Question 3 Answer(Radio Buttons)
      Question 4 Answer(Radio Buttons)
      Question 5 Answer(Radio Buttons)
      Category 3
      Question 6 Answer(Radio Buttons)

      Etc...

      Right now I have a webpage working that lists everything straight up with no subtable. Looks like this:
      Category 1 Question 1 Answer(Radio Buttons)
      Category 1 Question 2 Answer(Radio Buttons)
      Category 2 Question 3 Answer(Radio Buttons)
      Category 2 Question 4 Answer(Radio Buttons)
      Category 2 Question 5 Answer(Radio Buttons)
      Category 3 Question 6 Answer(Radio Buttons)

      This works fine. I just have a List in the backing bean and also have a binding to a org.richfaces.component.html.HtmlDataTable variable in the backing bean.

      My newbie question is, how is everything re-arranged for using the subTable?

      Do I need to have 2 Lists in the backing bean? If so, how does the 2 tables tie in to eachother? How does it know for Category 1, there are 2 questions, Question 1 and Question 2?

      Any help is much appreciated!

      Thx
      Nick