4 Replies Latest reply on Oct 25, 2012 9:13 AM by Siva P

    Multiples forms in a JSF page

    Deibys Quintero Newbie

      Hello Guys,

       

      I  have  a JSF page with multiple forms.  Those forms are not nested

       

      The pattern is like this:

       

      <rich:collapsiblePanel expanded="false" switchType="client" style="background-color: white;">
          <h:form>
               <rich:messages />
                     [controls]
          </h:form>
      </rich:collapsiblePanel>
      <rich:collapsiblePanel expanded="false" switchType="client" style="background-color: white;">
          <h:form>
               <rich:messages />
                    [controls]
          </h:form>
      </rich:collapsiblePanel>
      
      

       

      When an error occurs in the first form , It is also displayed in the second form 

      How can I prevent this ? I would like that errors or success messages are displayed only in the context of the form where they took place

       

      My whole .xhtml page is:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"   
            xmlns:c="http://java.sun.com/jstl/core"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:rich="http://richfaces.org/rich"
            xmlns:a4j="http://richfaces.org/a4j"
                  >
      
      
                <h:body>
                          <ui:composition template="/common/templates/template.xhtml">
                                    <ui:define name="title">Cargar Encuesta</ui:define>
                                    <ui:define name="content">
                                              <div style="width:600px;">
                                                        <rich:panel style="background-color: white;">
                                                                  <f:facet name="header">
                                                                            <h:outputText value="Información del Evento" />
                                                                  </f:facet>
                                                                  <table border="0">
                                                                            <tr>
                                                                                      <td><h:outputLabel value="Nombre" /></td>
                                                                                      <td colspan="3"><h:outputText value="#{CargarEncuestaBean.eventoTO.nombre}" style="background-color: #CCCCCC;" /></td>
                                                                            </tr>
                                                                            <tr>
                                                                                      <td><h:outputLabel value="Fecha Inicio" /></td>
                                                                                      <td><h:outputText value="#{CargarEncuestaBean.eventoTO.fechaInicio}" style="background-color: #CCCCCC;" /></td>
                                                                                      <td><h:outputLabel value="Fecha Fin" /></td>
                                                                                      <td><h:outputText value="#{CargarEncuestaBean.eventoTO.fechaFinal}" style="background-color: #CCCCCC;" /></td>
                                                                            </tr>
                                                                  </table>
                                                        </rich:panel>
                                                        <br />
                                                        <a4j:repeat value="#{CargarEncuestaBean.encuestas}" var="encuesta" rowKeyVar="index" >
                                                                  <rich:collapsiblePanel header="#{encuesta.encuestaCalificador.nombre}  Población: #{encuesta.poblacion}" expanded="false" switchType="client" style="background-color: white;">
                                                                            <h:form>
                                                                                      <rich:messages />
                                                                                      <table border="0">
                                                                                                <tr>
                                                                                                          <td><h:outputLabel value="Enlace de la Encuesta" /></td>
                                                                                                          <td><h:outputText  value="#{encuesta.linkEncuesta}" style="background-color: #CCCCCC;" /></td>
                                                                                                          <td><h:outputLabel value="Estado" /></td>
                                                                                                          <td><h:outputText  value="#{encuesta.estado}" style="background-color: #CCCCCC;" /></td>
                                                                                                </tr>
                                                                                                <tr>
                                                                                                          <td>Archivos Adjuntados</td>
                                                                                                </tr>
                                                                                      </table>
                                                                                      <rich:dataTable value="#{encuesta.listEncuestaConcepto}" var="concepto" >
                                                                                                <f:facet name="noData">
                                                                                                          <h:outputText value="No se han ingresado conceptos para este tipo de encuesta" />
                                                                                                </f:facet>
                                                                                                <rich:column>
                                                                                                          <f:facet name="header">
                                                                                                                    <h:outputText value="Concepto"/>
                                                                                                          </f:facet>
                                                                                                          <rich:select value="#{concepto.tipoConcepto.id}" disabled="#{!concepto.editable}" style="#{component.valid ? '' : 'border: 2px solid red; background: orange;'}">
                                                                                                                    <f:validateRequired />
                                                                                                                    <f:selectItems value="#{SelectListBean.encuestaConceptos}" />
                                                                                                          </rich:select>
                                                                                                          <h:outputText value="#{concepto.tipoConcepto.nombre}" rendered="false" />
                                                                                                </rich:column>
                                                                                                <rich:column>
                                                                                                          <f:facet name="header">
                                                                                                                    <h:outputText value="Evaluación"/>
                                                                                                          </f:facet>
                                                                                                          <h:outputText value="#{concepto.calificacion}" rendered="#{!concepto.editable}" />
                                                                                                          <h:inputText value="#{concepto.calificacion}" style="#{component.valid ? '' : 'border: 2px solid red; background: orange;'}" rendered="#{concepto.editable}" >
                                                                                                                    <f:validateRequired />
                                                                                                          </h:inputText>
                                                                                                </rich:column>
                                                                                                <rich:column>
                                                                                                          <f:facet name="header">
                                                                                                                    <h:outputText value="Contestaron"/>
                                                                                                          </f:facet>
                                                                                                          <h:outputText value="#{concepto.respondieron}" rendered="#{!concepto.editable}" />
                                                                                                          <h:inputText  value="#{concepto.respondieron}" style="#{component.valid ? '' : 'border: 2px solid red; background: orange;'}" rendered="#{concepto.editable}" >
                                                                                                                    <f:validateRequired />
                                                                                                          </h:inputText>
                                                                                                </rich:column>
                                                                                                <rich:column>
                                                                                                          <f:facet name="header">
                                                                                                                    <a4j:commandButton execute="@this" value="+" action="#{CargarEncuestaBean.adicionarConcepto(encuesta.listEncuestaConcepto)}" render="@form" />
                                                                                                          </f:facet> 
                                                                                                          <a4j:commandLink execute="@form" value="Editar" action="#{CargarEncuestaBean.editarConcepto(concepto)}" rendered="#{!concepto.editable}" render="@form" >
                                                                                                                    <a4j:param value="#{index}"  assignTo="#{CargarEncuestaBean.encuestaSeleccionada}" />
                                                                                                          </a4j:commandLink>
                                                                                                          <a4j:commandLink execute="@form" value="Guardar" action="#{CargarEncuestaBean.guardar(concepto)}" rendered="#{concepto.editable}" render="@form">
                                                                                                                    <a4j:param value="#{index}"  assignTo="#{CargarEncuestaBean.encuestaSeleccionada}" />
                                                                                                          </a4j:commandLink>
                                                                                                          <h:outputText value=" " />
                                                                                                          <a4j:commandLink execute="@this" value="Eliminar" action="#{CargarEncuestaBean.eliminarConcepto(concepto)}" render="@form" >
                                                                                                                    <a4j:param value="#{index}"  assignTo="#{CargarEncuestaBean.encuestaSeleccionada}" />
                                                                                                          </a4j:commandLink>
                                                                                                </rich:column>
                                                                                      </rich:dataTable>
                                                                            </h:form>
                                                                  </rich:collapsiblePanel>
                                                        </a4j:repeat>
                                              </div>
                                       </ui:define>
                          </ui:composition>
                </h:body>
      </html>     
      
      

       

       

       

      Thanks!

      Deibys