在 Tapestry 4 中扩展外部链接
是否可以在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查 Tapestry 源代码中的
ExternalLink.jwc
以了解该组件的配置方式。至于getExternalService()
,.jwc 说:因此,您可以使用这样的注释做同样的事情:
看起来您应该能够扩展
ExternalLink
,但是根据我的经验,T4 组件并不总是很容易子类化,并且该框架倾向于鼓励组合而不是继承。如果您遇到更多问题,也许用自定义组件包装ExternalLink
会更容易?即创建一个仅包含单个链接组件的新组件?Check
ExternalLink.jwc
from Tapestry's source to see how the component is configured. As forgetExternalService()
, the .jwc says:So you could do the same thing with an annotation like so:
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 anExternalLink
with your custom component instead? I.e. create a new component that only contains a single link component?