myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aneesha Govil" <popcor...@gmail.com>
Subject Re: creating a dynamic code for a group of radio buttons
Date Tue, 14 Nov 2006 09:58:02 GMT
Hi,

I haven't constructed radio buttons dynamically but in general, to do
something like this..
HtmlSelectOneRadio selectOneRadio = new HtmlSelectOneRadio();
selectOneRadio.setId("choicesRadioButtons");//TODO: componentID
selectOneRadio.setLayout("spread");
selectOneRadio.setValue(displayValue);

// If you are setting IDs for radio instances here, make sure each is unique
HtmlRadio radio = new HtmlRadio();
radio.setFor("choicesRadioButtons");
radio.setIndex("0");

selectOneRadio.getChildren().add(radio);

panelGroup.getChildren().add(selectOneRadio);

Hope that helps!

Aneesha


On 11/14/06, Yaron Spektor <yaron.spektor@b6systems.com> wrote:
>
>  Hi there,
>
> I would like to convert this code to dynamic components (I can not use
> tableData with newspaperColumn because I want multiple columns with the same
> button group and I need a header aligned with each such column). I would
> like to be able to set the  t:radio in a panelGrid with X number of
>  columns:
>
> <h:panelGroup>
>
>       <t:selectOneRadio id="buttons" layout="spread" forceId="true"
> forceIdIndex="false" value="hello">
>
>             <f:selectItems value="#{pc_Wizard.choicesDisplayValue}" />
>
>       </t:selectOneRadio>
>
>
>
>
>
>       <h:panelGrid columns="5" >
>
>
>
>         <t:radio for="buttons" index="0" />
>
>         <t:radio for="buttons" index="1" />
>
>         <t:radio for="buttons" index="2" />
>
>         <t:radio for="buttons" index="3" />
>
>         <t:radio for="buttons" index="4" />
>
>         <t:radio for="buttons" index="5" />
>
>         <t:radio for="buttons" index="6" />
>
>         <t:radio for="buttons" index="7" />
>
>         <t:radio for="buttons" index="8" />
>
>       </h:panelGrid>
>
>  </h:panelGroup>
>
>
>
> This is the code I started writing but I have a problem making it work
> especially setting the "for"
>
>   HtmlPanelGroup panelGroup= new HtmlPanelGroup();
>
>   HtmlPanelGrid htmlPanelGrid = new HtmlPanelGrid();
>
>   List panelGroupChildren = panelGroup.getChildren();
>
>   panelGroupChildren.clear();
>
>   HtmlRadio radio;
>
>
>
>   HtmlSelectOneRadio selectOneRadio = new HtmlSelectOneRadio();
>
>   selectOneRadio.setId("choicesRadioButtons");//TODO: componentID
>
>   selectOneRadio.setLayout("spread");
>
>   selectOneRadio.setValue(displayValue);
>
>
>
>   htmlPanelGrid.setColumns(5);
>
>   htmlPanelGrid.setColumnClasses(Constants.cColumnClasses+
> ","+Constants.cColumnClassesCurrency);
>
>   htmlPanelGrid.setRendered(true);
>
>
>
> for(int i=0;i<9;i++){
>
>   radio = new HtmlRadio();
>
>   radio.setId("selectOneRadio");
>
>   ValueBinding vb =app.createValueBinding("buttons");
>
>   radio.setValueBinding("for", vb);
>
>   radio.setIndex(i);
>
>   htmlPanelGrid.getChildren().add(radio);
>
> }
>
>
>
>
>
> panelGroupChildren.add(selectOneRadio);
>
> panelGroupChildren.add(htmlPanelGrid);
>
>
>
> return panelGroup;
>
>
>
> any ideas?
>
>
>
>
>

Mime
View raw message