Inputext nullpointer with <p:ajax> and @ViewScoped



我遇到了一个问题,我无法解决:(

通过在 selectOneRadio 中选择一个项目,我想设置一个特定的变量:

<h:form id="form">
    <p:selectOneRadio id="options" value="#{rechercheBean.choose}">
        <f:selectItem itemLabel="Critere 1" itemValue="c1" />
        <f:selectItem itemLabel="Critere 2" itemValue="c2" />
        <p:ajax update="critere" />
    </p:selectOneRadio>
    <h:panelGrid columns="1" id="critere">
        <c:choose>
            <c:when test="#{monBean.choix eq 'c1'}">
                <h:outputText value="Critere 1 :" />
                <p:inputText id="cr1" value="#{rechercheBean.critere1}" />
            </c:when>
            <c:when test="#{monBean.choix eq 'c2'}">
                <h:outputText value="Critere 2 :" />
                <p:inputText id="cr2" value="#{rechercheBean.critere2}" />
            </c:when>
        </c:choose>
    </h:panelGrid>
    <h:commandButton value="Add critere" actionListener="#{rechercheBean.add}"/>
</h:form>

对于 managedBean SessionScope,此代码有效,但对于 ViewScope,它不起作用。

在ViewScope中,当我单击按钮时,特定变量为空,但是如果我删除组件,则设置了特定变量!

我需要在输入分机:(之间切换

如何解决我的问题?

Tx很多!

替换

 <c:choose>
        <c:when test="#{monBean.choix eq 'c1'}">

<panelGroup rendered="#{monBean.choix eq 'c1'}">

(替换两个<c:when

此外,如果您使用的是素数,您可以将<h:commandButton替换为 <p:commandButton ,或者只是将f:ajax添加到当前<h:commandButton

最新更新