Adobe CQ EXTJS component data post to servlet

浪子不回头ぞ 提交于 2020-01-05 09:31:50

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/26373623/adobe-cq-extjs-component-data-post-to-servlet

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