Re: ExternalLink doesn't use model?

2007-09-26 Thread Martijn Dashorst
Please add a feature request to the JIRA.

Martijn

On 9/26/07, Tauren Mills [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ExternalLink doesn't use model?

2007-09-26 Thread Tauren Mills
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 [EMAIL PROTECTED] wrote:
 Please add a feature request to the JIRA.

 Martijn

 On 9/26/07, Tauren Mills [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 


 --
 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: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ExternalLink doesn't use model?

2007-09-26 Thread Eelco Hillenius
 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ExternalLink doesn't use model?

2007-09-26 Thread Tauren Mills
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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ExternalLink doesn't use model?

2007-09-26 Thread Eelco Hillenius
Anonymous class would be fine if you just pick one of the constructors.

Eelco

On 9/26/07, Tauren Mills [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]