Re: creating a dynamic code for a group of radio buttons
Hi Yaron, Can you post the updated code? I think you had missed this step earlier - selectOneRadio.getChildren().add(radio); Aneesha On 11/15/06, Yaron Spektor <[EMAIL PROTECTED]> wrote: Thanks Aneesha, I did have the IDs unique. I also tried setting the valueBinding to an HtmlSelectOneRadio that I put on the bean (with getters and setters of course) nothing seemed to work. Just to make sure my question is clear I need to create a dynamic view similar to this: |*column1|column2**|column3|* *|radio1|radio 2 |radio3|* *|radio4|radio5|* | The number of columns and number of rows is not fixed and all the radio buttons need to be in the same group. Any advice would be appreciated, -- *From:* Aneesha Govil [mailto:[EMAIL PROTECTED] *Sent:* Tuesday, November 14, 2006 4:58 AM *To:* MyFaces Discussion *Subject:* Re: creating a dynamic code for a group of radio buttons 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* <[EMAIL PROTECTED]> 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: 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?
RE: creating a dynamic code for a group of radio buttons
Thanks Aneesha, I did have the IDs unique. I also tried setting the valueBinding to an HtmlSelectOneRadio that I put on the bean (with getters and setters of course) nothing seemed to work. Just to make sure my question is clear I need to create a dynamic view similar to this: |column1|column2|column3| |radio1 |radio 2 |radio3 | |radio4 |radio5 | | The number of columns and number of rows is not fixed and all the radio buttons need to be in the same group. Any advice would be appreciated, From: Aneesha Govil [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 14, 2006 4:58 AM To: MyFaces Discussion Subject: Re: creating a dynamic code for a group of radio buttons 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 <[EMAIL PROTECTED]> 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: 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?
Re: creating a dynamic code for a group of radio buttons
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!AneeshaOn 11/14/06, Yaron Spektor <[EMAIL PROTECTED]> 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: 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?