0

I want to put a label beside the radio button.

enter image description here

HtmlSelectOneRadio has a setLabel(String s) method. But it does not work.

Is there a way to do that without using another library?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Eduardo Briguenti Vieira
  • 4,351
  • 3
  • 37
  • 49
  • Ah, the eternal question . [Use `` instead, or write a custom renderer](http://stackoverflow.com/questions/7435039/jsf-2-0-hselectoneradio-renders-table-element/7435111#7435111). By the way, if you do as if you're defining the view in a normal JSP/Facelets file like everyone, then it should be easier to find answers. There's namely **nothing** which is impossible in JSP/Facelets and only possible in Java. If you've found the answer for JSP/Facelets file, then you should be easily able to port it to Java. – BalusC Feb 07 '14 at 13:58
  • Hi @BalusC ! Tks for the response. The project is using jsf-facelets version 1.1.15. Is there any problem including the tomahawk dependency? – Eduardo Briguenti Vieira Feb 07 '14 at 16:39
  • HI @BalusC. I changed the question. I want to print a label beside the radio button, no matter if it's a div or a table. I think the warning about duplicate could be removed now. – Eduardo Briguenti Vieira Feb 07 '14 at 17:55

1 Answers1

0

It is done by using the setItemLabel in the UISelectItem object.

Then using some css to let it the way you want.

UISelectItem selectItemSim = new UISelectItem();
        UISelectItem selectItemNao = new UISelectItem();
        selectItemSim.setItemLabel("SIM");
        selectItemSim.setItemValue("SIM");
        selectItemSim.setId(perguntaVO.getCodigo() + "SIM");
        selectItemNao.setItemValue("NAO");
        selectItemNao.setItemLabel("NÃO");
        selectItemNao.setId(perguntaVO.getCodigo() + "NAO");
        htmlOneRadio.getChildren().add(selectItemSim);
        htmlOneRadio.getChildren().add(selectItemNao);
Eduardo Briguenti Vieira
  • 4,351
  • 3
  • 37
  • 49