0

I have an issue where the value of t:radio (associated with t:selectOneRadio) is not being passed to the backing bean. We are currently converting from JSF 1.x to JSF 2.x, using MyFaces 2.1.13 on Jboss 7.2.0, and we do have the 2.0 version of the Tomahawk library. I have spent hours trying different things to get it to work and searched high and low but can't find anyone else having encountered the same problem. I have determined that the setter is never being called once a value is checked.

I have extracted the code and simplified it, yet still nothing is passed on the ajax call.

<h:form id="profileReport">

    <h:messages />

    <h:panelGrid columns="2">

        <t:selectOneRadio id="selectQuestionnaire" layout="spread" required="true" 
                value="#{viewProfile.selectedQuestionnaire}">
            <f:selectItem itemValue="SC_PRE!20121212095427.0000000.059814626868021525" /> 
            <f:ajax event="click" execute="@this" render="profileReport:selectTemplate profileReport" />    
        </t:selectOneRadio>

        <h:outputLabel for="selectQuestionnaire" value="#{prmsgs.firstQuestionnaireLabel}" styleClass="labelText" />
        <t:radio index="0" for="profileReport:selectQuestionnaire" />

        <h:outputLabel for="selectTemplate" value="#{prmsgs.exploratoryProcessTemplate}:" styleClass="labelText" />
        <h:selectOneListbox id="selectTemplate" value="#{viewProfile.selectedInterpretiveProfileTemplateId}" required="#{menuNavigation.selectInterpretiveProfileActive}">
            <f:selectItems value="#{viewProfile.interpretiveProfileTemplates}"/>
        </h:selectOneListbox>
    </h:panelGrid>
</h:form>

Just for testing purposes, I have replaced the t:selectOneRadio with h:selectOneRadio and the setter is called. Then I tried the t:selectOneRadio without t:radio and that worked. So it appears to be an issue with t:radio, though I'm not sure what it is at this point. I am aware Icefaces has similar functionality, but I don't want to introduce another full component library just for this singular use at this time. We are trying to minimize the changes as much as possible as this is a very lean conversion process.

RobG
  • 43
  • 1
  • 5
  • Try with t:radio index="0" for="profileReport:selectQuestionnaire" renderLogicalId="true". I found this was solved in [TOMAHAWK-1551](https://issues.apache.org/jira/browse/TOMAHAWK-1551) – lu4242 Jan 20 '14 at 14:57
  • @lu4242 Thanks for that. I tried adding that code, but it hasn't solved the issue. The setter is still not being called - I tried with renderLogicalId both true and false just to see what would happen and neither cause any functionality changes. – RobG Jan 20 '14 at 15:30
  • Try changing execute="@this" in f:ajax to execute="@form". Probably the value inside t:radio is not being processed in the ajax request. – lu4242 Jan 20 '14 at 16:16
  • @lu4242 Thanks. That appears to have resolved this issue. The issue here is submitting the form (that this originally came from) before all required values are present makes validation of other elements fail (all other elements are executing @this). In this case the radio button is one of the last items picked, so it will work in this instance. The question is, why isn't the value in t:radio being submitted in the ajax request when referencing itself? If you add your comments to an answer, then I can select it as correct. – RobG Jan 20 '14 at 17:17

1 Answers1

1

When t:selectOneRadio layout="spread" is used, t:selectOneRadio is one component and t:radio is another component, even if they work together. In this case, when the ajax request is executed, the lifecycle is executed over t:selectOneRadio but it is not executed for t:radio. f:ajax component cannot be overriden in that way, so it is not possible to include t:radio in the lifecycle once it has started.

lu4242
  • 2,318
  • 1
  • 15
  • 15