You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kaspar Fischer <fi...@inf.ethz.ch> on 2008/01/11 01:39:39 UTC

[T4] AJAX: reender whole page or just send back the markup of the div

Dear all,

I have a very basic question about AJAX in Tapestry 4.1.3: IIUC, the  
"updateComponents"
attribute provided by Tapestry components works by rendering the  
*whole* page,
extracting the relevant components (via their ids) and sending them  
back to the client.
I find this very elegant and it makes the pages easy to maintain.

For very complex pages, however, the above approach can result in  
some overhead.
I'd therefore like to just call a function that returns the  
replacement div (and
does not render the whole page).

Is there a simple example that shows how to do this?

For instance: Given a div and a link, clicking the link will replace  
the div via AJAX
without reloading the page.

Thanks,
Kaspar

P.S. I have started reading about EventListeners but am not sure  
whether this is
exactly what I need.

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


Re: [T4] AJAX: reender whole page or just send back the markup of the div

Posted by Kaspar Fischer <fi...@inf.ethz.ch>.
On 18.01.2008, at 13:51, Pai911 wrote:

> Why do you open the link in new window?
>
> The scenario should be:
> 1. You click on a link
> 2. The link invoke a listener (Asynchrounously) and update some  
> attribute of
> the Page class
> 3. Some part of the page is re-rendered asynchronously with the new  
> data.

Sorry, I was not clear. I understand this scenario and tried your  
code. It
works. Still, it seems that my whole page is rendered (and not just  
the component).
At least, "rendered" in the sense that my

   void pageBeginRender(PageEvent event)

listeners is exectued for my page (whether output is written I don't  
know).

I came up with opening the link in a new window because it seemed to  
suggest
that tapestry indeed renders the full page. But of course, if there  
is some
JavaScript magic behind it, it will ask a different URL from the server
when you click the link (instead of opening it in a new window, in which
case the full page is rendered).


> Did you try the code sample I wrote??

Yes. Again, sorry, for not confirming this right away.

> If you do, but the refresh of the whole page occures,
>  I think you may be using a certain old version of IE 6 cause I've  
> run into
> such situation.


No, it worked.

With your comments, I understand it this way:

a) When you click an AJAX link, JS asks the server to only render the  
compontent(s)
that need update (updateComponents). This will run through the whole  
page
building process and, in particular, trigger my pageBeginRender(),  
etc. listeners.
But output is (?) only written for the components that need updating.

b) However, when you open the AJAX link in a new window (that is,  
access the
link without the onClick-JS), a different request is sent to the  
server: it
just renders the full page.

More or less correct?

Kaspar

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


Re: [T4] AJAX: reender whole page or just send back the markup of the div

Posted by Pai911 <ja...@gmail.com>.
Why do you open the link in new window?

The scenario should be:
1. You click on a link
2. The link invoke a listener (Asynchrounously) and update some attribute of
the Page class
3. Some part of the page is re-rendered asynchronously with the new data.

Did you try the code sample I wrote??

If you do, but the refresh of the whole page occures,
 I think you may be using a certain old version of IE 6 cause I've run into
such situation.


hbf wrote:
> 
> 
> On 11.01.2008, at 05:02, Pai911 wrote:
> 
>>
>> Hi!
>> I don't think that Tapestry will render the whole page when a  
>> listener is in
>> invoked Asynchronously.
> 
> Hm, I think not: When I open the link in a new window, the whole page  
> shows.
> So I think the whole page is actually rendered, returned to the  
> client where
> the div(s) to update are extracted.
> 
> Could this be true?
> 
> Thanks,
> Kaspar
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-T4--AJAX%3A-reender-whole-page-or-just-send-back-the-markup-of-the-div-tp14747399p14949369.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: [T4] AJAX: reender whole page or just send back the markup of the div

Posted by Kaspar Fischer <fi...@inf.ethz.ch>.
On 11.01.2008, at 05:02, Pai911 wrote:

>
> Hi!
> I don't think that Tapestry will render the whole page when a  
> listener is in
> invoked Asynchronously.

Hm, I think not: When I open the link in a new window, the whole page  
shows.
So I think the whole page is actually rendered, returned to the  
client where
the div(s) to update are extracted.

Could this be true?

Thanks,
Kaspar


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


Re: [T4] AJAX: reender whole page or just send back the markup of the div

Posted by Pai911 <ja...@gmail.com>.
Hi!
I don't think that Tapestry will render the whole page when a listener is in
invoked Asynchronously.

When you intend to define a link or form for Async invocation, remember to
set the async attribute as "true"

for example:
#DIV TO DISPLAY CURRENT TIME#
&lt;span jwcid="timeBar@Insert" value="ognl:currentTime"/>


#LINK TO UPDATE CURRENT TIME PROPERTY#
&lt;a jwcid="@DirectLink" listener="listener:updateTime" async="true"
updateComponents="timeBar">
What time is it? 

#CORRESPONDING JAVA CODE#

public abstract Date getCurrentTime();

public abstract void setCurrentTime(Date time);

public void updateTime(){
    this.setCurrentTime(new Date());
}

I think Tapestry Ajax basically updates client side page by "component".

If you want to manipulate it by DOM element, you have to use EventListener
annotation 
with the "target" to specify the DOM element you want to update

Please correct me if there is anything wrong

Regards,

John

hbf wrote:
> 
> Dear all,
> 
> I have a very basic question about AJAX in Tapestry 4.1.3: IIUC, the  
> "updateComponents"
> attribute provided by Tapestry components works by rendering the  
> *whole* page,
> extracting the relevant components (via their ids) and sending them  
> back to the client.
> I find this very elegant and it makes the pages easy to maintain.
> 
> For very complex pages, however, the above approach can result in  
> some overhead.
> I'd therefore like to just call a function that returns the  
> replacement div (and
> does not render the whole page).
> 
> Is there a simple example that shows how to do this?
> 
> For instance: Given a div and a link, clicking the link will replace  
> the div via AJAX
> without reloading the page.
> 
> Thanks,
> Kaspar
> 
> P.S. I have started reading about EventListeners but am not sure  
> whether this is
> exactly what I need.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-T4--AJAX%3A-reender-whole-page-or-just-send-back-the-markup-of-the-div-tp14747399p14749380.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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