setResponsePage is not working in SignInPanel

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

setResponsePage is not working in SignInPanel

aabfattah
Hello ,
I have reused the code of the SignInPanel to make another class with Arabic support then I added a button to signup for new user inside the sign in form but this button doesn't work and doesn't throw any exceptions

I made a system.println inside the button onSubmit() method and it prints in console but it doesn't do a redirect .

//From SignInPanel.java

         */
                public SignInForm(final String id) {
                        super(id);

                        setModel(new CompoundPropertyModel<SignInPanel>(SignInPanel.this));

                        // Attach textfields for username and password
                        add(new TextField<String>("username").setRequired(true));
                        add(new PasswordTextField("password").setRequired(true));

                        // MarkupContainer row for remember me checkbox
                        WebMarkupContainer rememberMeRow = new WebMarkupContainer(
                                        "rememberMeRow");
                        add(rememberMeRow);

                        // Add rememberMe checkbox
                        rememberMeRow.add(new CheckBox("rememberMe"));

                        // Show remember me checkbox?
                        rememberMeRow.setVisible(includeRememberMe);
                       
                        //New User button

                        Button registerButton= new Button("register" )
                        {
                                public void onSubmit()
                                {
                                       
                                        setResponsePage(AddNewCustomerPage.class);
                                        System.out.println("New user button was pressed");
                                }
                        };
                        registerButton.setDefaultFormProcessing(false);
                        add(registerButton);

                }

                /**
                 * @see org.apache.wicket.markup.html.form.Form#onSubmit()
                 */
                @Override
                public final void onSubmit() {
                        IAuthenticationStrategy strategy = getApplication()
                                        .getSecuritySettings().getAuthenticationStrategy();

                        if (signIn(getUsername(), getPassword())) {
                                //onSignInSucceeded();
                                User user = ((CallToFixWebSession) getSession()).getUser();
                                onSignInSucceededWithRedirect(user);

                                if (rememberMe == true) {
                                        strategy.save(username, password);
                                } else {
                                        strategy.remove();
                                }
                        } else {
                                onSignInFailed();
                                strategy.remove();
                        }
                       
                         
Reply | Threaded
Open this post in threaded view
|

Re: setResponsePage is not working in SignInPanel

Martin Grigorov-4
On Mon, Sep 19, 2011 at 1:32 PM, aabfattah
<[hidden email]> wrote:
> Hello ,
> I have reused the code of the SignInPanel to make another class with Arabic
> support then I added a button to signup for new user inside the sign in form
> but this button doesn't work and doesn't throw any exceptions
>
> *I made a system.println inside the button onSubmit() method and it prints
> in console but it doesn't do a redirect .
I guess it does redirect but then the authentication check makes
another redirect to the login page.
Check Firebug's logs in Net tab.

> *
> //From SignInPanel.java
>
>         */
>                public SignInForm(final String id) {
>                        super(id);
>
>                        setModel(new CompoundPropertyModel<SignInPanel>(SignInPanel.this));
>
>                        // Attach textfields for username and password
>                        add(new TextField<String>("username").setRequired(true));
>                        add(new PasswordTextField("password").setRequired(true));
>
>                        // MarkupContainer row for remember me checkbox
>                        WebMarkupContainer rememberMeRow = new WebMarkupContainer(
>                                        "rememberMeRow");
>                        add(rememberMeRow);
>
>                        // Add rememberMe checkbox
>                        rememberMeRow.add(new CheckBox("rememberMe"));
>
>                        // Show remember me checkbox?
>                        rememberMeRow.setVisible(includeRememberMe);
>
>                        *//New User button*
>
>                        *Button registerButton= new Button("register" )
>                        {
>                                public void onSubmit()
>                                {
>
>                                        setResponsePage(AddNewCustomerPage.class);
>                                        System.out.println("New user button was pressed");
>                                }
>                        };
>                        registerButton.setDefaultFormProcessing(false);
>                        add(registerButton);*
>                }
>
>                /**
>                 * @see org.apache.wicket.markup.html.form.Form#onSubmit()
>                 */
>                @Override
>                public final void onSubmit() {
>                        IAuthenticationStrategy strategy = getApplication()
>                                        .getSecuritySettings().getAuthenticationStrategy();
>
>                        if (signIn(getUsername(), getPassword())) {
>                                //onSignInSucceeded();
>                                User user = ((CallToFixWebSession) getSession()).getUser();
>                                onSignInSucceededWithRedirect(user);
>
>                                if (rememberMe == true) {
>                                        strategy.save(username, password);
>                                } else {
>                                        strategy.remove();
>                                }
>                        } else {
>                                onSignInFailed();
>                                strategy.remove();
>                        }
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/setResponsePage-is-not-working-in-SignInPanel-tp3823554p3823554.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com
Reply | Threaded
Open this post in threaded view
|

Re: setResponsePage is not working in SignInPanel

aabfattah
Reply | Threaded
Open this post in threaded view
|

Re: setResponsePage is not working in SignInPanel

aabfattah
To be more precise :

A post is done .
Then a get request to the page I want.
Then a get request to the homepage again .


How can I solve this ?