Ajax Validation on JSF
I want to validate required fields on diferent forms when i push on save (Toolbar.xhtml). How can i do this? Thanks in advance
I have the following code:
Father.xhtml
..
<ui:include src="/jsf/Toolbar.xhtml"/>
<ui:include src="/jsf/Adquisicion.xhtml"/>
..
Toolbar.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
>
<ui:insert name="toolbarComponent">
<h:form name="ToolbarForm" >
<a4j:commandLink id="save" action="#{backingBean1.save}"/>
</h:form>
</ui:insert>
</ui:composition>
Adquisicion.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<ui:insert name="component">
<a4j:form id="Adquisicion">
<rich:panel>
<f:facet name="header">
<h:outputText value="Header" />
</f:facet>
<h:panelGrid columns="3">
<h:outputText value="Name" />
<h:inputText id="nameId" value="#{adquisicion.name}" style="width:500px;" r开发者_开发知识库equired="true" requiredMessage="Required" >
<a4j:support event="onblur"/>
</h:inputText>
<rich:message for="nameId" style="color: red;"/>
</rich:panel>
<a4j:form>
</ui:insert>
<ui:composition>
The input fields have to go in the same <h:form>
(or <a4j:form>
, whatever you like) as the command link/button.
精彩评论