i see. i guess i assumed that the Link knows about the page it's linking from setResponsePage() in onClick(). so, in this use case is there any difference whether to override linksTo() or isEnabled()? i think overriding isEnabled() is more generic, if latter i'll need to add more logic to disable the link this will be the place to do it. anything else?

Thanks


From: "Martijn Dashorst" <[EMAIL PROTECTED]>
Reply-To: wicket-user@lists.sourceforge.net
To: wicket-user@lists.sourceforge.net
Subject: Re: [Wicket-user] RefreshingView and Link.setAutoEnable
Date: Fri, 29 Jun 2007 14:14:18 +0200

How would the Link know to which page it is linking? You need to provide

protected boolean linksTo(final Page page)

See the code for Link#isEnabled():

        /**
         * @see wicket.Component#isEnabled()
         */
        public boolean isEnabled()
        {
                // If we're auto-enabling
                if (getAutoEnable())
                {
                        // the link is enabled if this link doesn't link to the 
current page
                        return !linksTo(getPage());
                }
                return super.isEnabled();
        }

Martijn

On 6/29/07, Vadim Tesis <[EMAIL PROTECTED]> wrote:
> all,
>
> i'm trying to create a list of links using Refreshing view in wicket 1.3. > for some reason if i call Link.setAutoEnable(true) it doesn't really work, > the link is enabled all the time. however if i override Link.isEnabled()
> method it works, the link becomes disabled on the page it points to.
> there're 3 classes: BasePage, and HomePage, SignInPage which extend
> BasePage.  i'm creating RefreshingView in the BasePage.
> the code is below.  am i doing something wrong?
>
> Thanks,
> Vadim
>
> HTML:
> <ul >
>     <li wicket:id="refreshingView">
>       <a href="#" wicket:id="item">[Item Here]</a>
>     </li>
> </ul>
>
> Java:
> public class BasePage
> {
> Form form = new ...;
> final List<IModel> items = new ArrayList<IModel>();
> items.add(new AbstractReadOnlyModel()
>                {
>          private static final long serialVersionUID = 1L;
>         @Override
>          public Object getObject()
>         {
>             return (new Link("item")
>                 {
> //                @Override
> // public boolean isEnabled() { return (getPage().getClass() !=
> HomePage.class); }
>                   @Override
> public void onClick() { setResponsePage(HomePage.class); }
> //                             });
>                 }.setAutoEnable(true));
>         }
>               });
> items.add(new AbstractReadOnlyModel()
>         {
>         private static final long serialVersionUID = 1L;
>         @Override
>         public Object getObject()
>         {
>           return (new Link("item")
>                 {
> //              @Override
> // public boolean isEnabled() { return (getPage().getClass() !=
> SignInPage.class); }
>                 @Override
>                 public void onClick()
>                 { setResponsePage(SignInPage.class); }
> //              });
>                 }.setAutoEnable(true));
>         }
>             });
>
> form.add(new RefreshingView("refreshingView")
>         {
>         @Override
>         protected Iterator getItemModels() { return items.iterator(); }
>         @Override
>         protected void populateItem(Item item_)
>         {
>            AbstractLink al = (AbstractLink) item_.getModelObject();
>            if (item_.getIndex() == 0)
>              item_.add(new AttributeAppender("class", true, new
> Model("firstelement"), ""));
>            item_.add(al);
>         }
>             });
>
> add(form);
> }
>
> _________________________________________________________________
> Don't miss your chance to WIN $10,000 and other great prizes from Microsoft
> Office Live http://clk.atdmt.com/MRT/go/aub0540003042mrt/direct/01/
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>


--
Wicket joins the Apache Software Foundation as Apache Wicket
Join the wicket community at irc.freenode.net: ##wicket
Wicket 1.2.6 contains a very important fix. Download Wicket now!
http://wicketframework.org

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

_________________________________________________________________
Picture this – share your photos and you could win big! http://www.GETREALPhotoContest.com?ocid=TXT_TAGHM&loc=us


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to