1

我正在尝试呈现验证消息。我正在研究的技巧是消息仅在按下 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>
4

1 回答 1

0

您可以在需要时使用 a4j:support 发送请求,例如 onblur / onkeyup ... 或任何支持该项目的 javascript。 http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/a4j_support.html

于 2013-07-26T03:02:51.863 回答