Get a value from selectOneMenu

UI Components for JSF
Post Reply
quanghai
Posts: 1
Joined: 02 Feb 2018, 09:26

02 Feb 2018, 09:28

I´m trying to get the value "agrupacionEc" of a p:selectOneMenu combobox, but this value is not being captured (it appears null) before the execution of the valueChangeListener method

This is my code.
xhtml
<p:selectOneMenu value="#{userWizard.agrupacionEc}" style="width:100%" onchange="submit()" valueChangeListener="#{userWizard.valueChanged}">
<f:selectItem itemLabel="Select a ..." />
<f:selectItems value="#{userWizard.agrupaciones}" var="agrup" itemLabel="#{agrup}"
itemValue="#{agrup}"/>
</p:selectOneMenu>

Controller
public void valueChanged(ValueChangeEvent event) {
if(agrupacionEc != null){
if(agrupacionEc.equals(EmpresaTipoActividadEconomica.SERVICIOS)){
visible = true;
}

}

Can anyone help me by indicating what is missing? Thank you!

Jan Eckert
Posts: 84
Joined: 11 Sep 2014, 10:13
Location: Brussels, Belgium

02 Feb 2018, 10:18

Please use code tags like this to make it readable:
This is my code.

xhtml

Code: Select all

   <p:selectOneMenu value="#{userWizard.agrupacionEc}" style="width:100%" onchange="submit()" valueChangeListener="#{userWizard.valueChanged}">
      <f:selectItem itemLabel="Select a ..." />
      <f:selectItems value="#{userWizard.agrupaciones}" var="agrup" itemLabel="#{agrup}" itemValue="#{agrup}"/>
   </p:selectOneMenu>
Controller

Code: Select all

public void valueChanged(ValueChangeEvent event) {
   if(agrupacionEc != null){
      if(agrupacionEc.equals(EmpresaTipoActividadEconomica.SERVICIOS)){
         visible = true;
      }
   }
}
This time the service was for free, next time will charge $1. I will have a look at the problem later :)
Primefaces 6.1+
Wildfly 11

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 36 guests