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

Reply via email to