0

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

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
b.lopes
  • 435
  • 1
  • 7
  • 17

2 Answers2

0

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.

Zhedar
  • 3,480
  • 1
  • 21
  • 44
  • That was my first thought, too. But on the other hand, it contradicts the goal of orthogonality. I didn't implement it in the current version of BootsFaces, but there's no reason to not implement it. This evening, I'd like to give it a try. – Stephan Rauh May 23 '16 at 19:29
0

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");
  }
}

enter image description here

Stephan Rauh
  • 3,069
  • 2
  • 18
  • 37