• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Doubt in JSF

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

We are planning to develop an online examination in JSF. The exam contains 25 questions, there will be four answers (radio buttons) for each question. User can select one option against each question. Can anyone tell how to do it in JSF? is it possible to do it using data table? how to display the questions.


Thanks.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think using datatable would not be ideal in this case.
Using datatable you could present your questions like this

where [0] represents a radio bottom.
The problem here is that each radio button is independent of each other as there seems to be no way to link these using <h:selectOneRadio> and <f:selectItem> as each selectItem will be in a different <h:column> sub tag of the <h:dataTable>. So they would not behave as a group of radio buttons, user would be able to select all four options at once.

I think the way you should proceed is to have a page for each question and a <h:selectOneRadio> with 4 <f:selectItem> tags with itemLabel mappings to the answer strings.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually you can do it in JSf using DataTable.

My suggestion is that you can have a data table with two columns...one for the question and one for the options.

The value of your DataTable will be mapped to List of Entities, which contain a Question and a list of options.
something like this:

<h:dataTable border="1" value="#{QuestionBankMB.ClassTest}" var="test" binding="#{QuestionBankMB.dataTable}">

<h:column id="column1">
<f:facet name="header">
<h:outputText value="Question"></h:outputText>
</f:facet>
<h:outputText value="#{test.question}"></h:outputText>
</h:column>

<h:column id="column2">
<f:facet name="header">
<h:outputText value="Memeber Id"></h:outputText>
</f:facet>
<h:selectOneRadio id="selRate" value="#{question.optionSelected}">
<f:selectItems value="#{question.optionsList} />
</h:selectOneRadio>
</h:column>



and bind the datatable to a HTMLDataTable and using the getDataTable().getRowData(), you can get the detail of each row.

I hope this helps.

 
All of life is a contant education - Eleanor Roosevelt. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic