我遇到了一些问题,<f:event type="preRenderView" listener="#{decryptionBean.readAllBoards}>
导致我的所有按钮(默认类型,而不是 type="button"> 调用相同的 bean 方法,特别是decryptionBean.readAllBoards
.这是我认为是代码的相关部分:
<!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>
...
loadBoard1 和 loadBoard2 一样运行decryptionBean.loadBoard()
,decryptionBean.readAllBoards()
而 loadBoard2 只运行decryptionBean.readAllBoards()
。如果我删除该<f:event type="preRenderView" listener="#{decryptionBean.readAllBoards}>
行,则 loadBoard1 和 2 正常运行(调用正确/无方法)。关于可能发生的事情有什么想法吗?
提前致谢!