Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java <;f:事件类型=";“预渲染视图”&燃气轮机;使所有按钮调用相同的方法_Java_Jsf 2_Primefaces - Fatal编程技术网

Java <;f:事件类型=";“预渲染视图”&燃气轮机;使所有按钮调用相同的方法

Java <;f:事件类型=";“预渲染视图”&燃气轮机;使所有按钮调用相同的方法,java,jsf-2,primefaces,Java,Jsf 2,Primefaces,我在行、加载板1和2正常工作时遇到了一些问题(调用了正确的/no方法)。你知道会发生什么吗 提前谢谢 我不知道您希望preRenderView事件做什么,但它总是在RENDER_VIEW阶段之前被调用(因此得名) 单击按钮将导致视图重新渲染,因此在单击按钮时将始终调用该方法。如果使用ajax并仅渲染视图的一小部分,则不会触发该事件 如果不想在每次呈现视图时调用该方法,可以尝试ViewScope bean和@PostConstruct方法。Perfect。我应该更加关注preRenderView的

我在
行、加载板1和2正常工作时遇到了一些问题(调用了正确的/no方法)。你知道会发生什么吗


提前谢谢

我不知道您希望preRenderView事件做什么,但它总是在RENDER_VIEW阶段之前被调用(因此得名)

单击按钮将导致视图重新渲染,因此在单击按钮时将始终调用该方法。如果使用ajax并仅渲染视图的一小部分,则不会触发该事件


如果不想在每次呈现视图时调用该方法,可以尝试ViewScope bean和@PostConstruct方法。

Perfect。我应该更加关注preRenderView的实际工作,@PostConstruct是我真正需要的。非常感谢,先生/女士
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui">
...
<h:body>
<f:view>
    <f:event type="preRenderView" listener="#{decryptionBean.readAllBoards}"/>
</f:view>
...
<p:layout>
<p:layoutUnit id="andon_layout--board1" position="center"
   size="50%" styleClass="centered">
   <h2>Board 1</h2>
   <h:form id="andon_layout--board1--displayForm">
      <h:outputLabel for="location_list" value="Board List: " />
      <h:selectOneMenu id="location_list" value="Loading..."
         required="false">
         <f:selectItem itemLabel="Select One" itemValue="" />
         <f:selectItems value="#{decryptionBean.locDropDownArray}" />
      </h:selectOneMenu>
      <br />
      <p:commandButton id="loadBoard1" value="Load board" action="#{decryptionBean.loadBoard}"/>
      <h:messages id="b1_messages" />
   </h:form>
</p:layoutUnit>
<p:layoutUnit id="andon_layout--board2" position="east"
   size="50%" styleClass="centered">
   <h2>Board 2</h2>
   <h:form id="andon_layout--board2--displayForm">
      <h:outputLabel for="location_list" value="Board List: " />
      <h:selectOneMenu id="location_list" value="Loading..."
         required="false">
         <f:selectItem itemLabel="Select One" itemValue="#{decryptionBean.display2}" />
         <f:selectItems value="#{decryptionBean.locDropDownArray}" />
      </h:selectOneMenu>
      <br />
      <p:commandButton value="Load board" id="loadBoard2" />
   </h:form>
</p:layoutUnit>
</p:layout>
...