Tapestry5中的Mixins [英] Mixins in Tapestry5
问题描述
我是Tapestry5的新手,但是由于实习的缘故,我需要使用它.
I'm new to Tapestry5, but because of an internship I need to work with it.
目前,我正在尝试构建一个混合模块来集成CSRF令牌(在此处进行解释 )为任何形式.甚至有可能在mixin中实现这一目标吗?如果是,我可以从页面访问mixin提供的功能吗?
Currently I am trying to build a mixin to integrate a CSRF token (explanation here) to any form. Is it even possible to achieve this in a mixin? If yes, could I access functions that the mixin offers from the page?
我真的不确定mixins是如何工作的,并且在查找有关如何创建mixins的信息方面遇到很大的困难.有人可以解释如何创建一个mixin,甚至可以尝试做吗?
I am really not sure about how mixins really work and I'm having big difficulties on finding information about how to create one. Can somebody explain how to create a mixin and if what I'm trying to do is even possible?
非常感谢!
推荐答案
您可能会发现 HMAC 在挂毯5.3.6中引入的消息身份验证就足够了.配置此处吉拉
You might find that the HMAC message authentication introduced in tapestry 5.3.6 is good enough. Configuration here Jira here
如果没有,您很可能会编写一个Form mixin,它将一个隐藏的输入添加到表单中,然后检查 ComponentClassTransformWorker2 教程此处
If not, you will most likely write a Form mixin which adds a hidden input to a form and then checks for a RequestParameter in the form's onValidate
event (a mixin can see it's component's events). If you want to implicitly add a mixin to every form, you can do this via a ComponentClassTransformWorker2 tutorial here
A bit of googling reveals this, this and this.
这篇关于Tapestry5中的Mixins的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!