Skip to main content

bug at jsf 2.0 f:setPropertyActionListener

3 replies [Last post]
neverminddenis
Offline
Joined: 2009-11-23
Points: 0

f:setPropertyActionListener works after action, but must work before action. It seems like bug at mojarra

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vesuvius
Offline
Joined: 2007-06-02
Points: 0

Could you show your code? I tried a commandButton with an action and sPAL, and it worked properly, but I may be doing something completely different than you.

You may also wish to read this:
http://weblogs.java.net/blog/cayhorstmann/archive/2009/07/say_sayonara_t...

neverminddenis
Offline
Joined: 2009-11-23
Points: 0

It's simple test which I tried to undestand this problem. What message should appear when click on test button? I think there should be "heyMan", but if you'll try you see "heynull" at first click. And only after second click you'll see right message

@ManagedBean(name="testBean")
@SessionScoped
public class TestBean implements Serializable{
private String name;
private String message;

public void test(ActionEvent e) {
message = "hey" + name;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}
}

xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">

Facelet Title








vesuvius
Offline
Joined: 2007-06-02
Points: 0

[b]actionListener[/b]s are called in the order in which they are specified on the page.

Since your button's [b]actionListener[/b] precedes the [b]setPropertyActionListener[/b] on the page, it's called first.

As a workaround, you could replace the [b]actionListener[/b] with [b]action[/b]. You should return null from the action method, so that you'll remain on the same page.

I suppose you could also do something like this:

[code]




[/code]

Thus, the [b]setPropertyActionListener[/b] precedes the [b]actionListener[/b]. However, I'm not at my PC at the moment and won't be there for several more hours, so I'm just writing this without having tested it first. I just think it should work.