我需要在 LifeRay portlet 中验证我的表单。经过一番研究,我了解到 LifeRay 有 2 种方法来验证表单:使用 Alloy UI taglibs 和使用 Alloy UI javascript 库。使用标签库是老方法(如果我错了,请纠正我)。
所以我想使用 Alloy UI Javascript 库进行验证。但我怎样才能将它包含到 portlet 中呢?据我了解,Alloy UI JS 库从 6.x 版本开始就与 LifeRay 捆绑在一起。可能我需要指定 <header-portlet-css>
和<header-portlet-javascript>
?因为 Alloy UI 似乎没有自动包含到每个 portlet 中。
最佳答案
这是一个示例。
在您的 portlet JSP 中插入具有正确 use 属性的 Alloyui 标签库,以便在上下文中包含 A.FormValidator
对象:
<aui:script use="aui-form-validator">
var validator = new A.FormValidator({
boundingBox: form,
rules: {
'<portlet:namespace />emailAddress': {
email: true
},
'<portlet:namespace />countryId': {
required: true
}
},
strings: {
required: '<liferay-ui:message key="this-field-is-required" />'
}
});
</aui:script>
关于java - 在 LifeRay portlet 中使用 Alloy UI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19539613/