【问题标题】:Primefaces custom selectOneRadio, doesn't propagate to backing beanPrimefaces 自定义 selectOneRadio,不会传播到支持 bean
【发布时间】:2013-04-25 07:55:59
【问题描述】:

我目前遇到了<p:radioButton><p:selectOneRadio> 的问题。我正在尝试制作一个带有三个单选按钮的表单,旁边有一些框,这很有效,并且按钮中的“无线电机制”可以工作,因此一次只能选择一个。但是,选定的单选按钮不会传播到后端。我尝试在<p:selectOneRadio> 中添加<p:ajax> 以使其触发对支持bean 的某种调用,但没有成功。我看过以下 primefaces 示例:http://www.primefaces.org/showcase/ui/selectOneRadio.jsf

有人能指出我解决这个问题的正确方向吗?

<p:selectOneRadio id="customRadio" layout="custom" value="advancedSettingsBean.radioValue">
    <f:selectItem itemValue="1" />
    <f:selectItem itemValue="2" />
    <f:selectItem itemValue="3" />
    <p:ajax />
</p:selectOneRadio>
<tr>
    <td valign="top">
        <p:radioButton id="CheckboxValidTimeCurrent" for="customRadio" itemIndex="0">
        </p:radioButton>
    </td>
    <td colspan="2">
        <h:outputText value="#{messages.search_advanced_validtimecurren}" /> 
        <br />
    </td>
</tr>
<tr>
    <td valign="top">
        <p:radioButton id="CheckboxvValidTimeDate" for="customRadio" itemIndex="1">
        </p:radioButton>
    </td>
    <td colspan="2">
        <h:outputText value="#{messages.search_advanced_validtimedate}" />
        <br /> 
        <p:calendar id="singledate" value="#{advancedSettingsBean.singleSearchDate}"
            datePattern="yyyy-MM-dd" direction="smart" jointPoint="auto"
            inputStyle="width:80px" style="width: 200px">
            <f:convertDateTime pattern="yyyy-MM-dd" timeZone="UTC" />
        </p:calendar> Z 
        <br /> 
        <p:message showSummary="true" showDetail="false"
           id="singledateError" for="singledate" />
        <br />
    </td>
</tr>
<tr>
    <td valign="top">
        <p:radioButton id="CheckboxvValidTimeSpan" for="customRadio" itemIndex="2">
        </p:radioButton>
    </td>
...

【问题讨论】:

    标签: jsf jsf-2 primefaces radio-button


    【解决方案1】:

    你应该把 selectoneradio 的值放在一个 el 表达式中:

    value="#{advancedSettingsBean.radioValue}"
    

    【讨论】:

    • #FML.. 我怎么能错过它.. 但谢谢你指出来.. 有时你所需要的只是一个没有盯着它的人!
    • 没关系,我们都在编码和集中精力,在这种时候,我想休息一下,出去一会儿是最好的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-21
    • 2013-12-30
    • 2015-01-02
    • 2012-10-24
    • 1970-01-01
    • 1970-01-01
    • 2012-12-26
    相关资源
    最近更新 更多