我有一個表單包含inputText和消息組件。
我想從後臺bean設置錯誤消息,但保持不能執行它。如何設置錯誤消息到p:消息裏面的ui:從支持bean重複
下面是我的html代碼:
<h:form id="formId">
<h:panelGrid id="repeater" columns="2">
<h:outputText value="#{msg['label.appeal.case.reference.no']}" />
<ui:repeat id="uirepeater" value="#{beanPage.list}" var="value" varStatus="status">
<h:panelGrid columns="2">
<p:inputText id="refNo" value="#{beanPage.list[status.index]}" />
<p:message for="refNo" display="text" />
</h:panelGrid>
</ui:repeat>
</h:panelGrid>
<p:commandButton id="btmAdd" actionListener="#{beanPage.addRow}" value="Add" update="@form" />
<p:commandButton id="btmSubmit" actionListener="#{beanPage.submit}" value="Submit" update="@form" />
</h:form>
下面是支持豆代碼:
public void submit() {
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "test", "test");
FacesContext.getCurrentInstance().addMessage(":formId:uirepeater:refNo", msg);
FacesContext.getCurrentInstance().addMessage(":formId:uirepeater:0:refNo", msg);
}