How exactly does Tapestry mixin work?

旧时模样 提交于 2019-12-22 04:39:26

问题


I just realized after reading this article that I can not explain to myself how it works and what problems it can solve.

Yes, It could be used to change the behavior of existing component. But how it is limitated? What can I do, and what I can not do? Is it better than inheritance?

This article is helpful but I'm still confused a lot.

Can anyone explain Tapestry mixin using simple words?


回答1:


Tapestry Mixin is a limited version of component that should be attached to another component and can not have its own template. It has access to container parameters and can introduce its own. It is not better than inheritance. It is a different way to change components behaviour.

So, what you can do with mixins that can not be done with inheritance:

  • you can change behaviour of core tapestry components
  • you can use more than one mixin for one component

Some other words about mixinns:

  • they usually introduce some common logic that can be applied to all components, e.g. submit form on some client event or attach popup with help for some field
  • they can fix some problem with core components, e.g. we have mixin that fixes upload component when it is used in ajax form


来源:https://stackoverflow.com/questions/17564743/how-exactly-does-tapestry-mixin-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!