You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Torsten Weber <to...@gmail.com> on 2016/01/08 13:25:56 UTC

Zone Update with POST

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

Posted by Kalle Korhonen <ka...@gmail.com>.
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<String, String> saveContents(EditorContents contents) {
        ...
    }
}

Kalle


On Fri, Jan 8, 2016 at 4:25 AM, Torsten Weber <to...@gmail.com>
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.
>