You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alexander Monakhov <do...@gmail.com> on 2010/02/24 14:21:34 UTC

Modal Window, cookie and component update

Hi, guys.

I'm trying to create sing in page in modal window. So, there is home page
with sign in link. When user clicks the link modal window appears with
login/password form. When user submits valid authentication credentials
modal window is closed and sign in link is changed to sign out link.

Here is some code snipets:

Home page:

public class HomePage extends WebPage {

.....

public HomePage() {
....
        this.signInLink = new AjaxLink<Void>( SIGN_IN_LINK_ID ) {

            @Override
            public void onClick( AjaxRequestTarget target ) {
                modal.show( target );
            }

        };
        this.signOutLink = new Link<Void>( SIGN_OUT_LINK_ID ) {

            @Override
            public void onClick() {
                getSession().invalidate();

                setResponsePage( BasePage.this );
            }

        };

        signInLink.setOutputMarkupId( true );
        signOutLink.setOutputMarkupId( true );

        if ( ((CustomSession) getSession()).isSignedIn() ) {
            signInLink.setVisible( false );
        } else {
            signOutLink.setVisible( false );
        }

        add( signInLink );
        add( signOutLink );

/* here goes modal window initialization*/
}

    public void setSignedIn(
                    final boolean isSignedIn, final AjaxRequestTarget target
) {
        signInLink.setVisible( !isSignedIn );
        signOutLink.setVisible( isSignedIn );

        target.addComponent( signInLink );
        target.addComponent( signOutLink );
    }
}


In modal window there are two inputs for login and password and ajax button.
When user pushes submit button. setSignedIn() method of HomePage is called
and modal window is closed.

First problem is sign in link disappear when modal window is closed, but
sing out link doesn't appear (when I check ajax response, I can see that
component for sing out link was sent). Second problem is firefox doesn't
save value of login/password as it does usually(I guess it's issue of modal
window. Also, if setPersisted() method is invoked for login field, there is
an item in cookie, but it doesn't appear in login field next time user goes
to login page.). Third problem is if error() method is called, error message
doesn't appear in page, even though feedback panel is added( I was trying to
add feedback panel to home page or to panel that is added to modal window
without success. In any case in console WARN message appeared.)

Could you give me any suggestions?

Best regards, Alexander.

Re: Modal Window, cookie and component update

Posted by Alexander Monakhov <do...@gmail.com>.
Hey.

Thanks a lot for help. Feedback panel is shown now and sign out link appears
when it should. But firefox still doesn't want to save and insert values for
username/password fields. Usually, firefox asks to save login/password when
form is submitted, but when form is submitted from modal window with ajax
button, firefox doesn't ask anything. Also, usually firefox provides some
variants of text that fits this type of input field. But this time for
username input field it provides any information or some other information,
but not that was typed earlier.

Also, I've got another question. How could I make modal window to fit to his
content. I'm using setUseInitialHeight( false ), so height of modal window
fits height of content, but width is still to large.

Best regards, Alexander.

Re: Modal Window, cookie and component update

Posted by Igor Vaynberg <ig...@gmail.com>.
On Wed, Feb 24, 2010 at 5:21 AM, Alexander Monakhov <do...@gmail.com> wrote:
> Hi, guys.
>
> I'm trying to create sing in page in modal window. So, there is home page
> with sign in link. When user clicks the link modal window appears with
> login/password form. When user submits valid authentication credentials
> modal window is closed and sign in link is changed to sign out link.
>
> Here is some code snipets:
>
> Home page:
>
> public class HomePage extends WebPage {
>
> .....
>
> public HomePage() {
> ....
>        this.signInLink = new AjaxLink<Void>( SIGN_IN_LINK_ID ) {
>
>            @Override
>            public void onClick( AjaxRequestTarget target ) {
>                modal.show( target );
>            }
>
>        };
>        this.signOutLink = new Link<Void>( SIGN_OUT_LINK_ID ) {
>
>            @Override
>            public void onClick() {
>                getSession().invalidate();
>
>                setResponsePage( BasePage.this );
>            }
>
>        };
>
>        signInLink.setOutputMarkupId( true );
>        signOutLink.setOutputMarkupId( true );
>
>        if ( ((CustomSession) getSession()).isSignedIn() ) {
>            signInLink.setVisible( false );
>        } else {
>            signOutLink.setVisible( false );
>        }
>
>        add( signInLink );
>        add( signOutLink );
>
> /* here goes modal window initialization*/
> }
>
>    public void setSignedIn(
>                    final boolean isSignedIn, final AjaxRequestTarget target
> ) {
>        signInLink.setVisible( !isSignedIn );
>        signOutLink.setVisible( isSignedIn );
>
>        target.addComponent( signInLink );
>        target.addComponent( signOutLink );
>    }
> }
>
>
> In modal window there are two inputs for login and password and ajax button.
> When user pushes submit button. setSignedIn() method of HomePage is called
> and modal window is closed.
>
> First problem is sign in link disappear when modal window is closed, but
> sing out link doesn't appear (when I check ajax response, I can see that
> component for sing out link was sent).

s/signInLink.setOutputMarkupId( true );/
signInLink.setOutputMarkupPlaceholderTag(true);/

> Second problem is firefox doesn't
> save value of login/password as it does usually(I guess it's issue of modal
> window. Also, if setPersisted() method is invoked for login field, there is
> an item in cookie, but it doesn't appear in login field next time user goes
> to login page.).

i believe for this to work the input names must be stable, you can
override getinputname() on the two formcomponents to return
"username"/"password" instead of a dynamic name wicket generates. it
is your job, then, to make sure other form components do not cause
name collissions.

> Third problem is if error() method is called, error message
> doesn't appear in page, even though feedback panel is added( I was trying to
> add feedback panel to home page or to panel that is added to modal window
> without success. In any case in console WARN message appeared.)

your ajaxbutton has an onerror(), in there add the feedbackpanel to
the ajax target. also make sure you call
setoutputmarkupplaceholdertag(true) on the panel after you created it.

-igor

>
> Could you give me any suggestions?
>
> Best regards, Alexander.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org