【问题标题】:JSF 2 + Primefaces - Update tag Not Working [duplicate]JSF 2 + Primefaces - 更新标签不起作用[重复]
【发布时间】:2021-01-25 00:06:58
【问题描述】:

单击 selectOneMenu 时 ajax 更新不起作用,并在我重新加载页面时更改教员进行更新
我已经搜索了一个小时但找不到任何解决方案 onChooseFaculty 方法运行良好但更新不是

<h:form id="home">
    <p:sidebar id="homeSider" widgetVar="sidebar1">
        <h2 style="font-weight: normal">Select Department</h2>
        <br></br>
        <h:panelGrid id="homePanel" columns="2" cellpadding="5">
            <p:outputLabel for="faculty" value="Faculty: " />
            <p:selectOneMenu id="faculty" value="#{homeBacking.selectdFaculty}"
                style=" width:12em">
                <p:ajax listener="#{homeBacking.onChooseFaculty}"
                    ignoreAutoUpdate="false" update=":home:department" />

                <f:selectItem itemLabel="Select Faculty" itemValue=""
                    noSelectionOption="true" />
                <f:selectItems value="#{homeBacking.faculty}" />
            </p:selectOneMenu>

            <p:outputLabel for="department" value="Department: " />
            <p:selectOneMenu id="department"
                value="#{homeBacking.selectedDepartment}" style="width:12em"
                disabled="#{homeBacking.enableDept}">
                <f:selectItem itemLabel="Select Department" itemValue=""
                    noSelectionOption="true" />
                <f:selectItems value="#{homeBacking.department}" />
            </p:selectOneMenu>
        </h:panelGrid>
        <p:separator />
        <div class="container " align="center">
            <p:commandButton value="Submit" update="" />
            <p:commandButton value="Cancel" oncomplete="PF('sidebar1').hide()" />
        </div>
    </p:sidebar>
</h:form>

我试过了:

update=":home:homeS:homePanel:department" 
update=":home:homeS:department" 
update=":home:department" 
update=":department" 
update=":home"
update=":sidebar"

添加面板组并更新它 还有很多其他的东西

这是怎么回事?! 感谢您的帮助。

【问题讨论】:

  • 尝试从后端更新,使用 PrimeFaces.ajax().update("componentId")
  • 感谢所有的问题是 jsf impl 和 jsf api 不在同一个版本中

标签: jsf primefaces


【解决方案1】:

我看到您指定了一些名为“home”的 ID。我看不到任何具有此 ID 的元素。

但由于“faculty”和“department”在同一个命名容器中,只写 update="department" 就足够了。

【讨论】:

  • 由于格式错误而被隐藏在问题中
  • 亲爱的 pstar 感谢您的回答我试过了,但它不起作用!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-24
  • 2012-04-28
  • 2012-01-30
  • 2016-01-16
  • 1970-01-01
相关资源
最近更新 更多