0

I want toupdate a value everytime a change in value occurs in a selectOneMenu, and that works well, but I have a submit button that should be pressed after making a selection, the thing is that when I press that button with a selection made the entire class (bean) resets, I do not want the class to reset

 <div class="top-panel">
            <div class="labels">
                <label class="maquina">Maquina: #{buscarBean.maqSeleccionada}</label>
                <label class="label">Estado de la busqueda: </label>
            </div>
            
            <div class="dropdown">
                <p:selectOneMenu class="dropdown-select" id="seleccion"                       
                                 value="#{buscarBean.maqSeleccionada}">
                
                <f:selectItem itemLabel="Selecciona Maquina" itemValue="" />
                <f:selectItems value="#{buscarBean.getMapMaquinas()}" />
                <p:ajax event ="valueChange"  
                        partialSubmit="true" 
                        listener="#{buscarBean.maqSeleccionada}" />
                </p:selectOneMenu>
            </div>

            <h:form>
                <div class="buttons">
                    <button class="button">Parar Busqueda</button>
                    <button class="button">Ver Respuesta de la Maquina</button>
                    <button class="button">Parametros Seleccionados</button>
                    <h:commandButton class="button" value="Mostrar Todos los Parametros" action="#{buscarBean.updateCrearArchivo()}" />
                </div>
            </h:form>
        </div>

I have tried changing the scope of the bean and different methods of writing the ajax.

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
  • 1
    Use p:commandButton instead of h:commandButton? Put p:selectOneMenu inside h:form? remove event=valueChange? – Nikola Jul 06 '23 at 19:25
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jul 06 '23 at 19:59
  • Suggestion: take a step back and learn basic HTML first. Before using JSF (which is basically just a HTML code generator) you should already have known that you need to put the input elements in the **same** form as the submit element. It's not different in JSF. – BalusC Jul 07 '23 at 10:59

0 Answers0