Search code examples
jsfselectonemenuconfirm

How to get a confirmation box when value change in h:selectOneMenu


I'm having trouble trying to get a confirmation box when someone change the value in a h:selectOneMenu and if the person accept, then the value changes, otherwise it return to its original value.

I do not know how to manage to do this, I have made some research but most of the answer I found were for PrimeFaces (which I do not use).

Here's the relevant part of code with the selectOneMenu :

<ui:repeat value="#{CommandeBean.choixMetaProprietes}" var="choixMetaProprietes">
    <h:selectOneMenu value="#{choixMetaProprietes.metaProprieteSelectionnee}">
        <f:selectItems noSelectionValue="#{CommandeBean.retrieveDefaultMetaProprietesValue()}" value="#{choixMetaProprietes.metaProprietes}" var="metaPropriete" itemLabel="#{metaProprieteConverter.getMetaProprieteLabel(metaPropriete)}" itemValue="#{metaPropriete}"/>
        <f:converter converterId="com.festo.didactic.ca.webapp.entreecommandes.converter.MetaProprieteConverter"/>
    </h:selectOneMenu>
</ui:repeat>

I'm open to any idea that could help me solve this problem.


Solution

  • I finally manage to do it by storing the data in an input hidden and then compare the actual value of the selectOneMenu with the input in query.

    i was then able to call a confirmation box via confirm('blabla bla'). the result would then tell me if i need to keep the value or put the previous one.