Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

combo boks

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
del1.jsp

<h:selectOneMenu value="#{del1.selectedOption}" onchange="submit();"
valueChangeListener="#{del1.selectedOptionChanged}">
<f:selectItem itemLabel="Vet ikke" itemValue="Vet ikke"/>
<f:selectItem itemLabel="Mann" itemValue="Mann"/>
<f:selectItem itemLabel="Kvinne" itemValue="Kvinne"/>
</h:selectOneMenu>

Personnr.java

private String selectedOption;

public String getSelectedOption()
{
return selectedOption;
}

public void setSelectedOption(String selectedOption)
{
this.selectedOption = selectedOption;
}

public void selectedOptionChanged(ValueChangeEvent event)
{
selectedOption = (String)event.getNewValue();
if(selectedOption.equals("Vet ikke"))
activateOtherInput = true;
else
activateOtherInput = false;
FacesContext context = FacesContext.getCurrentInstance();

context.renderResponse();
}

faces-config.xml
<faces-config>
<managed-bean>
<managed-bean-name>del1</managed-bean-name>
<managed-bean-class>Personnr</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>


where is the problem? i want to access value that i have selected in combo box?
 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The values are not updated until the Update Model Values Phase and value change events are fired in process validations phase, you can get 'selected option' to point to correct value in Invoke application phase(command button/link)
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there!
I have the same problem, so i'll appreciate if you could tell us the solution you find.
In my case the selectOneMenu it's linked to another so i need to get the value and process the info before submit the form.

The setters methods of my bean are not called neither my valueChangeListener method. Is there any way to force to call them?

Any help and comments will be appreciate.

Thanks and sorry for my lame english.
 
Mario Campos
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there!
I have the same problem, so i'll appreciate if you could tell us the solution you find.
In my case the selectOneMenu it's linked to another so i need to get the value and process the info before submit the form.

The setters methods of my bean are not called neither my valueChangeListener method. Is there any way to force to call them?

Any help and comments will be appreciate.

Thanks and sorry for my lame english.
 
Kavita Tipnis
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In that case you have to use the binding attribute and then use the SetValue to set the value of the second drop down based on a ValueChangeEvent on the first drop down.
This link will be very helpful
http://balusc.blogspot.com/2007/10/populate-child-menus.html
 
reply
    Bookmark Topic Watch Topic
  • New Topic