[Catalyst] DELETE through REST and Jemplate

Alejandro Imass alejandro.imass at gmail.com
Mon Apr 13 06:08:11 GMT 2009


JRock's book needs a new edition very soon...

This will help you: The pre-workflow tag of p2ee Inventory app offers
a complete working very cool use of JQuery + Jemplate and the base
p2ee JS helper lib. you can browse the code here and rip out the stuff
you need:

http://p2ee.svn.sourceforge.net/viewvc/p2ee/inventory/tags/prewf/inventory/

I recommend you checkout the tag and get it running. All you need is
PostgreSql, and install the dependencies.

1) Create a database called p2ee
2) Create a Pg user called inventory password inventory
3) run the gen_db.sh script in data/model
4) Run dev server and Point browser to http://localhost:3000/w2app

You are set to go. The code there should illustrate clearly how to
integrate JQuery and Jemplate with an actual working app and a NEAT
RESTful api. The p2ee REST base controller will be published on CPAN
soon (next few days), but if anyone needs it there before just ask.

You can also check out the trunk because the w2app code is still there
but it's going away in the next few days when we finish the business
process resources. Then there will simply be no need for direct access
to Business Element resources directly with CRUD screen like the ones
you see in the tag. That was just a POC to demonstrate the concept of
Business Element Resources, but they are cool nonetheless ;-)

Best,
Alejandro Imass

On Tue, Mar 31, 2009 at 9:54 AM, Emmanuel Quevillon <tuco at pasteur.fr> wrote:
> Hi,
>
> I am playing with REST and Jemplate from the great Tuts from JRock's
> book.
> However, I am facing a problem. I understand well how to retrieve
> data from a REST url and playing Ajax with it, by a GET method.
> However, I don't know how to change the method to DELETE from a
> simple link like:
>
> test.js contains:
>
> function remove_item(id){
>  Jemplate.process('test.tt2',
>                  '[% Catalyst.uri_for("/rest/item/") %]'+id,
>                  '#_item');
> }
>
> template test.tt2:
>
> <a href="#" onclick="remove_item('[% item.id %]'); return
> false;">Remove item</a>
>
> If I code my template like this, it just do a GET request.
> How can I introduce DELETE method  to tell REST API to delete my
> item id?
>
> Sorry if my question seems stupid, I am a bit lost.
> If anybody has any clue, very welcome.
>
> Regards
> --
> -------------------------
> Emmanuel Quevillon
> Biological Software and Databases Group
> Institut Pasteur
> +33 1 44 38 95 98
> tuco at_ pasteur dot fr
> -------------------------
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>



More information about the Catalyst mailing list