Finally found a way to achieve this : just add support for StreamPageContent 
handling in the ComponentEventResultProcessor (in my module) :


@Contribute(ComponentEventResultProcessor.class) @Ajax
public static void provideStreamPageContentAjaxComponentEventResultProcessor(
            MappedConfiguration<Class, ComponentEventResultProcessor> 
configuration) {
        configuration.addInstance(StreamPageContent.class, 
StreamPageContentResultProcessor.class);
}

Now, I can do this :

@OnEvent(MY_EVENT)
Object onFetchGridContent(){
        return new StreamPageContent(GridContent.class, contentContext);
}

and provide the event URI to the js component.

RFE :  Couldn't this be done by default in TapestryModule?

Regards

Guillaume

Le 12 déc. 2011 à 18:59, Guillaume Bodet a écrit :

> Actually, the browser expects a raw XML response.
> If I return a page class or instance from the event handler, the XML content 
> gets wrapped into a JSON object (which cannot be interpreted by the client).
> I hoped the StreamPageContent would return the row page content (I use an XML 
> tml to build the page). But it seams that the event handler (server side) 
> doesn't know how to deal with the StreamPageResponse…
> 
> Regards
> 
> Guillaume
> 
> Le 12 déc. 2011 à 16:17, Howard Lewis Ship a écrit :
> 
>> On Mon, Dec 12, 2011 at 1:37 AM, Guillaume Bodet
>> <gbo...@financeactive.com> wrote:
>>> The event handler method throws an exception :
>>> A component event handler method returned the value 
>>> org.apache.tapestry5.services.StreamPageContent@5f00498c. Return type 
>>> org.apache.tapestry5.services.StreamPageContent can not be handled.
>>> 
>>> I believe this is related to the fact that the request is an XHR request, 
>>> and the ajax component event handler doesn't kno how to handle the 
>>> streampagecontent… any idea?
>> 
>> Because the browser is expecting a JSON response, and not a stream of HTML?
>> 
>> From an XHR request, you can return a page class or page instance and
>> it will, I believe, encode a JSON response to redirect to the page.
>> 
>>> 
>>> Regards
>>> 
>>> Guillaume
>>> 
>>> 
>>> Le 10 déc. 2011 à 06:09, Howard Lewis Ship a écrit :
>>> 
>>>> See 
>>>> http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/StreamPageContent.html
>>>> 
>>>> On Wed, Dec 7, 2011 at 2:17 AM, Guillaume Bodet
>>>> <gbo...@financeactive.com> wrote:
>>>>> Hi,
>>>>> 
>>>>> I'm using a nice js component called DHTMLX Grid in my T5 application.
>>>>> DhtmlxGrid fetched its data in an ajax request. Data is formatted as XML :
>>>>> <rows>
>>>>>       <head>
>>>>>               <column>…</column>
>>>>>       </head>
>>>>>       <row>
>>>>>               <cell>…</cell>
>>>>>       </row>
>>>>> </rows>
>>>>> 
>>>>> It is very convenient to use a tapestry page to dynamically create this 
>>>>> file.
>>>>> 
>>>>> Right now, I'm providing the grid a page render link to the xml page to 
>>>>> fetch its data. It works great but requires extra effort to share state 
>>>>> between the containing page and the data page.
>>>>> 
>>>>> What I would like to do is providing the data through an event link in 
>>>>> the main page.
>>>>> 
>>>>> Here is what the code could look like :
>>>>> 
>>>>> @InjectPage
>>>>> private XMLDataPage dataPage;
>>>>> 
>>>>> @OnEvent("loadGrid")
>>>>> StreamResponse provideGridData(){
>>>>>       dataPage.setState(state);
>>>>>       String result = pageRenderer.renderPageToString(dataPage);
>>>>>       return new XMLStreamResponse(result);
>>>>> }
>>>>> 
>>>>> Is it feasible ?
>>>>> 
>>>>> Regards
>>>>> 
>>>>> Guillaume
>>>>> 
>>>>> 
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>>> 
>>>> 
>>>> 
>>>> 
>>>> --
>>>> Howard M. Lewis Ship
>>>> 
>>>> Creator of Apache Tapestry
>>>> 
>>>> The source for Tapestry training, mentoring and support. Contact me to
>>>> learn how I can get you up and productive in Tapestry fast!
>>>> 
>>>> (971) 678-5210
>>>> http://howardlewisship.com
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>> 
>> 
>> 
>> 
>> -- 
>> Howard M. Lewis Ship
>> 
>> Creator of Apache Tapestry
>> 
>> The source for Tapestry training, mentoring and support. Contact me to
>> learn how I can get you up and productive in Tapestry fast!
>> 
>> (971) 678-5210
>> http://howardlewisship.com
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 


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

Reply via email to