• 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

h:selectOneRadio automatically creates Table

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh... this is working...
Thank you very muchhhhh
bye...
[ April 03, 2006: Message edited by: Nishita Jain ]
 
You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic