Hi,
Does somebody know which HtmlSelectOneRadio impl to use in order to allow it
to force a same id for all the radio buttons in a table?
One appreciation:  I don´t know if I am lost here but I am starting to think
that JSF has some serious design flaws in respect to this html element?

Regards,
Jorge Vasquez 

-----Mensaje original-----
De: Jorge Vásquez [mailto:[EMAIL PROTECTED] 
Enviado el: jueves, 03 de agosto de 2006 9:39
Para: 'MyFaces Discussion'
Asunto: RE: HELP with h:selectOneRadio inside h:dataTable

Thanks Martin, 
Due to the nature of the form I decided to use another strategy to solve the
problem, more based on a binding mechanism with a panel Grid, in this case I
am having problems when manipulating an HtmlSelectOneRadio component, do you
have by any chance have an example where a SelectOneRadio component is
included into a panelGrid from java code and where the selectOneRadio
element when rendered has the same name for each row but different values.
In case it helps this is my current xhtml code:

<h:panelGrid id="pruebaPanel" binding="#{searchTreeBean.searchFieldsPanel}"
columns="4" border="0" cellspacing="0"/>

And this is my java code where the panelGrid gets created:

        public void initializeFieldsPanel() {
                searchFieldsPanel.getChildren().clear();
                Application app =
FacesUtils.getFacesContext().getApplication();
                HtmlOutputText emptyString = (HtmlOutputText)
app.createComponent(HtmlOutputText.COMPONENT_TYPE);
                emptyString.setValue("");
                searchFieldsPanel.getChildren().add(emptyString);
                emptyString = (HtmlOutputText)
app.createComponent(HtmlOutputText.COMPONENT_TYPE);
                emptyString.setValue("");
                searchFieldsPanel.getChildren().add(emptyString);
                HtmlOutputText returnStr = (HtmlOutputText)
app.createComponent(HtmlOutputText.COMPONENT_TYPE);
                returnStr.setValue(Functions.getText("fields", "Return"));
                searchFieldsPanel.getChildren().add(returnStr);
                HtmlOutputText orderStr = (HtmlOutputText)
app.createComponent(HtmlOutputText.COMPONENT_TYPE);
                orderStr.setValue(Functions.getText("fields", "Order"));
                searchFieldsPanel.getChildren().add(orderStr);
                
                for (int i = 0; i < dataFieldCollection.getCollCount();
i++){
                        altDataField fld =
(altDataField)dataFieldCollection.getCollObject(i);
                        HtmlOutputText fieldName = (HtmlOutputText)
app.createComponent(HtmlOutputText.COMPONENT_TYPE);
                        fieldName.setValue(fld.getField("DESCR"));
                        searchFieldsPanel.getChildren().add(fieldName);
                        HtmlInputText inputText = (HtmlInputText)
app.createComponent(HtmlInputText.COMPONENT_TYPE);
                        int entryLength =
Integer.parseInt(fld.getField("ENTRYLENGTH"));
        
inputText.setMaxlength(Integer.parseInt(fld.getField("ENTRYLENGTH")));
                        if (entryLength > 40) {
                                inputText.setSize(40);
                        } else {
                                inputText.setSize(entryLength);
                        }
                        searchFieldsPanel.getChildren().add(inputText);
                        HtmlSelectBooleanCheckbox returnCheckBox =
(HtmlSelectBooleanCheckbox)
app.createComponent(HtmlSelectBooleanCheckbox.COMPONENT_TYPE);
                        returnCheckBox.setSelected(true);
                        searchFieldsPanel.getChildren().add(returnCheckBox);
                        HtmlSelectOneRadio orderRadioButton =
(HtmlSelectOneRadio) app.createComponent(HtmlSelectOneRadio.COMPONENT_TYPE);
                        SelectItem item = new SelectItem(i+"");
                        orderRadioButton.getChildren().add(item);
//                      orderRadioButton.setValue(item);
        
searchFieldsPanel.getChildren().add(orderRadioButton);
                }
        }

Where I am mostly interested is in the last 5 lines of code where the
HtmlSelectOneRadio component is created...

Regards and thanks again,
Jorge Vásquez

-----Mensaje original-----
De: Martin Grotzke [mailto:[EMAIL PROTECTED] 
Enviado el: miércoles, 02 de agosto de 2006 10:48
Para: MyFaces Discussion
Asunto: Re: HELP with h:selectOneRadio inside h:dataTable

Hello,

have a look at
http://wiki.apache.org/myfaces/Display_Radio_Buttons_In_Columns and
http://myfaces.apache.org/sandbox/tagreference.html#selectOneRow.
You find an example for the last one at
http://irian.at/myfaces-sandbox/selectOneRow.jsf.

Cheers,
Martin


On Wed, 2006-08-02 at 10:38 -0500, Jorge Vásquez wrote:
> Hi, I have no idea on how to include selectOneRadio elements inside a
> datatable in order for each f:selectItem to be associated to a
> different row, but all the elements belonging to the same radiobutton
> group.  I am currently getting independent radiobutton elements for
> each row but I need all of them to belong to the same group in order
> to allow only one of the rows to be selected at once.
> 
>  
> 
> In case it helps I am currently using the code:
> 
>  
> 
>                                    <h:dataTable
> value="#{searchTreeBean.dataFieldList}"var="dataField">
> 
>                                          <h:column>
> 
>                                                <h:outputText
> value="#{dataField.description}"/>
> 
> 
> <f:verbatim>&amp;nbsp;&amp;nbsp;&amp;nbsp;</f:verbatim>
> 
>                                          </h:column>
> 
>                                          <h:column>
> 
>                                                <h:inputText
> value="#{dataField.searchString}"maxlength="#{dataField.entryLength}"
> size="#{dataField.entrySize}"/>
> 
> 
> <f:verbatim>&amp;nbsp;&amp;nbsp;&amp;nbsp;</f:verbatim>
> 
>                                          </h:column>
> 
>                                          <h:column>
> 
> 
> <h:selectBooleanCheckboxvalue="#{dataField.returnSelected}" />
> 
>                                          </h:column>
> 
>                                          <h:column>
> 
> 
> <h:selectOneRadioid="myRadioButton">
> 
>                                                      <f:selectItem
> itemValue="#{dataField.orderBySelected}"/>
> 
> 
> </h:selectOneRadio>     
> 
> 
> </h:column>                                    
> 
>                                    </h:dataTable>
> 
>  
> 
> Any ideas?  
> 
>  
> 
> Regards,
> 
> JV
> 
> 

Reply via email to