Apache ISIS external link

251 Views Asked by At

Let's say I have a domain object Customer. On this object I have an address to an external site.

@PropertyLayout(named = "Link", describedAs = "Clickable link to customer")
public String getLink() {
    return "http://www.customer.com";
}

In this case this will be shown as just text on the webpage. How do I create a clickable link in the wicket viewer from this?

2

There are 2 best solutions below

0
On BEST ANSWER

There is a third-party extension: https://github.com/kev-m/isis-wicket-url/ This was done by Kevin Meyer, one of our committers.

I've raised https://issues.apache.org/jira/browse/ISIS-1616 to incorporate this into the framework "proper".

Meantime, you can add an action to open the link easily enough

@Action(semantics=SemanticsOf.SAFE)
@MemberOrder(named="link", sequence="1")
public java.net.URL openLink() throws MalformedURLException {
    return new java.net.URL(getLink());
}

and just to finish it off, you could add this guard:

public String disableOpenLink() {
    if(getLink() == null) { return "no link to open."; }
    try {
        openLink();
    } catch(MalformedURLException ex) {
        return "Bad link";
    }
    return null;
}
0
On

I don't think there is out of the box solution in Apache Isis for this. You will need to roll your own Wicket component for it. For example, annotate this property with custom annotation @ExternalLink and then register a ComponentFactory that creates Wicket ExternalLink component for this property. See https://github.com/isisaddons/isis-wicket-summernote/blob/master/cpt/src/main/java/META-INF/services/org.apache.isis.viewer.wicket.ui.ComponentFactory for example.