You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Alp Çevik <at...@gmail.com> on 2008/01/20 00:10:45 UTC

Ajax related trouble

Hello all,

I am a newbie trying to develop some app using Tapestry. I currently am
having some trouble using the ajax functionality.

The thing is, I am trying to use some 3rd party flash charting component
(Fusion charts v2) which I would like to update when data changes. The data
is also changed by the application which contains the charts.
1- I have to make some javascript function calls to update the chart
2- the chart should be updated after new data is sent to the server and
processed

I am using Directlink and update components to process the changed data on
the server, which works smoothly. The trouble is, I need to find some way to
trigger the function to update the charts after the directlink listener does
its job.

- thought of implementing a servlet for using ajax calls within tapestry,
but as the objects tend to change, it costs a lot to overcome the
synchronization issue with tapestry & the servlet
- I have tried updateing components for the part that runs the javascript,
receiving the javascript function call as new content with ajax, which
resulted in nonworking code in IE.
- tried using contrib Xtile component, noticing that I have to be calling
the listener with this component also and handle all the ajax related stuff
which current direct link is doing
- tried using event handler annotations, which did not work as the
javascript method that starts the process on eventhandler has no relations
to the directlink listener.
- tried getting the responsebuilder and outputting the script as an
initialization script, using write..script, during which I tried to obtain
some reference to the MarkupWriter hopelessly, then tried
addinitializationscript and got a nullpointer exception that I could not
figure out, though I could get the component and stuff on debugger.

Thank you in advance,

Alp

Re: Ajax related trouble

Posted by Alp Çevik <at...@gmail.com>.
Hi Andreas,

I am using 4.1.3.

The problem I am experiencing with the responsebuilder methods is I cannot
retrieve the MarkupWriter, getWriter within the responsebuilder returns
null. Thought it was something related to the lifecycle of tapestry
rendering and stuff. I didnt get into internals so I gave up trying to get a
handle. I dont know if initialization of a new MArkupwriter should do the
trick, if it does, then there is this problem of acquiring the printwriter,
where do I get it? a new instance is ok there too? (Maybe I should work on
the internals more before asking these questions, these may sound real
silly, but i do hope that I dont need to get all the details of the tapestry
engine in order to trigger some client side function.)

I guess I will be working on 4.1.4 as you suggested, as I also do want the
features of dojo 1.0.

About the documentation, it would be great to include some details about
calling a client side script, which is tough to find out, as I have been
looking into the matter for several hours now but was unable to get the
results yet. I also own the tapestry in action book but still it is tough to
find answers.

Thank you,
Alp



On Jan 20, 2008 3:26 AM, Andreas Andreou <an...@gmail.com> wrote:

