我正在使用 JSF 2.0 和 Primefaces 3.2。
我正在使用 Facelets 进行模板化,并且构建了一个 3 列布局:
左列 - mainContent 列 - 右列。每列都有自己的带有 ui:composition 的模板 xhtml 文件,我将其插入到 mainTemplate 中。
在 mainContent 列中,我有一个信息按钮 (p:commandButton):
<h:form id="mainForm">
<p:commandButton id="infoButton" value="Info" actionListener="#{faceletsAttachment.addInfo}"/>
</h:form>
但我希望信息显示在右栏中,带有
<h:form id="rightColumnForm">
<p:message for="infoButton">
</h:form>
这显然行不通,因为没有找到infoButton。知道我怎样才能使这项工作吗?我试过了
<p:message for="mainForm:infoButton">
也是,但没有雪茄。
我想使用 p:message 的原因是我希望消息将自身定位在 infoButton 的 y 位置上。如果您对我如何执行此操作有替代解决方案,我也将不胜感激。
最佳答案
如果您从服务器端手动添加消息,您可以执行以下操作
<p:message id="myInfoButton" for="myInfoButton" />
并将消息从服务器发送到myInfoButton
像这样
FacesContext.getCurrentInstance.addMessage("myInfoButton ", new FacesMessage("My Message", "Some Text goes here..."));
同时添加 :rightColumnForm
要更新 <p:commandButton id="infoButton"
的 ID
关于java - primefaces p :message outside the components form,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10246548/