[
https://issues.apache.org/jira/browse/WICKET-1016?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12531383
]
Martin Funk commented on WICKET-1016:
-------------------------------------
Coming up with something else.
Your needs can be achieved like this:
public class ExternalLinkPage_1 extends WebPage
{
private static final long serialVersionUID = 1L;
private final String href = "http://wicket.apache.org";
/**
* Construct.
*/
public ExternalLinkPage_1()
{
add(new ExternalLink("myLink", new PropertyModel(this, "href"))
{
public boolean isVisible()
{
return
ExternalLinkPage_1.this.href.equals("http://wicket.apache.org");
}
});
}
}
Just wrap your href our label in to a PropertyModel, that way they are well
reachable from the outside of the ExternalLink.
When ExternalLink is used as an anonymous class href an label are well
reachable too, as shown above.
Other ways of using it, or even extending it, I don't quite see.
My guessing on why ExternalLink is implemented like that would be, that ists
the simplest possible way to do the job.
It is so minimal that a derived ExternalLink can't even get a glimpse on its
own internals from the inside, but it has to fall
back on the class were it was anonymously defined in. Verry minimalistic.
It's just not a real Wicket Link, it is external to the extend that the
application doesn't notice when the user clicks it.
I'd say, ask em to close this bug.
> ExternalLink doesn't use model
> ------------------------------
>
> Key: WICKET-1016
> URL: https://issues.apache.org/jira/browse/WICKET-1016
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Reporter: Tauren Mills
> Priority: Minor
> Attachments: ExternalLink.patch
>
>
> 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() {
> return getModelObject() != null;
> }
> });
> 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.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.