简体   繁体   中英

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;" required="true" requiredMessage="Required" >
            <a4j:support event="onblur"/>
         </h:inputText>
  <rich:message for="nameId" style="color: red;"/>
     </rich:panel>
   <a4j:form> 
 </ui:insert>
<ui:composition> 

输入字段必须与命令链接/按钮使用相同的 <h:form> (或<a4j:form> ,无论您喜欢什么)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM