You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Joost Schouten (ml)" <jo...@jsportal.com> on 2008/03/21 00:24:02 UTC

disable JSON response

Hi,

We are in the process of migrating from T5.0.5 to T5.0.11. In our app we 
choose to disable all of T's javascripts and and do all AJAX ourselves. 
However, Tapestry seems to be a bit too clever in this area and detects 
our prototype AJAX request, overwrites our 
@ContentType("application/xml") set on the page our AJAX script requests 
and returns a "application/JSON" response in stead.

Is there is simple trick to tell T not to set the contentType to 
"application/JSON" and not to add the "{content:....}"?

Thanks,
Joost

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: disable JSON response

Posted by Howard Lewis Ship <hl...@gmail.com>.
This may be handled under the ability to programatically render a
page, and outstanding issue I'm going to look into.

On Thu, Mar 20, 2008 at 5:43 PM, Joosts Mailing lists
<jo...@jsportal.com> wrote:
> On 3/21/08, Howard Lewis Ship <hl...@gmail.com> wrote:
>  >
>  > The content type is set as a consequence of what is returned from the
>  > event handler method.  What exactly are you returning?
>
>  When you return a block or a component, Tapestry will send a JSON
>  > response, with the "content" key set to the character stream derived
>  > from the partial render.
>  >
>  > You can still return a ContentStream type to take control over exactly
>  > what is sent to the client.
>  >
>  > Am I guessing correctly that part of your page is actually a block
>  > used to generate an XML response?
>
>
>  Not really, we are returning an actual page rendering our AJAX response.
>
>  Object getAjaxAwareReturnPage() {
>         if (isAjaxRequest()) {
>             return targetingAJAX;
>         } else {
>             return null;
>         }
>     }
>
>  This seemed like a good hijax approach. Refresh the whole page on no js,
>  return our updatable components in one page on js enabled.
>
>  I'm guessing T sees a page return as a component and thus transforms this
>  into a JSON response. I was hoping there is a way to tell tapestry not to
>  alter the response at all so that I have full control over what is returned.
>  In the current situation I'm not quite sure how to work with prototypes
>  response.responseXML because I can't get the page to be returned as
>  application/XML. Is my architecture wrong or is tapestry missing a
>  configuration option?
>
>  Thanks for you quick reply,
>  Joost
>
>
>
>  On Thu, Mar 20, 2008 at 4:24 PM, Joost Schouten (ml)
>  > <jo...@jsportal.com> wrote:
>  > > Hi,
>  > >
>  > >  We are in the process of migrating from T5.0.5 to T5.0.11. In our app
>  > we
>  > >  choose to disable all of T's javascripts and and do all AJAX ourselves.
>  > >  However, Tapestry seems to be a bit too clever in this area and detects
>  > >  our prototype AJAX request, overwrites our
>  > >  @ContentType("application/xml") set on the page our AJAX script
>  > requests
>  > >  and returns a "application/JSON" response in stead.
>  > >
>  > >  Is there is simple trick to tell T not to set the contentType to
>  > >  "application/JSON" and not to add the "{content:....}"?
>  > >
>  > >  Thanks,
>  > >  Joost
>  > >
>  >
>  > >  ---------------------------------------------------------------------
>  > >  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  > >  For additional commands, e-mail: users-help@tapestry.apache.org
>  > >
>  > >
>  >
>  >
>  >
>  >
>  > --
>  > Howard M. Lewis Ship
>  >
>  > Creator Apache Tapestry and Apache HiveMind
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  > For additional commands, e-mail: users-help@tapestry.apache.org
>  >
>  >
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: disable JSON response

Posted by Joosts Mailing lists <jo...@jsportal.com>.
On 3/21/08, Howard Lewis Ship <hl...@gmail.com> wrote:
>
> The content type is set as a consequence of what is returned from the
> event handler method.  What exactly are you returning?

When you return a block or a component, Tapestry will send a JSON
> response, with the "content" key set to the character stream derived
> from the partial render.
>
> You can still return a ContentStream type to take control over exactly
> what is sent to the client.
>
> Am I guessing correctly that part of your page is actually a block
> used to generate an XML response?


Not really, we are returning an actual page rendering our AJAX response.

Object getAjaxAwareReturnPage() {
        if (isAjaxRequest()) {
            return targetingAJAX;
        } else {
            return null;
        }
    }

This seemed like a good hijax approach. Refresh the whole page on no js,
return our updatable components in one page on js enabled.

I'm guessing T sees a page return as a component and thus transforms this
into a JSON response. I was hoping there is a way to tell tapestry not to
alter the response at all so that I have full control over what is returned.
In the current situation I'm not quite sure how to work with prototypes
response.responseXML because I can't get the page to be returned as
application/XML. Is my architecture wrong or is tapestry missing a
configuration option?

Thanks for you quick reply,
Joost

On Thu, Mar 20, 2008 at 4:24 PM, Joost Schouten (ml)
> <jo...@jsportal.com> wrote:
> > Hi,
> >
> >  We are in the process of migrating from T5.0.5 to T5.0.11. In our app
> we
> >  choose to disable all of T's javascripts and and do all AJAX ourselves.
> >  However, Tapestry seems to be a bit too clever in this area and detects
> >  our prototype AJAX request, overwrites our
> >  @ContentType("application/xml") set on the page our AJAX script
> requests
> >  and returns a "application/JSON" response in stead.
> >
> >  Is there is simple trick to tell T not to set the contentType to
> >  "application/JSON" and not to add the "{content:....}"?
> >
> >  Thanks,
> >  Joost
> >
>
> >  ---------------------------------------------------------------------
> >  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >  For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator Apache Tapestry and Apache HiveMind
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: disable JSON response

Posted by Howard Lewis Ship <hl...@gmail.com>.
The content type is set as a consequence of what is returned from the
event handler method.  What exactly are you returning?

When you return a block or a component, Tapestry will send a JSON
response, with the "content" key set to the character stream derived
from the partial render.

You can still return a ContentStream type to take control over exactly
what is sent to the client.

Am I guessing correctly that part of your page is actually a block
used to generate an XML response?

On Thu, Mar 20, 2008 at 4:24 PM, Joost Schouten (ml)
<jo...@jsportal.com> wrote:
> Hi,
>
>  We are in the process of migrating from T5.0.5 to T5.0.11. In our app we
>  choose to disable all of T's javascripts and and do all AJAX ourselves.
>  However, Tapestry seems to be a bit too clever in this area and detects
>  our prototype AJAX request, overwrites our
>  @ContentType("application/xml") set on the page our AJAX script requests
>  and returns a "application/JSON" response in stead.
>
>  Is there is simple trick to tell T not to set the contentType to
>  "application/JSON" and not to add the "{content:....}"?
>
>  Thanks,
>  Joost
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>  For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org