aspose file tools*
The moose likes JSF and the fly likes Doubt in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Doubt in JSF" Watch "Doubt in JSF" New topic
Author

Doubt in JSF

Maya Pillai
Ranch Hand

Joined: Jul 17, 2008
Posts: 60
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.
Manu dv
Greenhorn

Joined: Jun 30, 2010
Posts: 8
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.


It's better to burn out than to fade away
Deepak Mahalingam
Greenhorn

Joined: Jul 09, 2010
Posts: 12
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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt in JSF