Hi John,

Thanks for the suggestion, but that did not work.  I suspect it didn't work
for the same reason that my attempt to use setEnabled(true/false) on the
AttributeModifier didn't work.  

It has to be with how wicket cache's pages.  I still don't quite grok how it
decides to re-render stuff...

My code:

    public CurrentProfile(String id)
    {
        ....

        displayModel = new DisplayModel();
        loginPanel.add(new AttributeModifier("style", true, displayModel));

        ....

        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)
                {
                    displayModel.setHidePanel(true);
                    target.addComponent(loginPanel);
                    target.addComponent(loginLabel);                    
                    target.appendJavascript(new
BlindDown(loginPanel).toJavascript());
                }
            }
        };

         ....
    }

    private class DisplayModel extends AbstractReadOnlyModel
    {
        boolean hidePanel = false;

        @Override
        public Object getObject()
        {
            return hidePanel ? "display: none" : "";
        }

        private void setHidePanel(boolean b)
        {
            hidePanel = b;
        }
    }

    @Override
    protected void onAfterRender()
    {
        displayModel.setHidePanel(false);
        super.onAfterRender();
    }

-Doug


John Krasnay wrote:
> 
> On Mon, Apr 21, 2008 at 07:18:57AM -0700, Doug Donohoe wrote:
>> 
>> 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).
>> 
> 
> One of the great things about models is that they facilitate lazy
> evaluation. Try this:
> 
>     new AttributeModifier("style", true, new AbstractReadOnlyModel() {
>         public Object getObject() {
>             return hidePanel ? "display: none" : "";
>         }
>     });
> 
> You can then toggle whether "display:none" is rendered by toggling the
> hidePanel field of your class.
> 
> jk
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/interesting-scriptaculous-usage-conundrum-tp16807943p16813005.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