Having ValueChangeListener problem

In my method processValueChange(....

i have written the following code -

if (phaseId.equals(PhaseId.ANY_PHASE)) {

event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);

event.queue();

}

else if (phaseId.equals(PhaseId.UPDATE_MODEL_VALUES)) {

. . . .

}

But it never reached the else if block. What should i do?

[363 byte] By [steinvommarsa] at [2007-11-26 12:33:34]
# 1
Are there other phases than ANY_PHASE then?
BalusCa at 2007-7-7 15:48:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Sorry, I did not get your question.
steinvommarsa at 2007-7-7 15:48:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
what is the date type of phaseId?
jgalacambraa at 2007-7-7 15:48:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
That constant ANY_PHASE is pretty descriptive, isn't it?If you check for *every possible* phase in the if clause already, then how are you ever supposed to reach the else if clause?
PTownswortha at 2007-7-7 15:48:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
> Sorry, I did not get your question.You're checking any phase. There are no other phases than "any phase", so the else if indeed will never be called :o)
BalusCa at 2007-7-7 15:48:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

are you trying to do this

this code should work fine

public void changeMethod(ValueChangeEvent event)

{

PhaseId phaseId = event.getPhaseId();

if (phaseId.equals(PhaseId.ANY_PHASE))

{

event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);

event.queue();

}

else if (phaseId.equals(PhaseId.UPDATE_MODEL_VALUES))

{

// do you method here

}

}

dboyd68a at 2007-7-7 15:48:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
i use this exact code in my app
dboyd68a at 2007-7-7 15:48:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8

public void changeMethod(ValueChangeEvent event) {

PhaseId phaseId = event.getPhaseId();

if (phaseId.equals(PhaseId.ANY_PHASE)) {

event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);

event.queue();

} else if (phaseId.equals(PhaseId.UPDATE_MODEL_VALUES)) {

// do you method here

}

}

I really don't understand this approach :) The else if will never be reached.

Better do:

public void changeMethod(ValueChangeEvent event) {

PhaseId phaseId = event.getPhaseId();

if (phaseId.equals(PhaseId.UPDATE_MODEL_VALUES)) {

// do you method here

} else {

event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);

event.queue();

}

}

BalusCa at 2007-7-7 15:48:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
Why do you need an if else statement if you want to do both parts? just stick the code together in a method. Or you could do both in one branch of the if statement if there are more than two branches.if (phaseId.equals(PhaseId.UPDATE_MODEL_VALUES) ||
Illua at 2007-7-7 15:48:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...