简体   繁体   中英

How to make two JSF selectOneMenu that depend on each other?

I have two instances of selectOneMenu , one dependent on the other. But my processValueChange in the bean is never invoked. JSP portion:

<h:selectOneMenu id="slaPeriod" onchange="submit()" required="true"> 
  <f:selectItems value="#{LoginForm.periodList}"/>
  <f:valueChangeListener type="form.LoginForm" />
</h:selectOneMenu>

I want to have the selected option and have an associated option in the next selectOneMenu . If say option is:

OPTIONS       VALUES
 1. Weekly     1....52
 2. Monthly    Jan...Dec
 3. Quaterly   1...4
 4. Yearly     this drop down has to be disabled

Associated bean :

public void processValueChange(ValueChangeEvent arg0) throws AbortProcessingException 
{
  System.out.println("Inside Process Value Change!!");
}

This method is never invoked. Once this is done my problem will be resolved.

If you have any idea please help me, I'm really confused. Every time there is a refresh action on selection but this method of the bean is never invoked.

Try the following:

  • Have you enclosed <h:selectOneMenu> within a <h:form> ?
  • Does your bean implements ValueChangeListener interface?
  • Is your bean inside the form package
  • Is your bean session scoped or request scope? (I'd suggest to try with session scope)
  • Is there any error on the console?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM