2

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...
1
  • You can pass the parameter not the method to javascript Commented Apr 13, 2011 at 9:50

2 Answers 2

3

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>  
Sign up to request clarification or add additional context in comments.

2 Comments

@sfrj with your case #{securityController.logIn} This will search for getLogIn() in securityController controller bean , you are passing it as value. @Matt +1
I did that and now i dont get build error. But when i click on the submit button i get an error. I think it has to do with the EJB. I will make an update to show you.
0

If you want to execute method on a javascript event then use <a4j:jsfunction>

Example here.

3 Comments

you forgot the link to the example
Is there any other alternative, i dont want to use richfaces. I had conflicts in the past with primefaces + rich faces together
@sfrj : then better add action to your commandbutton and oncomplete do the stuff you want passing any boolean variable set in action.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.