You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by membersound <me...@web.de> on 2012/10/29 15:54:18 UTC

Why is ajaxRenderer needed for zone update?

Why do I need a ajaxResponseRenderer within my backing class, when I want to
update a zone?
Eg: having a table with all users, and when clicking a user I want to update
another table which shows the address of the selected user. Now I have to:
-create a zone with the address table grid, and place it into a zone
-trigger that zone from an eventlink or pagelink within the main table
-make ajaxResponseRenderer for that eventlink in the backing class.

Question: Why do I need this ajax response in backing? Because I'm already
updating the user object by user.id that is given in context on eventLink
click. So why is it no sufficient to just update the zone from the tml
frontend?


<p:usernameCell><t:eventLink event="selectUsername" context="user.id"
zone="userprofile">${user.username}</t:eventLink></p:usernameCell>

	<t:zone id="userprofile">
             <t:if test="selectUsername">
             	<t:grid source="user.address">
             	</t:grid>
             </t:if>
	</t:zone>


class UserPage{
	@Property
	boolean isSelectUsername;

	User user;

	void onSelectUsername(Long id) {
		isSelectUsername = true;
		user = dao.find(id);
		ajaxResponseRenderer.addRender("userprofile", userprofile);
	}	
}





--
View this message in context: http://tapestry.1045711.n5.nabble.com/Why-is-ajaxRenderer-needed-for-zone-update-tp5717391.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: Why is ajaxRenderer needed for zone update?

Posted by Dragan Sahpaski <dr...@gmail.com>.
On Mon, Oct 29, 2012 at 3:54 PM, membersound <me...@web.de> wrote:
> Why do I need a ajaxResponseRenderer within my backing class, when I want to
> update a zone?
> Eg: having a table with all users, and when clicking a user I want to update
> another table which shows the address of the selected user. Now I have to:
> -create a zone with the address table grid, and place it into a zone
> -trigger that zone from an eventlink or pagelink within the main table
> -make ajaxResponseRenderer for that eventlink in the backing class.
>
> Question: Why do I need this ajax response in backing? Because I'm already
> updating the user object by user.id that is given in context on eventLink
> click. So why is it no sufficient to just update the zone from the tml
> frontend?

Because you have to specify with what content are you updating the zone.
This is expressed with tapestry blocks. So you are saying that you are
updating your zone with it's own body (which is a pretty common use
case).

>
>
> <p:usernameCell><t:eventLink event="selectUsername" context="user.id"
> zone="userprofile">${user.username}</t:eventLink></p:usernameCell>
>
>         <t:zone id="userprofile">
>              <t:if test="selectUsername">
>                 <t:grid source="user.address">
>                 </t:grid>
>              </t:if>
>         </t:zone>
>
>
> class UserPage{
>         @Property
>         boolean isSelectUsername;
>
>         User user;
>
>         void onSelectUsername(Long id) {
>                 isSelectUsername = true;
>                 user = dao.find(id);
>                 ajaxResponseRenderer.addRender("userprofile", userprofile);
>         }
> }

There is an alternative:
Block onSelectUsername(Long id) {
                 isSelectUsername = true;
                 user = dao.find(id);
                return userprofile.getBody();
      }
This is easier when updateing only one zone, but ajaxResponseRenderer
really comes in use when you are updating multiple zones.



>
>
>
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Why-is-ajaxRenderer-needed-for-zone-update-tp5717391.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
>

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