Can I do something like this:
<b:navLink ... onclick="ajax:callBeanMethodA;ajax:callBeanMethodB" />
Like that doesn't work, is there any way to make it work ?
Thanks
Can I do something like this:
<b:navLink ... onclick="ajax:callBeanMethodA;ajax:callBeanMethodB" />
Like that doesn't work, is there any way to make it work ?
Thanks
I guess your best bet it to combine these two or multiple method calls in a convenience method in your backing bean.
This way you can also make sure, that they're called in a consistent order:
public void combinedMethod() {
callBeanMethodA();
callBeanMethodB();
}
Then just call the single convenience method from your listener:
<b:navLink ... onclick="ajax:beanName.combinedMethod" />
Other advantages of this approach would be better readability and reusability and maintainability, as you defined the combined logic centrally.
Actually, it does work. It's just a bit simpler than you thought. Omit the second ajax:
prefix, and things work fine:
JSF markup:
<b:messages id="messages" />
<b:commandButton value="Click me!"
onclick="ajax:menuView.save();menuView.reload()"
update="@form">
</b:commandButton>
Java bean:
@ManagedBean
public class MenuView {
public void save() {
addMessage("Success", "Data saved");
}
public void reload() {
addMessage("Success", "reloaded");
}
}