[ 
https://issues.apache.org/jira/browse/MYFACES-4115?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15997525#comment-15997525
 ] 

Leonardo Uribe commented on MYFACES-4115:
-----------------------------------------

In the component there are two use cases:

1. h:selectOneRadio is inside a dataTable or repeat component like this:

{code:xml}

<h:dataTable id="table" value="#{selectOneGroupBean.myValues}" var="val">
        <h:column>
                <h:selectOneRadio id="radio" group="someGroup" 
                        value="#{selectOneGroupBean.selectedValue}">
                        <f:selectItem itemValue="#{val}" itemLabel="#{val}"/>
                </h:selectOneRadio>
        </h:column>
</h:dataTable>

{code}

2. There are more than one h:selectOneRadio, but there is one that holds
the select list. Each one has an id ending with an index that indicates
the value that will be rendered in the current component. For example:

{code:xml}

<h:selectOneRadio id="radio0" group="someGroup" 
value="#{selectOneGroupBean.selectedValue}">
        <f:selectItems value="#{selectOneGroupBean.myValues}" />
</h:selectOneRadio>
<h:selectOneRadio id="radio1" group="someGroup" />
<h:selectOneRadio id="radio2" group="someGroup" />

{code}
I think the best trick to make it work is take a look at "value" 
ValueExpression. When this VE is not present, the component is a placeholder,
when it is present, the component can hold a submitted value.

On h:selectOneRadio renderer decode() if the component has "group" property
set, retrieve the value and if the value starts with the component clientId,
the current component will be the "source component". Now, the algorithm 
should apply a visit tree call starting from the closest UIForm. When it
founds a component than belongs to the group there are two cases:

- If the source component has a "value" ValueExpression, call 
setSubmittedValue(...) and if the target component is the source component
pass the submitted value, otherwise call resetValue().
- If the source component does not have a "value" ValueExpression, find
the first component that belongs to the groupd and with a "value" 
ValueExpression and set the value there, otherwise call resetValue().

This algorithm looks more consistent because:

- It ensures only one visit tree call per group.
- It ensures values from previous requests will be cleared.

Then on render phase, the Renderer will detect the group attribute and if
the attribute is set, it will get the value to use using the same rules
used in decode() phase. This means only a visit tree call is necessary when
option 2 is used. 

I think the algorithm proposed respect the spirit of the spec, and I have
already tested it, so I think it should be the way at least for MyFaces.

> Implement h:selectOneRadio "group" (distributed radio button)
> -------------------------------------------------------------
>
>                 Key: MYFACES-4115
>                 URL: https://issues.apache.org/jira/browse/MYFACES-4115
>             Project: MyFaces Core
>          Issue Type: New Feature
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>             Fix For: 2.3.0
>
>
> Implement h:selectOneRadio "group" (distributed radio button)



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to