I am trying to implement a login section which appears (inserted into he
page) when a user clicks a [login] link at the top of the page.  I have this
working fine with AjaxFallbackLink which turns visibility on/off based on
the link.  The pertinent code is as follows:

        Link link = new AjaxFallbackLink("loginLink", new Model(loginText))
        {
            @Override
            public void onClick(final AjaxRequestTarget target)
            {
                loginPanel.setVisible(!loginPanel.isVisible());
                loginLabel.setModelObject(loginPanel.isVisible() ?
cancelText : loginText);

                if (target != null)
                {
                    target.addComponent(loginPanel);
                    target.addComponent(loginLabel);
                }
            }
        };

Everything works great.  Next I wanted to use the scriptaculous "blind down"
effect to unveil the login box instead of just appearing all at once.

So I added a line which did this when displaying the panel:

    target.appendJavascript(new BlindDown(loginPanel).toJavascript());

Where BlindDown is an implementation of the wicket-stuff scriptaculous
effect.

This worked with one issue: the login panel "flashed", went away and then
was revealed.  This is because the login panel needs to be initially hidden 
(style="display: none") for the 'blind down' to be visually correct.

So I added an attribute modifier to the loginPanel:

    new AttributeModifier("style", true, new Model("display: none")

This corrected the 'flash' problem.  But introduced another problem.  Now,
when the form is submitted with an error, when the page is redisplayed, the
form is hidden (because the attribute modifier is still in effect).

I tried two ways to turn off the AttributeModifier:

1) remove it in an onAfterRender call, but I got a exception regarding
modifying component tree during render.  I couldn't find a way to actually
remove it after render due to all the 'final' methods.  However, this may
not have worked anyway for the same reason #2 below didn't work.

2) call setEnabled(false) on the AttributeModifier in the onAfterRender()
call, but that seems to have no effect.  I assume this is because of how the
page is cached internally in wicket.  I'm not 100% certain how wicket
redisplays a page with a form without re-rendering the page, but apparently
it doesn't revisit it's attribute modifiers.

So the question is, how to solve this problem.  I essentially have a case
where I need to have a "one-time-only" attribute modifier.  When the
component is sent back in an Ajax request, it needs to be set, but otherwise
not set.

Any suggestions on how to solve this?

Thanks,

-Doug
-- 
View this message in context: 
http://www.nabble.com/interesting-scriptaculous-usage-conundrum-tp16807943p16807943.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to