Get a value from selectOneMenu

UI Components for JSF
Post Reply
pabloGaitan
Posts: 2
Joined: 15 Sep 2017, 18:03

15 Sep 2017, 18:38

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!

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

16 Sep 2017, 14:15

There is a button above the text editor that you can use to format code... And please post version info too

And

Code: Select all

 onchange="submit()" 
is bad... That is very oldschool JSF... Today there is ajax

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 28 guests