2013-06-18 24 views
1

我試圖呈現驗證消息。我正在處理的技巧是消息只有在按下Enter鍵後纔會出現(不在提交按鈕後!)。之後,它可以正常工作。只有在按Enter鍵後才顯示錯誤消息

這裏就是我所做的JSF側(部分已爲簡化起見,省略):

<?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:ui="http://java.sun.com/jsf/facelets" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:sec="http://www.springframework.org/security/facelets/tags" 
    xmlns:c="http://java.sun.com/jsp/jstl/core" 
    xmlns:rich="http://richfaces.org/rich" 
    xmlns:a4j="http://richfaces.org/a4j" 
    xmlns:fn="http://java.sun.com/jsp/jstl/functions"> 
<body> 
    <ui:composition> 
     <h:form id="idForm"> 
      <h:panelGrid width="100%" 
       rendered="#{not empty declarationReglementaireModel.detailCurrentDecReg.decReg.listLigneGldsDTO}"> 

       <rich:extendedDataTable id="listGLD" iterationStatusVar="itGLD" 
        rows="50" 
        value="#{declarationReglementaireModel.detailCurrentDecReg.decReg.listLigneGldsDTO}" 
        var="ligneGLD" frozenColumns="1" style="height:300px; width:920px;" 
        selectionMode="none"> 

        <rich:column width="35px"> 
         <h:panelGrid columns="1" cellpadding="2"> 
          <a4j:commandLink render="editGridGLD" execute="@this" 
           oncomplete="#{rich:component('modifGLD')}.show()"> 
           <span class="icone icone-edit icone-align-center" /> 
           <a4j:param value="#{itGLD.index}" 
            assignTo="#{declarationReglementaireModel.currentLigneGldIndex}" /> 
           <f:setPropertyActionListener 
            target="#{declarationReglementaireModel.currentLigneGld}" 
            value="#{ligneGLD}" /> 
          </a4j:commandLink> 

         </h:panelGrid> 
        </rich:column> 

        <rich:column> 
         <f:facet name="header"> 
          <h:outputText value="Montant encaissement exercice" /> 
         </f:facet> 
         <div style="text-align: right"> 
          <h:outputText value="#{ligneGLD.mtEncaissesExercice}"> 
           <f:convertNumber currencySymbol="€" groupingUsed="true" 
            maxFractionDigits="2" type="currency" /> 
          </h:outputText> 
         </div> 
        </rich:column> 
        <rich:column> 
         <f:facet name="header"> 
          <h:outputText value="Montant réductions exercice" /> 
         </f:facet> 
         <div style="text-align: right"> 
          <h:outputText value="#{ligneGLD.mtReducExercice}"> 
           <f:convertNumber currencySymbol="€" groupingUsed="true" 
            maxFractionDigits="2" type="currency" /> 
          </h:outputText> 
         </div> 
        </rich:column> 
        <rich:column> 
         <f:facet name="header"> 
          <h:outputText value="Date PACA" /> 
         </f:facet> 
         <h:outputText value="#{ligneGLD.dtPaca}"> 
          <f:convertDateTime pattern="dd/MM/yyyy" timeZone="Europe/Paris" /> 
         </h:outputText> 
        </rich:column> 
        <rich:column> 
         <f:facet name="header"> 
          <h:outputText value="Numéro OLAF" /> 
         </f:facet> 
         <h:outputText value="#{ligneGLD.noOlaf}"> 
         </h:outputText> 
        </rich:column> 
        <rich:column width="200px"> 
         <f:facet name="header"> 
          <h:outputText value="Origine titre" /> 
         </f:facet> 
         <h:outputText value="#{ligneGLD.origineTitre}"> 
         </h:outputText> 
        </rich:column> 
        <rich:column> 
         <f:facet name="header"> 
          <h:outputText value="Contentieux" /> 
         </f:facet> 
         <h:outputText value="#{ligneGLD.boContentieux}"> 
         </h:outputText> 
        </rich:column> 
       </rich:extendedDataTable> 

       <h:panelGrid columns="3" styleClass="liste"> 
        <h:panelGroup> 
         <h:outputText id="paginationCompteurGLD" 
          value="Ligne #{composantPaginationGLDBack.firstElement} à #{composantPaginationGLDBack.lastElement} sur #{composantPaginationGLDBack.nbTotalElements}" /> 
        </h:panelGroup> 
       </h:panelGrid> 
      </h:panelGrid> 

      <rich:popupPanel header="Données modifiables" id="modifGLD" 
       domElementAttachment="form" autosized="true" zindex="500" 
       left="auto" top="auto"> 
       <h:panelGrid columns="1" id="editGridGLD"> 
        <h:panelGroup styleClass="bloc-contenu-message " layout="block"> 
         <rich:messages /> 
        </h:panelGroup> 
        <h:panelGrid columns="6" cellspacing="10" 
         styleClass="criteresSaisie" rowClasses="critereLigne" 
         columnClasses="titreCourtColonne,,titreCourtColonne,,titreCourtColonne,"> 

         <h:outputLabel for="GLDdtDeclCreanceMandataire" 
          value="Date déclaration mandataire" /> 
         <rich:calendar id="GLDdtDeclCreanceMandataire" inputSize="8" 
          value="#{declarationReglementaireModel.currentLigneGld.dtDeclCreanceMandataire}" 
          enableManualInput="true" datePattern="dd/MM/yyyy" 
          showInput="true"> 
         </rich:calendar> 

         <h:outputLabel value="Montant réductions exercice" /> 
         <h:inputText 
          value="#{declarationReglementaireModel.currentLigneGld.mtReducExercice}" 
          onchange="this.value=this.value.replace(/\./g,',')" size="10"> 
          <f:convertNumber maxFractionDigits="2" type="number" /> 
         </h:inputText> 

         <h:outputLabel for="GLDdtPaca" value="Date PACA" /> 
         <rich:calendar id="GLDdtPaca" inputSize="8" 
          value="#{declarationReglementaireModel.currentLigneGld.dtPaca}" 
          enableManualInput="true" datePattern="dd/MM/yyyy" 
          showInput="true"> 
         </rich:calendar> 


        </h:panelGrid> 
        <h:panelGroup> 
         <div align="right"> 
          <h:panelGrid columns="8"> 
           <a4j:commandButton value="Enregistrer" 
            action="#{rechercheDecRgltCtrl.enregistrerLigneGLD}" 
            render="editGridGLD" execute="modifGLD" 
            oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('modifGLD')}.hide();}" /> 
           <a4j:commandButton value="Annuler" 
            onclick="#{rich:component('modifGLD')}.hide(); return false;" /> 
          </h:panelGrid> 
         </div> 
        </h:panelGroup> 
       </h:panelGrid> 
      </rich:popupPanel> 
     </h:form> 
    </ui:composition> 
</body> 
</html> 
+0

你的'render =「editGridGLD,editGridGLD」'有兩次相同的ID。 –

+0

我犯了一個錯誤,我編輯了這個帖子。 – Netmaster

+0

不是很清楚你到底在問什麼,但如果點擊提交按鈕,隱藏信息會不會更容易? – Makhiel

回答