简体   繁体   English

如何使两个相互依赖的JSF selectOneMenu?

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

I have two instances of selectOneMenu , one dependent on the other. 我有两个selectOneMenu实例,一个实例依赖于另一个实例。 But my processValueChange in the bean is never invoked. 但是我的bean中的processValueChange从未被调用。 JSP portion: JSP部分:

<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 . 我要具有选定的选项,并在下一个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. 每次对选择进行刷新操作时,都不会调用该bean方法。

Try the following: 请尝试以下操作:

  • Have you enclosed <h:selectOneMenu> within a <h:form> ? 您是否已将<h:selectOneMenu>包含在<h:form>
  • Does your bean implements ValueChangeListener interface? 您的bean是否实现ValueChangeListener接口?
  • Is your bean inside the form package 您的bean是否在form包中
  • Is your bean session scoped or request scope? 您的bean会话是作用域还是请求作用域? (I'd suggest to try with session scope) (我建议尝试使用会话范围)
  • Is there any error on the console? 控制台上是否有任何错误?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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