On Tue, Dec 15, 2009 at 1:17 PM, Simon Gaeremynck <[email protected]> wrote:
> I have to write a batchpost mechanism that allows our UI guys to do a single
> POST to our servlet with a set of endpoints and data for it.
> Imagine something like:
>
> [
> {url: /foo/a, data: {a: 1, b: 2}},
> {url: /foo/b, data: {alfa: 1, test: 2}},
> {url: /foo/c, data: {name: "Simon", b: 2}},
> ]

> Is there an easier way of doing this kind of behavior or is this strongly
> discouraged?

If I understand correctly, you want to mainpulate several nodes in a
single request?
The data you have listed above can be posted with an HTML form like this:
<form method="post" action="/">
  <input type="text" name="/foo/a/a" value="1" />
  <input type="text" name="/foo/a/b" value="2" />
  <input type="text" name="/foo/b/alfa" value="1" />
  <input type="text" name="/foo/b/test" value="2" />
  <input type="text" name="/foo/c/name" value="Simon" />
  <input type="text" name="/foo/c/b" value="2" />
  <button type="submit">Submit</button>
</form>

Notice how the "name" attribute of the input elements are in fact
paths to properties.

Submitting that form to the SlingPostServlet should result in these nodes:
/foo/a, with properties a=1 and b=2
/foo/b, with properties alfa=1 and test=2
/foo/c, with properties name=Simon and b=2

-- 
Vidar S. Ramdal <[email protected]> - http://www.idium.no
Sommerrogata 13-15, N-0255 Oslo, Norway
+ 47 22 00 84 00 / +47 21 531941, ext 2070

Reply via email to