0

I want something with design like many checkboxes and user must select only one checkbox. There is h:selectManyCheckbox, but thre isn't h:selectOneCheckbox. I also know to do it with h:selectOneRadio, but it shows all radio buttons in one line, although I write <br/> between <f:selectItem>.

How can I do it in JSF 2.0?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Aram Gevorgyan
  • 2,175
  • 7
  • 37
  • 57

1 Answers1

2

You can use h:selectOneRadio with layout attribute set to pageDirection in order to render the radio buttons vertically.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
partlov
  • 13,789
  • 6
  • 63
  • 82
  • Thanks, but it isn't the best solution. I want it look like checkbox. – Aram Gevorgyan Dec 30 '12 at 19:25
  • Why exactly isn't it "the best solution"? Why exactly do you want to do it differently from the standards? Why exactly do you want to use a **single** selection using **checkboxes**? – BalusC Dec 30 '12 at 19:31
  • I don't think you should do it. BalusC told you reasons. For me it is like you eat soup with fork. But if you want to do it, you need to create javascript function and manage checkbox states on your own. – partlov Dec 30 '12 at 19:32
  • @BalusC: Suppose I have list of candidates and voter must select only one candidate. Why isn't ""best solution" , why not radio button, because it's design doesn't look good. I want it look smth like checkbox. – Aram Gevorgyan Dec 30 '12 at 19:39
  • 1
    It's after all your choice. You'll only end up with 2 major problems: 1) You're completely confusing endusers by using checkboxes for single selection. The average enduser expects a radio button for that as they are for more than a decade in web forms been used for single selection. 2) You'd need to bring in some ugly JavaScript based hack in order to uncheck other checkboxes when another one is checked (which in turn would totally cease to work when the enduser has JavaScript disabled, like in half of the current mobile browser population). If you want to change the look'n'feel, just use CSS. – BalusC Dec 30 '12 at 19:46
  • Ok, thanks. I don't want some ugly javascript. So the main point of my question is to know, maybe it is such tool, or I can do it in some easy way. But as I see the best way is radiobutton. – Aram Gevorgyan Dec 30 '12 at 19:52