Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added example code for graceful degredation

...

The renderer for each zone can be a block or component, or a Renderable or RenderCommand ... or an object, such as String, that can be coerced to either of these. Typically, you will inject a Block or Component and return that:

Code Block
java
java
  @Inject
  private Form registrationForm;

  @Inject Block registrationHelp;

  Object onActionFromRegister()
  {
    return new MultiZoneUpdate("userInput", registrationForm).add("helpPanel", registrationHelp);
  }

This implies that there are two zones, "userInput" and "helpPanel", somewhere in the rendered page, waiting to receive the updated content.

...

To support graceful degradation, you should detect that case in your event handler method and return a traditional response: a page, page name or page class. This is accomplished by injecting the Request object, and invoking the isXHR() method. This value will be true for Ajax requests, and false for traditional request.

Code Block
java
java

@Inject
private Request request;
...
Object onClickFromSomeLink()
{
    if(request.isXHR())
    {
       return zone.getBody(); // AJAX request, return zone body
    }
    else
    {
       return null; // non-AJAX request, redraw current page
    }
} 

Zone Effect Functions

A Zone may be initially visible or invisible. When a Zone is updated, it is made visible if not currently so. This is accomplished via a function on the Tapestry.ElementEffect client-side object. By default, the show() function is used for this purpose. If you want Tapestry to call a different Tapestry.ElementEffect function when updates occur, specify its name with the zone's show parameter.

...