开发者

Extending ExternalLink in Tapestry 4

开发者 https://www.devze.com 2023-04-05 15:46 出处:网络
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 abstr开发者_Python百科acts in

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 abstr开发者_Python百科acts in my subclass, but that doesn't take care of things like getExternalService(). Any insight into how this thing's actually initialized?


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号