Andrea created TOMAHAWK-1662:
--------------------------------

             Summary: t:selectOneRadio with layout="spread" does not work with 
RichFaces <a4j:ajax />
                 Key: TOMAHAWK-1662
                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1662
             Project: MyFaces Tomahawk
          Issue Type: Bug
          Components: selectOneRadio / radio
    Affects Versions: 1.1.14
         Environment: JBoss AS 7.1.1, JSF 2.1.7, RichFaces 4.3.0.Final, 
Tomahawk 1.1.14
            Reporter: Andrea


Tomahawk radiobutton does work properly when using <a4j:ajax/>. For example the 
following JSF snipped does not work:
{code}
<h:form id="myFrm">
        <t:selectOneRadio id="myRadio" value="#{testtest.resultId}" 
layout="spread">
                <f:selectItem id="item1" itemValue="10" itemLabel="10" />
                <f:selectItem id="item2" itemValue="20" itemLabel="20" />
                <a4j:ajax />
        </t:selectOneRadio>
        <div><t:radio id="radio1" for="myRadio" index="0"/></div>
        <div><t:radio id="radio2" for="myRadio" index="1"/></div>
</h:form>
{code}
If I replace <a4j:ajax /> with <f:ajax />, everything works as expected.

I have debugged this issue, and firstly I thought this was a RichFaces issue 
(see https://issues.jboss.org/browse/RF-13066), Right now I think this is a 
Tomahawk issue instead, and should be fixed here.

As I described on RF bug page, I think that 
org.apache.myfaces.custom.radio.HtmlRadio implement ClientBehaviorHolder and 
delegate the requests to the "for" component. In this specific case, "radio1" 
and "radio2" client behaviors are actually defined in "myRadio".

The fix would be something like this:
{code}
public abstract class AbstractHtmlRadio extends UIComponentBase implement 
ClientBehaviorHolder {

        /**
         * Delegating ClientBehaviorHolder to "for" UIComponent
         */
        @Override
        public Map<String, List<ClientBehavior>> getClientBehaviors() {
                UIComponent uiSelectOne = findComponent(getFor());
                if (uiSelectOne instanceof ClientBehaviorHolder) {
                        ClientBehaviorHolder clientBehaviorHolder = 
(ClientBehaviorHolder) uiSelectOne;
                        return clientBehaviorHolder.getClientBehaviors();
                }
        }
}
{code}

This above just to show how the delegation would work.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to