I want to process the value of an inputSecret using onblur functionality but I obtain the error Couldn't invoke method getOnblur
<b:column span="3">
<p:outputLabel value="#{msg.confirmPassword}" />
<b:inputSecret value="#{workerDetail.confirmPassword}" onblur="#{workerDetail.checkPassword}"/>
</b:column>
This is the method on the backing bean:
public void checkPassword(AjaxBehaviorEvent event)
{
System.out.println(confirmPassword);
}
How can I solve?
BootsFaces takes a slightly different approach to AJAX than the other JSF frameworks. The idea is to simply use the JavaScript callback functions to call a method in a Java backend bean. However, we also want to preserve compatibility to other JSF frameworks, so we couldn't follow you approach, as tempting as it may be. Instead, we decided to precede the AJAX call by an ajax:
prefix. It's followed by an EL expression which also defines the parameter list. In other words: other than standard JSF, BootsFaces doesn't pass the event parameter.
TL;DR:
Simply change your onblur
attribute like so:
<b:column span="3">
<p:outputLabel value="#{msg.confirmPassword}" />
<b:inputSecret value="#{workerDetail.confirmPassword}" onblur="ajax:workerDetail.checkPassword()"/>
</b:column>
Please note the brackets following checkPassword
. It's an EL expression which is executed when the event has been triggered and sent to the Java backend.
The resulting backing bean method doesn't need the event parameter:
public void checkPassword()
{
System.out.println(confirmPassword);
}
The difference to your approach is that your EL expression was evaluated when the page is rendered - which is a tad to early.