Hey, all-

I have a  project that was working correctly in Restlet 1.1.x, but I'm updating 
it to 2.1-M7, and having a problem with resources with multiple variants. On 
this project, I have been using the client's Accept header to determine which 
variant to return.

The old code for the resource looked like this (boiled down):

In constructor:
getVariants().add(new Variant(MediaType.TEXT_XML));
getVariants().add(new Variant(MediaType.APPLICATION_XHTML_XML));


@Override
public Representation represent(Variant variant) throws ResourceException {
    Representation result = null;
    if (variant.getMediaType().equals(MediaType.TEXT_XML)) {
        result = getXMLTemplateRepresentation();
    } else {
        result = getHTMLTemplateRepresentation();
    }
    return result;
}

In the new code, I have tried a number of different things. As it stands right 
now:

In constructor:
setNegotiated(true);
getVariants().add(new Variant(MediaType.TEXT_XML));
getVariants().add(new Variant(MediaType.APPLICATION_XHTML));

@Get("xml")
public Representation toXml() throws ResourceException {
    return getXMLTemplateRepresentation();
}

@Get("xhtml")
public Representation toXhtml() throws ResourceException {
    return getXHTMLTemplateRepresentation();
}

Requesting either of these variants gives me a 405 ("Method Not Allowed") 
error. Other resources (withonly a single variant) are working correctly (with 
setNegotiated(false) in their constructors.) There's almost certainly something 
I'm overlooking. Does anyone have any suggestions?

Thanks!

--------------------------
John Wismar
Alldata Technology
916-478-3296

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2837581

Reply via email to