Jsf 单击后重新渲染组件

Jsf 单击后重新渲染组件,jsf,primefaces,Jsf,Primefaces,我正在使用primefaces组件进行UI开发。我无法理解如何通过ajax进行重新渲染 当我点击提交按钮时,表单应该隐藏并显示 在pageload上,它应该只显示输出标签,并隐藏数据表 在从bean中设置新的渲染值后,请帮助更新相应的组件 <p:commandButton value="Submit" actionListener="#{managedBean.function}" update="idOfTheComponent idOfTheNextComponent">

我正在使用primefaces组件进行UI开发。我无法理解如何通过ajax进行重新渲染

  • 当我点击提交按钮时,表单应该隐藏
    并显示

  • 在pageload上,它应该只显示
    输出标签
    ,并隐藏
    数据表


  • 在从bean中设置新的渲染值后,请帮助更新相应的组件

    <p:commandButton  value="Submit" actionListener="#{managedBean.function}"
    update="idOfTheComponent idOfTheNextComponent">
    
    
    

    确保给定的id是组件的确切id,如果没有给出
    prependId=“false”
    ,JSF将从父级(
    :parentId:childId
    )生成id(如有疑问,请查看html)。您还可以使用
    @form
    更新整个表单。

    从bean中设置新的渲染值后更新相应的组件

    <p:commandButton  value="Submit" actionListener="#{managedBean.function}"
    update="idOfTheComponent idOfTheNextComponent">
    
    
    

    确保给定的id是组件的确切id,如果没有给出
    prependId=“false”
    ,JSF将从父级(
    :parentId:childId
    )生成id(如有疑问,请查看html)。您还可以使用
    @form
    更新整个表单。

    从bean中设置新的渲染值后更新相应的组件

    <p:commandButton  value="Submit" actionListener="#{managedBean.function}"
    update="idOfTheComponent idOfTheNextComponent">
    
    
    

    确保给定的id是组件的确切id,如果没有给出
    prependId=“false”
    ,JSF将从父级(
    :parentId:childId
    )生成id(如有疑问,请查看html)。您还可以使用
    @form
    更新整个表单。

    从bean中设置新的渲染值后更新相应的组件

    <p:commandButton  value="Submit" actionListener="#{managedBean.function}"
    update="idOfTheComponent idOfTheNextComponent">
    
    
    

    确保给定的id是组件的确切id,如果没有给出
    prependId=“false”
    ,JSF将从父级(
    :parentId:childId
    )生成id(如有疑问,请查看html)。您还可以使用
    @form
    更新整个表单。

    这是您的表单的副本,它针对的是完全相同的问题。发布多个问题并不能完全解决您的问题

    然而,这段代码对我来说非常好

    xhtml

    <p:commandButton value="Submit" action="#{testBean.go()}" update="@form" />
    
    <p:dataTable id="table" value="#{testBean.list}" var="item" rendered="#{testBean.showTable}">
        <p:outputLabel value="Table" />
    </p:dataTable>
    
    <p:outputLabel id="label" value="Label" rendered="#{testBean.showLabel}" />
    

    仅更新dataTable和outputLabel的id不起作用,@form肯定起作用。

    这是您的id的副本,它针对完全相同的问题。发布多个问题并不能完全解决您的问题

    然而,这段代码对我来说非常好

    xhtml

    <p:commandButton value="Submit" action="#{testBean.go()}" update="@form" />
    
    <p:dataTable id="table" value="#{testBean.list}" var="item" rendered="#{testBean.showTable}">
        <p:outputLabel value="Table" />
    </p:dataTable>
    
    <p:outputLabel id="label" value="Label" rendered="#{testBean.showLabel}" />
    

    仅更新dataTable和outputLabel的id不起作用,@form肯定起作用。

    这是您的id的副本,它针对完全相同的问题。发布多个问题并不能完全解决您的问题

    然而,这段代码对我来说非常好

    xhtml

    <p:commandButton value="Submit" action="#{testBean.go()}" update="@form" />
    
    <p:dataTable id="table" value="#{testBean.list}" var="item" rendered="#{testBean.showTable}">
        <p:outputLabel value="Table" />
    </p:dataTable>
    
    <p:outputLabel id="label" value="Label" rendered="#{testBean.showLabel}" />
    

    仅更新dataTable和outputLabel的id不起作用,@form肯定起作用。

    这是您的id的副本,它针对完全相同的问题。发布多个问题并不能完全解决您的问题

    然而,这段代码对我来说非常好

    xhtml

    <p:commandButton value="Submit" action="#{testBean.go()}" update="@form" />
    
    <p:dataTable id="table" value="#{testBean.list}" var="item" rendered="#{testBean.showTable}">
        <p:outputLabel value="Table" />
    </p:dataTable>
    
    <p:outputLabel id="label" value="Label" rendered="#{testBean.showLabel}" />
    


    仅更新dataTable和outputLabel的id不起作用,@form肯定起作用。

    您可以使用简单的java脚本设置特定组件的样式。例如
    style=display:none
    在primefaces中是否仍有这样做的方法?您可以共享一些代码吗?您可以使用简单的java脚本来设置特定组件的样式。例如
    style=display:none
    在primefaces中是否仍有这样做的方法?您可以共享一些代码吗?您可以使用简单的java脚本来设置特定组件的样式。例如
    style=display:none
    在primefaces中是否仍有这样做的方法?您可以共享一些代码吗?您可以使用简单的java脚本来设置特定组件的样式。例如
    style=display:none
    是否仍可以在primefaces中执行此操作?您是否可以共享一些代码?是否使用@form..?检查html页面中的id并打印用于呈现的变量的值,检查其显示的id和变量名是否与预期的值相同。是否使用@form..?检查html页面中的id并打印用于呈现的变量的值,检查其显示的id和变量名是否与预期的值相同。是否使用@form..?检查html页面中的id并打印用于呈现的变量的值,检查id和变量名是否显示与预期值相同的值。是否使用@form..?检查html页面中的id并打印用于呈现的变量值,检查id和变量名是否显示与预期值相同的值。