Validateur maison qui n'est pas appelé quand je clique sur le bouton de recherche
Bonjour,
j'ai un certain nombre de champ dans une boite de dialogue (qui est elle même dans un form) et un bouton de recherche. Parmi ces champ j'ai un champ autocomplete avec un validateur custom (voir ci dessous)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
<p:panel id="#{widgetVar}Panel"
header="#{msgWs['recherche.panel.title']}"
styleClass="width-max inner-panel">
<p:selectOneRadio id="#{id}depVilleRadioButton" value="#{rechercheReferencesController.rechercheReferenceHelpers[key].choixDepartement}" layout="custom">
<f:selectItem itemLabel="" itemValue="true" />
<f:selectItem itemLabel="" itemValue="false" />
<p:ajax event="change" update="#{id}Recherche #{widgetVar}Panel" listener="#{rechercheReferencesController.rechercheReferenceHelpers[key].toggleSelectDepville}" resetValues="true" oncomplete="updateAutocompleteRechWs()"/>
</p:selectOneRadio>
<p:remoteCommand name="updateAutocompleteRechWs" update="#{widgetVar}Panel"/>
<p:panelGrid columns="1" styleClass="inner-table">
<p:panelGrid columns="5" styleClass="inner-table">
<p:radioButton id="#{id}depVilRadButOpt1" for="#{id}depVilleRadioButton" itemIndex="0" />
<p:outputLabel for="#{id}numeroDepartement"
value="#{msgWs['recherche.numeroDepartement']}" styleClass="#{!rechercheReferencesController.rechercheReferenceHelpers[key].choixDepartement ? '' : 'obligatoire' }"/>
<p:autoComplete id="#{id}numeroDepartement" value="#{rechercheReferencesController.rechercheReferenceHelpers[key].departementRecherche}" rendered="#{empty rendered ? true : rendered}"
completeMethod="#{departementHelper.completeDepartement}" forceSelection="true"
minQueryLength="1" maxResults="20" var="departement"
itemLabel="#{departement.shortString}"
itemValue="#{departement}" converter="#{departementConverter}"
queryDelay="300" size="40" disabled="#{!rechercheReferencesController.rechercheReferenceHelpers[key].choixDepartement}" >
<!-- validator="#{rechercheReferencesController.rechercheReferenceHelpers[key].validateDepartementRequired}"> -->
<f:validator validatorId="departementValidator" />
<p:ajax event="itemSelect" update="#{id}Recherche #{widgetVar}Panel" process="#{widgetVar}Panel" />
</p:autoComplete>
<!-- required="#{!rechercheReferencesController.rechercheReferenceHelpers[key].choixDepartement ? false : empty rechercheReferencesController.rechercheReferenceHelpers[key].listeDepartements}" -->
<!-- requiredMessage="#{msgWs['recherche.departement.required']}" -->
<p:panelGrid columns="1" styleClass="inner-table" style="text-align: center;">
<p:commandButton value="#{msg['ajouter']}"
action="#{rechercheReferencesController.rechercheReferenceHelpers[key].ajouterDepartement}"
icon="ui-icon-seek-next"
iconPos="right"
update="#{id}Recherche #{widgetVar}Panel"
disabled="#{!rechercheReferencesController.rechercheReferenceHelpers[key].choixDepartement}"
style="width: 100px;">
</p:commandButton>
<p:commandButton value="#{msg['supprimer']}"
action="#{rechercheReferencesController.rechercheReferenceHelpers[key].supprimerDepartements}"
icon="ui-icon-seek-prev"
iconPos="right"
update="#{id}Recherche #{widgetVar}Panel"
disabled="#{!rechercheReferencesController.rechercheReferenceHelpers[key].choixDepartement}"
style="width: 100px;">
</p:commandButton>
</p:panelGrid> |
Mon validateur est decrit ci dessous
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
package fr.appli.synotex.validation;
import java.util.ResourceBundle;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
import fr.appli.synotex.domain.Departement;
import fr.appli.synotex.service.ResourceBundleService;
import fr.appli.synotex.service.ResourceBundleService.Bundle;
@FacesValidator(value = "departementValidator")
public class DepartementValidator implements Validator {
@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
Boolean valueIsNotNullDepartement = value != null && value instanceof Departement;
ResourceBundle bundle = ResourceBundleService.getBundle(Bundle.WS);
if (!valueIsNotNullDepartement) {
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, bundle.getString("recherche.departement.required"), null));
}
}
} |
Or mon validateur n'est appelè que si je selectionne un departement dans mon champ autocomplete. Il n'est pas appelè quand je clique sur mon bouton de recherche. Comment faire pour qu'il soit appelè quand je clique sur mon bouton de recherche. Merci d'avance pour votre aide