You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Zhubin Salehi <zh...@yahoo.com> on 2009/07/23 18:44:56 UTC

Markup for Disabled Panels and Pages

Hi all,

I was wondering if there is a way to change a panel's or page's markup or even class when it is disabled. I have two versions of some of my panels and pages: a XXXViewPanel/Page and a XXXEditPanel/Page. The view-only version has labels instead of dropdown menus and text fields. Based on user's roles some pages/panels might be view-only for some users and editable for some others. Is there a way that I can substitute a panel or page when it is disabled?

Thanks,
Zhubin

Re: Markup for Disabled Panels and Pages

Posted by Igor Vaynberg <ig...@gmail.com>.
a couple of ways jump to mind.

if all you really want is to swap out markup you can do

class mypanel extends panel {
   String getVariant() { if (!isenabled()) { return "disabled"; } else
{return null;}}
}

and have mypanel_disabled.html which will be used when the panel is disabled.


if you want to swap out the panel itself you can do something like this:

class vieweditpanel extends panel {
     panel current;

     protected void onbeforerender() {
        boolean edit=isenabled();
        boolean installedit=false;
        boolean installview=false;
        if (current==null) {
           installedit=edit; installview=!installedit;
        } else {
            if (edit&&!(current instanceof editpanel)) {
               installedit=true;
           } else if (!edit&&(!current instanceof viewpanel)) {
               installview=true;
           }
        }

        if (installedit) {current=new editpanel(...); addorreplace(current);}
        else if(installview) {current=new viewpanel(...);
addorreplace(current);}


       }
}

-igor


On Thu, Jul 23, 2009 at 9:44 AM, Zhubin Salehi<zh...@yahoo.com> wrote:
> Hi all,
>
> I was wondering if there is a way to change a panel's or page's markup or even class when it is disabled. I have two versions of some of my panels and pages: a XXXViewPanel/Page and a XXXEditPanel/Page. The view-only version has labels instead of dropdown menus and text fields. Based on user's roles some pages/panels might be view-only for some users and editable for some others. Is there a way that I can substitute a panel or page when it is disabled?
>
> Thanks,
> Zhubin
>

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