在 Tapestry 4 中扩展外部链接

发布于 2024-12-04 21:08:49 字数 157 浏览 5 评论 0原文

是否可以在 Tapestry 4 中扩展 ExternalLink?当我尝试时,似乎我的参数都没有被填充。我尝试在子类中显式地重新注释抽象,但这并不能解决诸如 getExternalService() 之类的问题。知道这个东西是如何实际初始化的吗?

Is it possible to extend ExternalLink in Tapestry 4? When I try, it seems as though none of my parameters are getting populated. I've tried explicitly re-annotating the abstracts in my subclass, but that doesn't take care of things like getExternalService(). Any insight into how this thing's actually initialized?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笔落惊风雨 2024-12-11 21:08:49

检查 Tapestry 源代码中的 ExternalLink.jwc 以了解该组件的配置方式。至于 getExternalService(),.jwc 说:

<inject property="externalService" object="engine-service:external"/>

因此,您可以使用这样的注释做同样的事情:

@InjectObject("engine-service:external")
public abstract IEngineService getExternalService();

看起来您应该能够扩展 ExternalLink,但是根据我的经验,T4 组件并不总是很容易子类化,并且该框架倾向于鼓励组合而不是继承。如果您遇到更多问题,也许用自定义组件包装 ExternalLink 会更容易?即创建一个仅包含单个链接组件的新组件?

Check ExternalLink.jwc from Tapestry's source to see how the component is configured. As for getExternalService(), the .jwc says:

<inject property="externalService" object="engine-service:external"/>

So you could do the same thing with an annotation like so:

@InjectObject("engine-service:external")
public abstract IEngineService getExternalService();

It looks like you should be able to extend ExternalLink, but in my experience T4 components are not always easy to subclass and the framework tends to encourage composition over inheritance. If you run into more problems, perhaps it would be easier to wrap an ExternalLink with your custom component instead? I.e. create a new component that only contains a single link component?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文