实际上,我正在使用“提交前”侦听器对我的选择框进行一些验证,我提供了以下链接:https://helpx.adobe.com/experience-manager/using/classic_dialog_validation.html。
但是“提交前”方法只在我放的时候调用,对话监听器只在对话根级别调用。
如何在对话框根级别放置对话监听器(我在我的项目中检查没有dialog.xml文件,他们只使用java代码来构造组件对话框)。
有人能在这方面帮我吗?enter image description here
对话框属性构造代码:
@DialogField(name ="./validateProgram",
fieldLabel =“验证程序”,
fieldDescription = "(synchronized)",
additionalProperties = {
@Property(renderIn = Property.RenderValue.TOUCH,
name = "validation",
value = "validation-program")
},
listeners = {
@Listener(name ="beforesubmit",
value = "function(dialog){" +
"return programValidation.beforeSubmit(dialog);"+
"}")
})
@Selection(
type ="select",
optionsProvider = " ",
dataSource = "/resourcetype/data")
public final String validateProgram;Java脚本代码:
window.onload =函数(){
programValidation.init();};
var函数程序验证||( programValidation= ($){
function initialize() {
};
function validate() {
alert("inside validate method");
var res = true;
return res;
};
return {
beforeSubmit: validate,
init: initialize
}})(jQuery);
发布于 2017-08-30 12:45:04
您正在使用cq component maven plugin这是一条非常重要的信息来回答您的问题。
我以前没有使用过这个插件,但在您的示例中,我假设您正在寻找Listener注释,您可以在其中将名称设置为beforesubmit,将值设置为function(){alert(1)}
您可能必须在局部变量上设置注释,类似于注释对话框字段'@DialogField‘的方式,在插件的用法页面中可以找到更多文档:http://code.digitalatolson.com/cq-component-maven-plugin/usage.html
希望这能有所帮助。
发布于 2017-09-05 18:35:51
多谢你们的支持。找到以下方法来解决此问题。
我从两个侦听器(FIELD_LISTENER_LOAD_CONTENT和FIELD_LISTENER_SELECTION_CHANGED)中添加了ValidateFields方法
function ValidateFields(dialog) {
dialog.on("beforesubmit", function(e) {
if(<condtion failed>)
CQ.Ext.Msg.alert(CQ.I18n.getMessage("Error"), CQ.I18n.getMessage("<error message>"));
return false;
} else {
return true;
}
}, this);
}https://stackoverflow.com/questions/45932351
复制相似问题