> Which Tapestry version is this with?
>
> I think there was a change in 4.1.4-SNAPSHOT that handles the
> nullpointer exception
> when using addinitializationscript.
>
> On the other hand, let me propose another solution that (I think)
> better works in your case
>
> ResponseBuilder.addStatusMessage(IMarkupWriter writer, String
> category, String text)
> - you can get the responseBuilder from the currect IRequestCycle -.
>
> When the ajax response arrives, tapestry will 'publish' the text using
> the given category, i.e.
> it will execute for you: dojo.event.topic.publish('myCategoy','myText')
>
> So, if you're subscribed to that topic, your custom js functions can
> be notified, i.e.
> dojo.event.topic.subscribe('myCategory', function(msg) { alert(msg);
> /* do custom processing here */ } );
>
> I'll raise a documentation issue for this - i think i missed explaining
> it.
>
>
>
>
> On Jan 20, 2008 1:10 AM, Alp Çevik <at...@gmail.com> wrote:
> > Hello all,
> >
> > I am a newbie trying to develop some app using Tapestry. I currently am
> > having some trouble using the ajax functionality.
> >
> > The thing is, I am trying to use some 3rd party flash charting component
> > (Fusion charts v2) which I would like to update when data changes. The
> data
> > is also changed by the application which contains the charts.
> > 1- I have to make some javascript function calls to update the chart
> > 2- the chart should be updated after new data is sent to the server and
> > processed
> >
> > I am using Directlink and update components to process the changed data
> on
> > the server, which works smoothly. The trouble is, I need to find some
> way to
> > trigger the function to update the charts after the directlink listener
> does
> > its job.
> >
> > - thought of implementing a servlet for using ajax calls within
> tapestry,
> > but as the objects tend to change, it costs a lot to overcome the
> > synchronization issue with tapestry & the servlet
> > - I have tried updateing components for the part that runs the
> javascript,
> > receiving the javascript function call as new content with ajax, which
> > resulted in nonworking code in IE.
> > - tried using contrib Xtile component, noticing that I have to be
> calling
> > the listener with this component also and handle all the ajax related
> stuff
> > which current direct link is doing
> > - tried using event handler annotations, which did not work as the
> > javascript method that starts the process on eventhandler has no
> relations
> > to the directlink listener.
> > - tried getting the responsebuilder and outputting the script as an
> > initialization script, using write..script, during which I tried to
> obtain
> > some reference to the MarkupWriter hopelessly, then tried
> > addinitializationscript and got a nullpointer exception that I could not
> > figure out, though I could get the component and stuff on debugger.
> >
> > Thank you in advance,
> >
> > Alp
> >
>
>
>
> --
> Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
> Tapestry / Tacos developer
> Open Source / JEE Consulting
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Ajax related trouble

Posted by Andreas Andreou <an...@gmail.com>.
Which Tapestry version is this with?

I think there was a change in 4.1.4-SNAPSHOT that handles the
nullpointer exception
when using addinitializationscript.

On the other hand, let me propose another solution that (I think)
better works in your case

ResponseBuilder.addStatusMessage(IMarkupWriter writer, String
category, String text)
- you can get the responseBuilder from the currect IRequestCycle -.

When the ajax response arrives, tapestry will 'publish' the text using
the given category, i.e.
it will execute for you: dojo.event.topic.publish('myCategoy','myText')

So, if you're subscribed to that topic, your custom js functions can
be notified, i.e.
dojo.event.topic.subscribe('myCategory', function(msg) { alert(msg);
/* do custom processing here */ } );

I'll raise a documentation issue for this - i think i missed explaining it.




On Jan 20, 2008 1:10 AM, Alp Çevik <at...@gmail.com> wrote:
> Hello all,
>
> I am a newbie trying to develop some app using Tapestry. I currently am
> having some trouble using the ajax functionality.
>
> The thing is, I am trying to use some 3rd party flash charting component
> (Fusion charts v2) which I would like to update when data changes. The data
> is also changed by the application which contains the charts.
> 1- I have to make some javascript function calls to update the chart
> 2- the chart should be updated after new data is sent to the server and
> processed
>
> I am using Directlink and update components to process the changed data on
> the server, which works smoothly. The trouble is, I need to find some way to
> trigger the function to update the charts after the directlink listener does
> its job.
>
> - thought of implementing a servlet for using ajax calls within tapestry,
> but as the objects tend to change, it costs a lot to overcome the
> synchronization issue with tapestry & the servlet
> - I have tried updateing components for the part that runs the javascript,
> receiving the javascript function call as new content with ajax, which
> resulted in nonworking code in IE.
> - tried using contrib Xtile component, noticing that I have to be calling
> the listener with this component also and handle all the ajax related stuff
> which current direct link is doing
> - tried using event handler annotations, which did not work as the
> javascript method that starts the process on eventhandler has no relations
> to the directlink listener.
> - tried getting the responsebuilder and outputting the script as an
> initialization script, using write..script, during which I tried to obtain
> some reference to the MarkupWriter hopelessly, then tried
> addinitializationscript and got a nullpointer exception that I could not
> figure out, though I could get the component and stuff on debugger.
>
> Thank you in advance,
>
> Alp
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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