0

I have a p:selectOneMenu and a p:commandButton as shown in the code below :

<h:form  styleClass="form-horizontal">
    <div class="form-group ">
        <div align="center">
            <h:outputText for="dd" value="Unité organisationnelle" styleClass="col-lg-4 nomSalarie"/>
        </div>
        <div class="col-lg-6" align="center">
            <p:selectOneMenu id="uniteOrga" value="#{resultatRecherche.uoRecherche}" >
                <f:selectItem itemLabel="Choisir Unité Organisationnelle" itemValue="" noSelectionOption="true" />
                <f:selectItems value="#{resultatRecherche.listeActivUo}" />
            </p:selectOneMenu>
        </div>
        <div class="col-lg-2"></div>
    </div>
    <div class="form-group">
        <div class="col-lg-4"></div>
        <div align="center" >
            <h:commandButton value="Rechercher" action="#{resultatRecherche.getCritere}" styleClass="col-lg-6 boutton"/>
        </div>
        <div class="col-lg-2"></div>
    </div>
</h:form>

and here is the method getCritere from my backing bean ResultatRecherche :

public String getCritere () throws Exception
{
    if ( isNullOrEmpty(prenomNomRecherche) && isNullOrEmpty(uoRecherche) )
    {
        return "pageRecherche";
    }
    else if ( !isNullOrEmpty(prenomNomRecherche) && isNullOrEmpty(uoRecherche) )
    {
        return getCollaborateursParNom();
    }
    //I am in these case
    else if ( isNullOrEmpty(prenomNomRecherche) && !isNullOrEmpty(uoRecherche) )
    {
        return getCollaborateursParUo();
    }
    else
    {
        return getCollaborateurParNomEtUo();
    }
}

My problem is that, when I select some items of my list (resultatRecherche.listeActiveUo) and I click on the Rechercher button, it works just fine (the result page is shown as expected), but when I select some other items from the list, the page remains as it is, and my p:selectOneMenu is surrounded by red.

I used the debugger to see where the problem is, and I noticed that for the cases which are not working, the getCritere method is not even reached.

Thanks for your help in advance.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
hicham
  • 53
  • 1
  • 2
  • 14
  • 1
    That "selectOneMenu becomes red" bit likely indicates a JSF validation error triggering. I would add a messages component to the page to have it printed out and see what it is. The fact that a validation error occurs is likely the reason why your action method is never invoked. – Gimby Apr 17 '15 at 11:19
  • 1
    There are multiple problems here. The duplicate shows how to fix the main problem of the command button not being invoked. Once you figured out the cause, then you should indeed face the second problem of a simple validation error blocking the submit, this is in turn answered in the following dupe: http://stackoverflow.com/questions/9069379/validation-error-value-is-not-valid/ – BalusC Apr 17 '15 at 11:24

0 Answers0