You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Tauren Mills <ta...@tauren.com> on 2007/09/26 09:24:03 UTC
ExternalLink doesn't use model?
I don't understand why ExternalLink doesn't store the external href as
the model. It stores it in an href property. It seems to not follow
the normal wicket way.
This makes it difficult to do things like display a link only if the
model is not null. For instance:
add(new ExternalLink("web", new PropertyModel(service,"web")) {
@Override
public boolean isVisible() {
if (getModelObject() == null) {
return false;
}
return super.isVisible();
}
});
The problem is that getModelObject() is always null, because the
PropertyModel is stored in the href property. And since isVisible()
is part of Component, the href property isn't accessible.
Any suggestions for a simple solution?
Thanks,
Tauren
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: ExternalLink doesn't use model?
Posted by Eelco Hillenius <ee...@gmail.com>.
Anonymous class would be fine if you just pick one of the constructors.
Eelco
On 9/26/07, Tauren Mills <ta...@tauren.com> wrote:
> Eelco,
>
> Thanks. I was trying to do it as an anonymous class, but your idea is
> simpler. Here's what I ended up with:
>
> public class HidingExternalLink extends ExternalLink {
>
> private static final long serialVersionUID = 1L;
>
> public HidingExternalLink(final String id, final String href) {
> this(id, href, null);
> }
>
> public HidingExternalLink(final String id, final IModel href) {
> this(id,href,null);
> }
>
> public HidingExternalLink(final String id, final String href, final
> String label) {
> super(id, href, label);
> setModel(new Model(href));
> }
>
> public HidingExternalLink(final String id, final IModel href, final
> IModel label) {
> super(id, href, label);
> setModel(href);
> }
>
> public boolean isVisible() {
> return getModelObject() != null;
> }
>
> }
>
> Tauren
>
>
>
>
> On 9/26/07, Eelco Hillenius <ee...@gmail.com> wrote:
> > > In the meantime, anyone have suggestions how to create a link to an
> > > external web page that is only visible if the model is not null?
> >
> > class MyExternalLink extends ExternalLink {
> > .... constructors ....
> >
> > public boolean isVisible() {
> > return getModelObject() != null;
> > }
> > }
> >
> > Eelco
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: ExternalLink doesn't use model?
Posted by Tauren Mills <ta...@tauren.com>.
Eelco,
Thanks. I was trying to do it as an anonymous class, but your idea is
simpler. Here's what I ended up with:
public class HidingExternalLink extends ExternalLink {
private static final long serialVersionUID = 1L;
public HidingExternalLink(final String id, final String href) {
this(id, href, null);
}
public HidingExternalLink(final String id, final IModel href) {
this(id,href,null);
}
public HidingExternalLink(final String id, final String href, final
String label) {
super(id, href, label);
setModel(new Model(href));
}
public HidingExternalLink(final String id, final IModel href, final
IModel label) {
super(id, href, label);
setModel(href);
}
public boolean isVisible() {
return getModelObject() != null;
}
}
Tauren
On 9/26/07, Eelco Hillenius <ee...@gmail.com> wrote:
> > In the meantime, anyone have suggestions how to create a link to an
> > external web page that is only visible if the model is not null?
>
> class MyExternalLink extends ExternalLink {
> .... constructors ....
>
> public boolean isVisible() {
> return getModelObject() != null;
> }
> }
>
> Eelco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: ExternalLink doesn't use model?
Posted by Eelco Hillenius <ee...@gmail.com>.
> In the meantime, anyone have suggestions how to create a link to an
> external web page that is only visible if the model is not null?
class MyExternalLink extends ExternalLink {
.... constructors ....
public boolean isVisible() {
return getModelObject() != null;
}
}
Eelco
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: ExternalLink doesn't use model?
Posted by Tauren Mills <ta...@tauren.com>.
Martijn,
Will do.
In the meantime, anyone have suggestions how to create a link to an
external web page that is only visible if the model is not null?
Thanks,
Tauren
On 9/26/07, Martijn Dashorst <ma...@gmail.com> wrote:
> Please add a feature request to the JIRA.
>
> Martijn
>
> On 9/26/07, Tauren Mills <ta...@tauren.com> wrote:
> > I don't understand why ExternalLink doesn't store the external href as
> > the model. It stores it in an href property. It seems to not follow
> > the normal wicket way.
> >
> > This makes it difficult to do things like display a link only if the
> > model is not null. For instance:
> >
> > add(new ExternalLink("web", new PropertyModel(service,"web")) {
> > @Override
> > public boolean isVisible() {
> > if (getModelObject() == null) {
> > return false;
> > }
> > return super.isVisible();
> > }
> > });
> >
> > The problem is that getModelObject() is always null, because the
> > PropertyModel is stored in the href property. And since isVisible()
> > is part of Component, the href property isn't accessible.
> >
> > Any suggestions for a simple solution?
> >
> > Thanks,
> > Tauren
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
>
> --
> Buy Wicket in Action: http://manning.com/dashorst
> Apache Wicket 1.3.0-beta3 is released
> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta3/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: ExternalLink doesn't use model?
Posted by Martijn Dashorst <ma...@gmail.com>.
Please add a feature request to the JIRA.
Martijn
On 9/26/07, Tauren Mills <ta...@tauren.com> wrote:
> I don't understand why ExternalLink doesn't store the external href as
> the model. It stores it in an href property. It seems to not follow
> the normal wicket way.
>
> This makes it difficult to do things like display a link only if the
> model is not null. For instance:
>
> add(new ExternalLink("web", new PropertyModel(service,"web")) {
> @Override
> public boolean isVisible() {
> if (getModelObject() == null) {
> return false;
> }
> return super.isVisible();
> }
> });
>
> The problem is that getModelObject() is always null, because the
> PropertyModel is stored in the href property. And since isVisible()
> is part of Component, the href property isn't accessible.
>
> Any suggestions for a simple solution?
>
> Thanks,
> Tauren
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.0-beta3 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta3/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org