cancel
Showing results for 
Search instead for 
Did you mean: 

POST data in template

nilsw
Champ in-the-making
Champ in-the-making
Stupid newbie question probably, but here it goes.

I have managed to AJAX load HTML into a dialog from a custom Share toolbar action with a GET request. But when I switch to POST (which I will need as I have to send a lot of data), I can no longer access the request parameters in the template.

The request looks like this:

Alfresco.util.Ajax.request(
{
   method: "POST",
   url: Alfresco.constants.PROXY_URI + "cadq/common/slingshot/doclib/action/order-form",
   dataObj:
   {
      printOrderRef: printOrderRef,
      printOrderFileName: printOrderFileName,
      htmlid: this.id
   },
   successCallback:
   {
      fn: this.onPrintOrderFormLoaded,
      scope: this
   },
   failureMessage: "Could not load Print Order Form template",
   execScripts: true
});

and the template

<div id="${args.htmlid}-dialog" class="details">
   <div id="${args.htmlid}-title" class="hd">Utskriftsbest&auml;llning</div>
   <div class="bd">
      <p>Best&auml;llningsfil: ${args.printOrderFileName}</p>
      <form id="${args.htmlid}-form" action="#" method="post">
         <div class="bdft">
            <input type="button" id="${args.htmlid}-ok" value="OK" tabindex="6" />
            <input type="button" id="${args.htmlid}-cancel" value="Avbryt" tabindex="7" />
            <input type="hidden" id="printOrderRef" value="${args.printOrderRef}" />
         </div>
      </form>
   </div>
</div>

when I run this I get

freemarker.core.InvalidReferenceException - Expression args.htmlid is undefined

So, how do I send and reference parameters with POST?
1 REPLY 1

nilsw
Champ in-the-making
Champ in-the-making
Answering myself, I have solved with a js controller. I changed the request to JSON and finally managed to extract the POST data with:

var jsonData = jsonUtils.toObject(requestbody.content);
model.htmlid = jsonData.htmlid;
model.printOrderRef = jsonData.printOrderRef;
model.printOrderFileName = jsonData.printOrderFileName;