简体   繁体   English

获取selectOneMenu选择的值

[英]get selectOneMenu selected value

i have a clientId for selectOneMenu. 我有一个selectOneMenu的clientId。 i programmatically invoke the UIComponent using. 我以编程方式调用UIComponent。 but this is where i get confused, i want to get the selected value on the selectOneMenu. 但这是我感到困惑的地方,我想在selectOneMenu上获取选定的值。 i have tried getValue(), it gives the default value , and getsubmittedvalue() gives null. 我已经尝试过getValue(),它给出了默认值,而getsubmittedvalue()给出了null。

can someone please help me? 有人可以帮帮我吗?

thanks in advance 提前致谢

This discrepancy can occur when you're invoking it at the wrong moment of the JSF lifecycle or when the component is part of an iterated component like h:dataTable and the component is currently not in the iteration stage. 当您在JSF生命周期的错误时刻调用该差异时,或者当该组件是诸如h:dataTable类的迭代组件的一部分并且该组件当前不在迭代阶段时,就会出现这种差异。 After all, this isn't the way how the JSF stuffs ought to work. 毕竟,这不是JSF东西应该如何工作的方式。 The normal approach is to bind the value to a bean property and then just access exactly that property in the action method associated with the command link/button. 通常的方法是将值绑定到bean属性,然后仅在与命令链接/按钮关联的action方法中完全访问该属性。

Anyway, I think that the actual problem is already been solved by my answer on your other question . 无论如何,我认为实际问题已经由我对您其他问题的回答解决。

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

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