users@jersey.java.net

Re: [Jersey] Extending BookStore example to make books updateable

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 07 Oct 2009 10:35:56 +0200

Hi Frank,

If you want to mix implicit views and explicit resource methods you
need to annotate the resource class with @ImplicitProduces. For example:

   @ImplicitProduces("text/html;qs=5")

Otherwise you need to convert the implicit views into explicit
resource methods that return an instance of Viewable.

What version of the Bookstore are you modifying?

If you could zip up your Bookstore sample and send it to me i should
be able to modify it for you. But i will likely on have time to do
that next week.

Paul.

On Oct 6, 2009, at 5:25 PM, FSauer_at_dsthealthsolutions.com wrote:

>
> 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;
> }
> <mime-attachment.gif> 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.
>