Adobe CQ EXTJS组件数据发布到servlet [英] Adobe CQ EXTJS component data post to servlet

查看:175
本文介绍了Adobe CQ EXTJS组件数据发布到servlet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当点击保存按钮时,必须将对话框数据提交给自定义吊带servlet的。
自定义吊装servlet将调用osgi服务,最后使用jcr api将数据保存到crx。



问题:如何将对话数据发布到servlet? p>

我是新来的,感谢您的帮助!



-Sri

解决方案

我假设当你说保存你是指一些自定义按钮,而不是对按钮,将对话框数据保存到节点。 / p>

添加处理程序到保存按钮。处理函数必须检索对话框对象,循环遍历其中的所有字段,并将值发布到自定义servlet中。处理程序应该是这样的

  function(button,event){
// fetch dialog using the save button
var dialog = button.findParentByType('dialog');
var params = {}; //要发布的参数
var textfields = dialog.findByType('textfield'); //返回对话框中的所有文本框$​​ b $ b(i = 0; i< textfields.length; i ++){
params [textfields [i] .name] = textfields [i] .getValue(); //将值添加到params,其名称与您提供给textfield的名称相同
}
$ .post(servlet路径,params); //你也可以使用cq的ext js包的CQ.shared.HTTP来执行post
}

如果您想要做的是在默认情况下点击确定按钮发布表单数据,请设置 formurl 属性到您的自定义servlet的路径。在这种情况下,如果这些值不像对话框正常那样存储在相应节点上的适当名称的属性中,那么当组件被重新编辑时,该对话框将无法加载值。


I got a EXTJS CQ component with two text fields and and button.

When the "save" button clicked, the dialog data has to be submitted to custom sling servlet. Custom sling servlet will call a osgi service and finally saves data to crx using jcr api.

Question : How to post the dialog data to servlet ?

I am new to CQ, Thanks for any help!

-Sri

解决方案

I'm assuming when you say "save" you are referring to some custom button and not the "OK" button that saves the dialog data to the node.

Add a handler to the save button. The handler function must retrieve the dialog object, loop over all the fields in it and post the values to your custom servlet. The handler should be something like this

function(button,event){
//fetch dialog using  the save button
  var dialog = button.findParentByType('dialog');
  var params = {}; //parameters to post
  var textfields = dialog.findByType('textfield'); //returns all textfields in the dialog 
  for(i=0;i<textfields.length;i++){
      params[textfields[i].name] = textfields[i].getValue(); //add the value to params with name same as the name you have provided to the textfield
  }
  $.post( "path to your servlet" , params ); // you can also use CQ.shared.HTTP of cq's ext js package to do the post
}

In case all you want to do is post the form data on clicking the "OK" button that comes by default, set the formurl property of the dialog to the path of your custom servlet. In this case if the values aren't stored back as properties with appropriate names on the corresponding node like a dialog normally does, the dialog will not be able to load the values when the component is re-edited.

这篇关于Adobe CQ EXTJS组件数据发布到servlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