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<zhooz...@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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to