1

I have a problem I can not solve, I have a selectOneListbox with a Value Chang Listener and submit 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. 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:

 <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:

public void setActiveFromAllList(ValueChangeEvent event)
{

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

   Doing some stuff..


}
Daniel
  • 36,833
  • 10
  • 119
  • 200
Johan Nordli
  • 1,220
  • 3
  • 13
  • 26

1 Answers1

1

I think you might want to use the ajax event like this:

    <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.

Peter Jaloveczki
  • 2,039
  • 1
  • 19
  • 35
  • Thanks, it works perfectly. And here, others with the same problem read about the value change listeners: http://stackoverflow.com/questions/11879138/when-to-use-valuechangelistener-or-fajax-listener – Johan Nordli Jun 11 '13 at 14:43