*
The moose likes JSF and the fly likes JSF SelectOneRadio and inputText Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF SelectOneRadio and inputText " Watch "JSF SelectOneRadio and inputText " New topic
Author

JSF SelectOneRadio and inputText

Andy Holm
Ranch Hand

Joined: Jul 03, 2008
Posts: 86
I am trying to create a select one radio button with one option for "Other" where the user can then type input in an inputText field. This "Other" option is the last item in the list, and I am having trouble laying out the textBox to correspond with the option. Currently, the inputText box is in the middle of the second column rather than next to the "Other" selectItem. Here is my code:

Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
I sugges you to use Tomahawk's t:selectOneRadio component. It has an additional 'layout' attribute value, namely 'spread'. If you use it, you can place every radiobutton everywhere in the form as you want. This makes positioning easy.
Andy Holm
Ranch Hand

Joined: Jul 03, 2008
Posts: 86
Currently, I am not using Tomahawk or myFaces. I am using JSP. Is there a way to do it without Tomahawk, or is Tomahawk compatible with JSP?
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Uh.

Tomahawk is just a component library which adds extended components on top of basic JSF components.

Compatiblity with JSP is not an issue. It´s just a view technology.
eve agostini
Ranch Hand

Joined: Nov 01, 2005
Posts: 43
that's because you have 2 columns...in the first there is the selectoneradio and in the sencond these is the input text...anything you put inside the selectoneradio, it just stays inside that.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
No.. The h:selectOneRadio itself also renders a table and that´s the problem.
eve agostini
Ranch Hand

Joined: Nov 01, 2005
Posts: 43
my answer was correct I just explained what happened.
If the h:selectOneRadio itself renders a table, that's another story. Then, maybe the problem is that Andy would like to put the h:inputText inside the table rendered by the h:selectOneRadio, rather than inside the pnel grid.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
There is no way to put the inputText in the table rendered by selectOneRadio.

That´s why I suggested to use the Tomahawk´s variant which has a layout="spread" attribute. This way the selectOneRadio doesn´t render anything but the radiobuttons and you can place the radiobuttons everywhere in the form to your taste.
eve agostini
Ranch Hand

Joined: Nov 01, 2005
Posts: 43
Bauke Scholtz wrote:There is no way to put the inputText in the table rendered by selectOneRadio.


Ok I think it's pretty correct if I call this a problem :P

Anyway I was just explaining something about how a panel grid works, which probably was not very clear to Andy.

So I just said that that was the problem, if you have a solution for it that's good.

EDIT:

By the way, if it's just a problem of layout, you could solve it by an appropriate style class
 
 
subject: JSF SelectOneRadio and inputText
 
Similar Threads
Dynamic Radio Button
Default selection of Radio Button when added to h:panelGrid
Radio
selectOneRadio in several columns...
How to make one of the Radio button default selected