简体   繁体   English

使用提交但设置和获取方法后触发valueChangeListener

[英]Fire valueChangeListener with submit but after set and get methods

I have a problem I can not solve, I have a selectOneListbox with a Value Chang Listener and submit onclick. 我有一个无法解决的问题,我有一个带有值更改监听器的selectOneListbox并提交onclick。 It works perfectly but the problem I have noticed is that the Set and Get methods I have for other elements in my form runs after the method that captures the ValueChangeListener. 它工作正常,但我注意到的问题是,表单中其他元素的Set和Get方法在捕获ValueChangeListener的方法之后运行。 And I can not use the right data from the elements in my form, how do I resolve this? 而且我无法使用表单元素中的正确数据,如何解决此问题?

So i got in my selectOneListbox: 所以我进入了selectOneListbox:

 <h:selectOneListbox onclick="Submit();" 
valueChangeListener="#{normalbesoksgrenController.setActiveFromAllList}" 
size="20" value="#{normalbesoksgrenController.currentVardTillfalleID}">

 <f:selectItems itemValue="#{item.vardTillfalle.id}" itemLabel="# 
{normalbesoksgrenController.getDateAndTime(item.getVardTillfalle().getStartTid())}"
var="item" value="#{normalbesoksgrenController.besokList}" ></f:selectItems>

             </h:selectOneListbox>

And i got my backbean: 我得到了我的backbean:

public void setActiveFromAllList(ValueChangeEvent event)
{

    int id = Integer.parseInt(event.getNewValue().toString());

   Doing some stuff..


}

I think you might want to use the ajax event like this: 我认为您可能想使用像这样的ajax事件:

    <h:selectOneListBox .....>
       <f:ajax execute="@form" listener="#{normalbesoksgrenController.setActiveFromAllList}" event="change" reder=":whatEverYouWant"  />
    </h:selectOneListBox>

The execute attribute defines what should be submitted before the ajax request is handled. execute属性定义在处理ajax请求之前应提交的内容。

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

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