自动加载命令
Command for autoload
JSF 或 PrimeFaces 中是否有自动加载命令?
我有一个用于 facelets 的 JSF 模板:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="template.xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:form>
<p:remoteCommand name="onload" action="#{mainMenuBean.setMenuCategories}" autoRun="true" />
</h:form>
<ui:define name="west">
<ui:include src="mainmenu.xhtml" />
</ui:define>
<ui:define name="center">
<p:outputLabel value="Zentrum" />
<h:form>
<p:remoteCommand name="rc" update="msgs" actionListener="#{mainMenuBean.setMenuCategories()}" />
<p:growl id="msgs" showDetail="true" />
<p:commandButton type="button" onclick="rc()" value="Execute" icon="ui-icon-refresh" />
</h:form>
</ui:define>
</ui:composition>
现在 p:remoteCommand
由于某种原因无法使用。是否有我可以代替 p:remoteCommand
放置的命令,以便在每次加载时自动执行某些 bean 方法?
JSF 2.2 有 viewAction,它可以在每次加载或每次获取时执行(并在回发时跳过)。它位于页面的元部分:
<f:meta>
<f:viewAction action="#{anyBean.anyAction}"/>
</f:meta>
编辑:请注意,这是一个操作组件,因此它的执行将取决于任何先前的验证/转换是否成功。
JSF 或 PrimeFaces 中是否有自动加载命令?
我有一个用于 facelets 的 JSF 模板:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="template.xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:form>
<p:remoteCommand name="onload" action="#{mainMenuBean.setMenuCategories}" autoRun="true" />
</h:form>
<ui:define name="west">
<ui:include src="mainmenu.xhtml" />
</ui:define>
<ui:define name="center">
<p:outputLabel value="Zentrum" />
<h:form>
<p:remoteCommand name="rc" update="msgs" actionListener="#{mainMenuBean.setMenuCategories()}" />
<p:growl id="msgs" showDetail="true" />
<p:commandButton type="button" onclick="rc()" value="Execute" icon="ui-icon-refresh" />
</h:form>
</ui:define>
</ui:composition>
现在 p:remoteCommand
由于某种原因无法使用。是否有我可以代替 p:remoteCommand
放置的命令,以便在每次加载时自动执行某些 bean 方法?
JSF 2.2 有 viewAction,它可以在每次加载或每次获取时执行(并在回发时跳过)。它位于页面的元部分:
<f:meta>
<f:viewAction action="#{anyBean.anyAction}"/>
</f:meta>
编辑:请注意,这是一个操作组件,因此它的执行将取决于任何先前的验证/转换是否成功。