openlaszlo simple post code

Here’s a little form for sending an XML post in OpenLaszlo. This is a useful little snippet of code, since as if you get one little content header or something wrong, Rails will be unforgiving with its powerful, yet strict implementation of REST.

What the app looks like (enter text in the top, click the button, response is printed in the lower box):

The code:

<canvas title="Test Post" proxied="false">
  <dataset src="http:/projects.xml" name="ds"
    ondata="response.setAttribute('text'this.childNodes[0].serialize())"/>
  <simplelayout spacing="4"/>
  <edittext id="postdata" multiline="true" width="400" height="200"
     text='&lt;project&gt; &lt;title&gt;XXX&lt;/title&gt; &lt;/project&gt;'/>
  <button text="post">
    <handler name="onclick">
    ds.setQueryParam("lzpostbody", postdata.text);
    ds.setAttribute("querytype", "POST");
    ds.setHeader("Content-Type", "application/xml")
    ds.doRequest();
  </handler>
  </button>
  <edittext id="response" multiline="true" width="400" height="280"/>
</canvas>

This entry was posted in code. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*