aspose file tools*
The moose likes JSF and the fly likes h:selectOneRadio  automatically creates Table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "h:selectOneRadio  automatically creates Table" Watch "h:selectOneRadio  automatically creates Table" New topic
Author

h:selectOneRadio automatically creates Table

Nishita Jain
Ranch Hand

Joined: Mar 30, 2006
Posts: 97
hi,
i m new to jsf.
i m making an app with struts and jsf.
i need to create radio button in diff row but when i used <h:selectOneRadio>
or similar tag and run my app <h:selectOneRadio> will automatically creates table.
I mean if i write
<h:selectOneRadio id="correctAns" value="#{QuestionBean.correctAns}" >
<f:selectItem itemValue="0" itemLabel="Answer1" />
<f:selectItem itemValue="1" itemLabel="Answer2" />
<f:selectItem itemValue="2" itemLabel="Answer3" />
<f:selectItem itemValue="3" itemLabel="Answer4" />
<f:selectItem itemValue="4" itemLabel="Answer5" />
</h:selectOneRadio>

html generated will be

<table id="addMultiChoiceQuestion:correctAns">
<tr>
<td>
<label><input type="radio" name="addMultiChoiceQuestion:correctAns" value="0"> Answer1</input></label></td>
<td>
<label><input type="radio" checked name="addMultiChoiceQuestion:correctAns" value="1"> Answer2</input></label></td>
<td>
<label><input type="radio" name="addMultiChoiceQuestion:correctAns" value="2"> Answer3</input></label></td>

<td>
<label><input type="radio" name="addMultiChoiceQuestion:correctAns" value="3"> Answer4</input></label></td>
<td>
<label><input type="radio" name="addMultiChoiceQuestion:correctAns" value="4"> Answer5</input></label></td>
</tr>
</table>
Is der any way to avoid that.

Thank you.
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
set the layout attribute. Not sure if this is what you are looking for .

<h:selectOneRadio id="correctAns" value="#{QuestionBean.correctAns}"
layout="pageDirection">
<f:selectItem itemValue="0" itemLabel="Answer1" />
<f:selectItem itemValue="1" itemLabel="Answer2" />

</h:selectOneRadio>

Thanks,
[ March 30, 2006: Message edited by: Rajeev Ravindran ]

SCJP, SCWCD, SCBCD, Oracle Certified Professional (SQL n PL/SQL)
Nishita Jain
Ranch Hand

Joined: Mar 30, 2006
Posts: 97
Originally posted by Rajeev Ravindran:
set the layout attribute. Not sure if this is what you are looking for .

<h:selectOneRadio id="correctAns" value="#{QuestionBean.correctAns}"
layout="pageDirection">
<f:selectItem itemValue="0" itemLabel="Answer1" />
<f:selectItem itemValue="1" itemLabel="Answer2" />

</h:selectOneRadio>

Thanks,

[ March 30, 2006: Message edited by: Rajeev Ravindran ]
Nishita Jain
Ranch Hand

Joined: Mar 30, 2006
Posts: 97
hi Thank 4 reply.
but layout="pageDirection" is not working still table is created in dat. the only diff is that now radio buttons appears Vertically.

now code is
<table id="addMultiChoiceQuestion:correctAns">
<tr>
<td>
<label><input type="radio" name="addMultiChoiceQuestion:correctAns" value="0"> Answer1</input></label></td>
</tr>

<tr>
<td>
<label><input type="radio" checked name="addMultiChoiceQuestion:correctAns" value="1"> Answer2</input></label></td>
</tr>
<tr>
<td>
<label><input type="radio" name="addMultiChoiceQuestion:correctAns" value="2"> Answer3</input></label></td>
</tr>
<tr>

<td>
<label><input type="radio" name="addMultiChoiceQuestion:correctAns" value="3"> Answer4</input></label></td>
</tr>
<tr>
<td>
<label><input type="radio" name="addMultiChoiceQuestion:correctAns" value="4"> Answer5</input></label></td>
</tr>
</table>

can u suggest some other option.
Thank u.
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
Originally posted by Nishita Jain:

i need to create radio button in diff row


You don't like tables ? i dont think you can stop JSF from creating tables, it the way JSF align the components.

Thanks,
Nishita Jain
Ranch Hand

Joined: Mar 30, 2006
Posts: 97
hi,
ya i really dont like tables
bcz it is creating a lot problem bcz my page design is lik dis

radio1 -- text field

radio2 -- text field

radio3 -- text field

radio4 -- text field

(same id for 4 radio as i have 2 select only 1 radio)
when i execute the page,
for each radio table wiil be gennerated . and this page wil only run if i select last radio.

bcz last radio have its own table.
so can u plzzz find solution


Thank u v much in advance

Nishita
Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
when you post questions/answers next time
please take some time to spell out the words
d - the
u - you
bcz - because
v - very
lik - like
dis - this

u knw wat i mean

anyway what you think about the code below ?

<h:form styleClass="form" id="form1">
<h: panelGroup>
<h: panelGrid columns="2">
<h: panelGrid columns="1">
<h:selectOneRadio disabledClass="selectOneRadio_Disabled"
styleClass="selectOneRadio" id="radio1" layout="pageDirection">
<f:selectItem itemValue="1" itemLabel="answer1" />
<f:selectItem itemValue="2" itemLabel="answer2" />
<f:selectItem itemValue="Value2" itemLabel="answer3" />
</h:selectOneRadio>
</h: panelGrid>
<h: panelGrid columns="1">
<h:inputText value="text1" />
<h:inputText value="text2" />
<h:inputText value="text3" />
</h: panelGrid>
</h: panelGrid>
</h: panelGroup>
</h:form>

Thanks,
[ March 31, 2006: Message edited by: Rajeev Ravindran ]
Nishita Jain
Ranch Hand

Joined: Mar 30, 2006
Posts: 97
oh... this is working...
Thank you very muchhhhh
bye...
[ April 03, 2006: Message edited by: Nishita Jain ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: h:selectOneRadio automatically creates Table
 
Similar Threads
simple alignment problem with select one radio
Nested Loop and getting parameter problem
selectOneRadio in several columns...
JSF2 Populate SelectOneRadio with Enum values
selectOneRadio - javascript get value