Zone Update with POST

2016-01-08 Thread Torsten Weber
Hello,

I am using an editor written in javascript. When someone clicks on "save"
data should be sent to Tapestry and a zone should be updated.

Currently in javascript I call:

zoneManager.deferredZoneUpdate(zoneId, zoneUrlWithContent).

zoneUrlWithContent contains the content of the editor as parameter and I
retrieve the content in  Tapestry with:

Object onSave(@RequestParameter(allowBlank=true, value="content") final
String content) { .. }



Now I want to send the content by POST because the size of URLs is limited
to 8192 characters.


Can you give me an example (JS and Tapestry event handler in Tapestry 5.4)?


Thanks in advance.
T.W.


Re: Zone Update with POST

2016-01-08 Thread Kalle Korhonen
For handling POST, I'd utilize Tynamo's tapestry-resteasy (
http://www.tynamo.org/tapestry-resteasy+guide/). JS could be something like
this:

$.ajax({
   url: 'http://my.server.com/editor/save',
   data: data,
   error: function() {
   },
   dataType: 'json',
   success: function(data) {
   },
   type: 'POST'});

JAX-WS EditorResourceImpl.java:

@Path("/editor")
public class EditorResourceImpl implements EditorResource {
@Path("/save")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@CommitAfter
public Map saveContents(EditorContents contents) {
...
}
}

Kalle


On Fri, Jan 8, 2016 at 4:25 AM, Torsten Weber 
wrote:

> Hello,
>
> I am using an editor written in javascript. When someone clicks on "save"
> data should be sent to Tapestry and a zone should be updated.
>
> Currently in javascript I call:
>
> zoneManager.deferredZoneUpdate(zoneId, zoneUrlWithContent).
>
> zoneUrlWithContent contains the content of the editor as parameter and I
> retrieve the content in  Tapestry with:
>
> Object onSave(@RequestParameter(allowBlank=true, value="content") final
> String content) { .. }
>
>
>
> Now I want to send the content by POST because the size of URLs is limited
> to 8192 characters.
>
>
> Can you give me an example (JS and Tapestry event handler in Tapestry 5.4)?
>
>
> Thanks in advance.
> T.W.
>