x:selectOneRadio tag cannot be nested within the h:dataTable tag in version 
1.1.0
---------------------------------------------------------------------------------

         Key: MYFACES-680
         URL: http://issues.apache.org/jira/browse/MYFACES-680
     Project: MyFaces
        Type: Bug
    Versions: 1.1.0    
 Environment: Windows XP Pro sp2, Tomcat 4.1.31
    Reporter: Jason Allen
    Priority: Minor


I've run into an issue with version 1.1.0 when trying to implement a 
x:selectOneRadio tag within the h:dataTable tag where only one row from the 
data table can have the radio button selected.  In version 1.0.9, I used the 
forceId and forceIdIndex attributes in the x:selectOneRadio tag to force the id 
of each x:selectOneRadio to be the same.  Each row in the h:dataTable will have 
x:selectOneRadio with only one SelectItem in it, but since the id's are the 
same, the browser handles it correctly.

However, with version 1.1.0 in the validateValue(FacesContext, Object) method 
of the javax.faces.component.UISelectOne class, there is a call to 
_SelectItemsUtil.matchValue(FacesContext, Object, Iterator, _ValueConverter) 
which checks to see if the selected value of the x:selectOneRadio exists in the 
list of SelectItems.  Since each row in the data table has a x:selectOneRadio 
with only one SelectItem, this check will only return true for the row where 
the radio button is selected.  All other rows cause this check to fail and add 
a 'Value is not a valid option' error to the context messages list, which 
prevents the page from performing any other actions.

Here is an example of how I am using the x:selectOneRadio:

<h:dataTable
        cellspacing="0"
        style="padding-top: 0px; padding-bottom: 0px;"
        styleClass="form-sub-table"
        value="#{backingBean.personList}" 
        var="person">
        
        <h:column>
                <h:outputText value="#{person.firstName} #{person.lastName}" 
escape="false" />
        </h:column>

        <h:column>
                <x:selectOneRadio id="preside" 
                        forceId="true" 
                        forceIdIndex="0" 
                        value="#{backingBean.presidePersonId}" 
                        valueChangeListener="#{backingBean.presideOverride}"
                        style="margin: 0px; border: 0px;"
                        border="0">
                                                                                
        
                        <f:selectItem itemValue="#{person.personId}" 
itemLabel="" />
                </x:selectOneRadio>
        </h:column>
</h:dataTable>

It's not completely clear to me why the existence of the x:selectOneRadio value 
in it's child SelectItems needs to be enforced so strictly.  I propose that 
this check be either optional or eliminated all toghether.

Thanks,

Jason Allen

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to