users@jersey.java.net

Extending BookStore example to make books updateable

From: <FSauer_at_dsthealthsolutions.com>
Date: Tue, 6 Oct 2009 10:25:52 -0500

I am trying to extend the bookstore example so that the Book jsp has a
form so the Books are editable.
I added an updateItem method to the BookStore like so, but after I do
that, the jsp for Book is no longer shown, get 405 'The specified HTTP
method is not allowed for the requested resource ().'
If I add @Get to getItem I get a 404 The requested resource () is not
available. I am missing something but I don't know what it is....
It works when I add '/update' at the end of the updateItem URI but I'm
trying to avoid that.
Also when I add '/update' to make it work, the method returns XML instead
of coming back with an implicit View for the item. How do I make that
work?

Any help would be appreciated,

Thanks,

Frank


    @Path("items/{itemid}")
    public Item getItem(@PathParam("itemid") String itemid) {
        Item i = getItems().get(itemid);
        if (i == null)
            throw new NotFoundException("Item, " + itemid + ", is not
found");

        return i;
    }

    @Path("items/{itemid}")
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    @POST
    public Item updateItem(
                @PathParam("itemid") String itemid,
                @FormParam("title") String title,
                @FormParam("author") String author) {
        Item i = getItems().get(itemid);
        if (i != null) {
                i.setTitle(title);
                i.setAuthor(author);
        }
        return i;
    }


Frank Sauer
Principal Architect
DST Health Solutions
2500 Corporate Drive
Birmingham, AL 35242
(205)437-5204 (Office) (Direct)
(205)568-4684 (Cell)
fsauer_at_dsthealthsolutions.com
It is impossible to sharpen a pencil with a blunt axe. It is equally vain
to try to do it with ten blunt axes instead -- Edsger W. Dijkstra


-----------------------------------------
Please consider the environment before printing this email and any
attachments.

This e-mail and any attachments are intended only for the
individual or company to which it is addressed and may contain
information which is privileged, confidential and prohibited from
disclosure or unauthorized use under applicable law. If you are
not the intended recipient of this e-mail, you are hereby notified
that any use, dissemination, or copying of this e-mail or the
information contained in this e-mail is strictly prohibited by the
sender. If you have received this transmission in error, please
return the material received to the sender and delete all copies
from your system.





picture
(image/gif attachment: 01-part)