1

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?

4

2 回答 2

2

有一个第三方扩展:https ://github.com/kev-m/isis-wicket-url/ 这是由我们的提交者之一 Kevin Meyer 完成的。

我提出了https://issues.apache.org/jira/browse/ISIS-1616以将其合并到“正确”的框架中。

同时,您可以添加一个动作来轻松打开链接

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

为了完成它,你可以添加这个守卫:

public String disableOpenLink() {
    if(getLink() == null) { return "no link to open."; }
    try {
        openLink();
    } catch(MalformedURLException ex) {
        return "Bad link";
    }
    return null;
}
于 2017-05-16T06:53:58.537 回答
1

我认为 Apache Isis 中没有现成的解决方案。您将需要为它滚动您自己的 Wicket 组件。例如,使用自定义注解对该属性进行注解@ExternalLink,然后注册一个为该属性ComponentFactory创建 WicketExternalLink组件的组件。参见https://github.com/isisaddons/isis-wicket-summernote/blob/master/cpt/src/main/java/META-INF/services/org.apache.isis.viewer.wicket.ui.ComponentFactory例如.

于 2017-05-15T23:28:32.480 回答