Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

h:selectOneRadio automatically creates Table

 
Nishita Jain
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh... this is working...
Thank you very muchhhhh
bye...
[ April 03, 2006: Message edited by: Nishita Jain ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic