Reputation: 12423
I am making a custom login dialog, similar to the one found on http://www.primefaces.org/showcase/ui/dialogLogin.jsf but i get an error when building:
javax.el.PropertyNotFoundException: /WEB-INF/templates/BasicTemplate.xhtml @58,83 oncomplete="handleLoginRequest(#{securityController.logIn})": The class 'managedbeans.SecurityController' does not have the property 'logIn'.
I think the mistake is in the way i try to trigger the logging procedure. Could someone have a look if my syntax is correct?
<p:dialog id="dialog" header="Login" widgetVar="dlg" modal="true" width="400" resizable="false" draggable="false" fixedCenter="true">
<h:form>
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="username" value="Em@il: *" />
<p:inputText value="#{securityController.email}"
id="email" required="true" label="email" />
<h:outputLabel for="password" value="Password: * " />
<h:inputSecret value="#{securityController.password}"
id="password" required="true" label="password" />
<f:facet name="footer">
<p:commandButton value="Login" update="growl"
oncomplete="handleLoginRequest(#{securityController.logIn})"/>
</f:facet>
</h:panelGrid>
</h:form>
</p:dialog>
<script type="text/javascript">
function handleLoginRequest(input) {
if(input == false) {
jQuery('#dialog').parent().effect("shake", { times:3 }, 100);
} else {
dlg.hide();
jQuery('#loginLink').fadeOut();
}
}
</script>
And this the managed bean that holds the method that is being called onComplete event:
@ManagedBean
@RequestScoped
public class SecurityController {
@EJB
private IAuthentificationEJB authentificationEJB;
private String email;
private String password;
private String notificationValue;
public void logIn() {
if(authentificationEJB.saveUserState(email, password)) {
notificationValue = "Dobro dosli";
}
}
//getters and setters...
Upvotes: 2
Views: 8055
Reputation: 30025
You have to call your login method from the actionListener
attribute of p:commandButton
and not inside the oncomplete
attribute. The javascript function from the example can be used without changes. It is only for displaying the effect.
Change your p:commandButton
this way:
<p:commandButton value="Login" update="growl"
oncomplete="handleLoginRequest(xhr, status, args)"
actionListener="#{securityController.logIn}"
/>
And use the js function exactly as in the primefaces showcase:
<script type="text/javascript">
function handleLoginRequest(xhr, status, args) {
if(args.validationFailed || !args.loggedIn) {
jQuery('#dialog').parent().effect("shake", { times:3 }, 100);
} else {
dlg.hide();
jQuery('#loginLink').fadeOut();
}
}
</script>
Upvotes: 3