[CONF] Apache Tapestry > Component Events

2011-01-09 Thread confluence







Component Events
Page edited by Bob Harner


Comment:
Lots of rewording, trying to simplify and organize this material for new users.  Not done yet, though.


 Changes (62)
 



h1. Component Events  
Component events are the means by which components are made aware of behaviors by the user, such as clicking links and submitting forms. 
*Component events* are Tapestry's way of conveying a user's interactions with the web page, such as clicking links and submitting forms, to designated methods in your page and component classes.  When a component event occurs, Tapestry calls the event handler method you've provided, if any, in the containing component's class. 
 
Component events are used for two purposes: 
Let's review a simple example. Here's a portion of the template for a page (let's call it "Chooser") that lets the user choose a number between 1 and 10: 
 
* They represent requests initiated by the user, triggered by links and forms in the client web browser. These are described more fully in [page navigation|#pagenav.html] and in [request processing|#request.html]. * They represent flow-of-control within a request, allowing one component to notify its container about some kind of circumstance ("a form was submitted"), or to collect some piece for data from the container. Often, a navigation request (originating with the user) will spawn a number of flow-of-control requests. For example, a Form component will be triggered by an action request, and will then send notification events to announce when the form submission is about to be processed, and whether it was succesful or not.  In Tapestry 4, you would configure a parameter of a component with the name of a method to invoke when a certain event occured, usually a request from the client.  This has some limitations, including the fact that only a single method could be invoked, and that it tied together a component and a method based on a method name, which required careful coordination between the template and the Java code.  Tapestry 5 introduces the concept of _event handler methods_, identified via a naming convention, or via the [OnEvent annotation|http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/annotations/OnEvent.html]. Event handler methods may have any visibility, even private. Normally they are given package private visibility, to support testing.  Rather than configure a component to invoke a particular method, you identify one or more methods to listen for events from that component. A single event handler method may receive notifications from many different components.  For example, here's a portion of a page (let's call it "Chooser") that lets the user choose a number between 1 and 10:  
{code:xml} 
 Choose a number from 1 to 10:  
 
 
 ${index} 
...
{code}  
The ActionLink component creates an action URL. 
Notice that Chooser.tml contains an ActionLink component. When rendered on the page, the ActionLink component creates an action URL, which in this case might look like {{http://localhost:8080/chooser.select/3}} 
 
The URL identifies the page that contains the component ("chooser"), the type of event (unless it is "action", the default and most common event type), the id of the component within the page ("select"), plus the additional context value(s). 
This URL identifies the page that contains the component ("chooser"), the type of event (unless it is "action", the default and most common event type), the id of the component within the page ("select"), plus the additional context value ("3"). _Additional context values, if any, are appended to the path._ 
 
A sample URL: {{http://localhost:8080/chooser.select/3}}. 
There's no direct mapping from URL to a piece of code. Instead, when the user clicks on the link, the ActionLink component emits events. And then Tapestry ensures that the correct bit of code (your event handler method, see below) gets invoked for those events. 
 
When there are additional context values, they are appended to the path. 
This demonstrates a critical difference between Tapestry and a more traditional, action oriented framework. The URL doesn't say what happens when the link is clicked, it identifies _which component is responsible_ when the link is clicked. 
 
This demonstrates a critical difference between Tapestry and a more traditional, action oriented framework. This URL doesn't say what happens when the link is clicked, it identifies _which component is responsible_ when the link is clicked. 
Ofte

[jira] Created: (TAP5-1410) Correction to regexp used for zip code validation in Tapestry 5 tutorial

2011-01-09 Thread Tony Ingraldi (JIRA)
Correction to regexp used for zip code validation in Tapestry 5 tutorial


 Key: TAP5-1410
 URL: https://issues.apache.org/jira/browse/TAP5-1410
 Project: Tapestry 5
  Issue Type: Improvement
  Components: documentation
Reporter: Tony Ingraldi
Priority: Minor


The regexp used for zip code validation in the Tapestry 5 tutorial 
(http://tapestry.apache.org/using-beaneditform-to-create-user-forms.html) is 
\\d{5}(-\\d{4})?

It should be ^\\d{5}(-\\d{4})?$ to get the desired behavior.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Commented: (TAP5-1408) datefield popup does not have option to cancel

2011-01-09 Thread Benny Law (JIRA)

[ 
https://issues.apache.org/jira/browse/TAP5-1408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12979415#action_12979415
 ] 

Benny Law commented on TAP5-1408:
-

Some of the users of my app are not very experienced with GUIs, and if we are 
having difficulty figuring out how to cancel a calendar popup, I'm sure it will 
be even harder for them. I still think the most intuitive way to cancel the 
popup is to click outside. That's what most users would try first. I don't 
think it is necessary to clutter the UI with another icon.

> datefield popup does not have option to cancel
> --
>
> Key: TAP5-1408
> URL: https://issues.apache.org/jira/browse/TAP5-1408
> Project: Tapestry 5
>  Issue Type: Bug
>Affects Versions: 5.2.4
>Reporter: Paul Stanton
>
> using the datefield component, if a user changes their mind there seems to be 
> no way for them to close the popup without changing the value in some way.
> once the icon has been clicked, there's no option to close the popup 
> explicitly and selecting the current value is disabled so the user has to 
> select another date to close the popup.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Commented: (TAP5-1408) datefield popup does not have option to cancel

2011-01-09 Thread Paul Stanton (JIRA)

[ 
https://issues.apache.org/jira/browse/TAP5-1408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12979412#action_12979412
 ] 

Paul Stanton commented on TAP5-1408:


ah, didn't notice that .. i tried clicking within the textfield its self, 
clicking outside, clicking the existing value cell ...

perhaps a close icon would be most intuitive for dumb users like myself.

> datefield popup does not have option to cancel
> --
>
> Key: TAP5-1408
> URL: https://issues.apache.org/jira/browse/TAP5-1408
> Project: Tapestry 5
>  Issue Type: Bug
>Affects Versions: 5.2.4
>Reporter: Paul Stanton
>
> using the datefield component, if a user changes their mind there seems to be 
> no way for them to close the popup without changing the value in some way.
> once the icon has been clicked, there's no option to close the popup 
> explicitly and selecting the current value is disabled so the user has to 
> select another date to close the popup.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Commented: (TAP5-1408) datefield popup does not have option to cancel

2011-01-09 Thread Benny Law (JIRA)

[ 
https://issues.apache.org/jira/browse/TAP5-1408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12979411#action_12979411
 ] 

Benny Law commented on TAP5-1408:
-

The popup can be cancelled by clicking the icon again. However, it would be 
nice if the popup could be cancelled by clicking outside it or pressing Esc 
which is normal behaviour for most dropdowns and popups.

> datefield popup does not have option to cancel
> --
>
> Key: TAP5-1408
> URL: https://issues.apache.org/jira/browse/TAP5-1408
> Project: Tapestry 5
>  Issue Type: Bug
>Affects Versions: 5.2.4
>Reporter: Paul Stanton
>
> using the datefield component, if a user changes their mind there seems to be 
> no way for them to close the popup without changing the value in some way.
> once the icon has been clicked, there's no option to close the popup 
> explicitly and selecting the current value is disabled so the user has to 
> select another date to close the popup.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Updated: (TAP5-1407) multizoneupdate should be easier to use - not a chain

2011-01-09 Thread Paul Stanton (JIRA)

 [ 
https://issues.apache.org/jira/browse/TAP5-1407?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul Stanton updated TAP5-1407:
---

Fix Version/s: (was: 5.2.4)

> multizoneupdate should be easier to use - not a chain
> -
>
> Key: TAP5-1407
> URL: https://issues.apache.org/jira/browse/TAP5-1407
> Project: Tapestry 5
>  Issue Type: Improvement
>  Components: tapestry-core
>Affects Versions: 5.2.4
>Reporter: Paul Stanton
>
> Currently MultiZoneUpdate is a chain of MultiZoneUpdates, ie
> public class MultiZoneUpdate
> {
> ...
> public MultiZoneUpdate add(String zoneId, Object renderer)
> {
> return new MultiZoneUpdate(zoneId, renderer, this);
> }
> ...
> }
> usage:
> MultiZoneUpdate mzu = new MultiZoneUpdate("zone2", zone1); // ugly!
> mzu = mzu.add("zone2", zone2); // ugly!
> mzu = mzu.add("zone3", zone3); // ugly!
> ...
> return mzu;
> This becomes hard to use when event handlers call common methods which 
> contribute zone updates.
> Also, it is possible to request multiple updates for the one zone which 
> doesn't make much sense.
> In some cases it would be much easier if you could construct a 
> MultiZoneUpdate object without actually contributing a zone update directive. 
> ie:
> MultiZoneUpdate mzu = new MultiZoneUpdate();
> mzu.add("zone2", zone1);
> mzu.add("zone2", zone2);
> mzu.add("zone3", zone3);
> mzu.add("zone3", zone3); // knocks out prev zone3 update
> ...
> return mzu;
> I have created a utility class which helps me work around this issue (and 
> issue #TAP5-1406), however note it relies on the dummy zone hack.:
> import java.util.HashMap;
> import java.util.Map.Entry;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.MarkupWriter;
> import org.apache.tapestry5.ajax.MultiZoneUpdate;
> import org.apache.tapestry5.internal.services.PageRenderQueue;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.PartialMarkupRenderer;
> import org.apache.tapestry5.services.PartialMarkupRendererFilter;
> import org.apache.tapestry5.services.javascript.JavaScriptSupport;
> public class XHRResponseHelper
> {
>   private HashMap zoneUpdates;
>   private boolean scriptAdded;
>   public XHRResponseHelper()
>   {
>   this.zoneUpdates = new HashMap();
>   scriptAdded = false;
>   }
>   public void addScriptCall(final String script, PageRenderQueue 
> pageRenderQueue, final JavaScriptSupport javascriptSupport)
>   {
>   scriptAdded = true;
>   pageRenderQueue.addPartialMarkupRendererFilter(new 
> PartialMarkupRendererFilter()
>   {
>   public void renderMarkup(MarkupWriter writer, 
> JSONObject reply, PartialMarkupRenderer renderer)
>   {
>   javascriptSupport.addScript(script);
>   renderer.renderMarkup(writer, reply);
>   }
>   });
>   }
>   public void addZoneUpdate(String zoneId, ComponentResources 
> componentResources)
>   {
>   addZoneUpdate(zoneId, 
> componentResources.getEmbeddedComponent(zoneId));
>   }
>   public void addZoneUpdate(String zoneId, Object renderer)
>   {
>   zoneUpdates.put(zoneId, renderer);
>   }
>   public MultiZoneUpdate buildMultiZoneUpdate(ComponentResources 
> componentResources)
>   {
>   // work around issue  - 
> https://issues.apache.org/jira/browse/TAP5-1406
>   if (zoneUpdates.isEmpty() && scriptAdded)
>   addZoneUpdate("dummyZone", componentResources);
>   MultiZoneUpdate mzu = null;
>   for (Entry entry : zoneUpdates.entrySet())
>   {
>   if (mzu == null)
>   mzu = new MultiZoneUpdate(entry.getKey(), 
> entry.getValue());
>   else
>   mzu = mzu.add(entry.getKey(), entry.getValue());
>   }
>   return mzu; // null if zoneUpdates is empty
>   }
> }
> usage:
> XHRResponseHelper response = new XHRResponseHelper();
> response.addZoneUpdate("myZone", componentResources);
> response.addZoneUpdate("myZone2", block);
> response.addScriptCall("alert('script');", pageRenderQueue, 
> javascriptSupport);
> return response.buildMultiZoneUpdate(componentResources);
> hope that helps.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Created: (TAP5-1409) datefield - cannot select same day in different month

2011-01-09 Thread Paul Stanton (JIRA)
datefield - cannot select same day in different month
-

 Key: TAP5-1409
 URL: https://issues.apache.org/jira/browse/TAP5-1409
 Project: Tapestry 5
  Issue Type: Bug
Affects Versions: 5.2.4
Reporter: Paul Stanton


say your date format is m/d/ and the initial value is 1/1/2011 and you want 
to change it to 2/1/2011.. that is not possible. changing month, the selected 
'day' is still selected and therefore not selectable.

use case:

initial date is 1/1/2011
1. open date picker
2. change month to feb
3. try to click on 1st of feb
- nothing happens. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[jira] Created: (TAP5-1408) datefield popup does not have option to cancel

2011-01-09 Thread Paul Stanton (JIRA)
datefield popup does not have option to cancel
--

 Key: TAP5-1408
 URL: https://issues.apache.org/jira/browse/TAP5-1408
 Project: Tapestry 5
  Issue Type: Bug
Affects Versions: 5.2.4
Reporter: Paul Stanton


using the datefield component, if a user changes their mind there seems to be 
no way for them to close the popup without changing the value in some way.

once the icon has been clicked, there's no option to close the popup explicitly 
and selecting the current value is disabled so the user has to select another 
date to close the popup.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



[CONF] Apache Tapestry > Configuration

2011-01-09 Thread confluence







Configuration
Page edited by Bob Harner


Comment:
Added tapestry.page-pool-enabled symbol


 Changes (9)
 



...
If "true", then the  tag that Tapestry normally writes into the , identifying the Tapestry version, will be omitted. Use this when you do not wish to advertise your application's use of Tapestry.  
h3. tapestry.production-mode  A flag (true or false) indicating whether the application is running in production or in development. The default is true, which means that runtime exceptions are not reported with full detail (only the root exception message is displayed, not the entire stack of exceptions, properties and other information shown in development mode).  
h3. tapestry.page-pool.active-window  
The time interval that an instantiated page instance may be cached before being removed. As pages are returned to the pool, they are time stamped. Periodically (as per the file check interval), the pool is scanned for page instances that have not been used recently; those that are outside the active window are discarded. This is used to free up unnecessary page instances after a request surge. 
_Starting in 5.2, this is only used if tapestry.page-pool-enabled is "true"._ 
 
The time interval that an instantiated page instance may be cached before being removed. As pages are returned to the pool, they are time stamped. Periodically (as per the file check interval), the pool is scanned for page instances that have not been used recently; those that are outside the active window are discarded. This is used to free up unnecessary page instances after a request surge.  Starting in 5.2, this is only effective if tapestry.page-pool-enabled is true.  
The default is "10 m" (10 minutes).  
h3. tapestry.page-pool-enabled  Starting with Tapestry 5.2, page pooling has been turned off by default. This symbol lets you re-enable page pooling.  Under most circumstances this symbol should not be set.  The disabling of page pooling starting in 5.2 significantly reduces heap memory usage and improves performance for most web applications.  The default is "false".  
h3. tapestry.page-pool.hard-limit  
_Starting in 5.2, this is only used if tapestry.page-pool-enabled is "true"._  
The absolute maximum number of page instances (for a particular page name / locale combination) that Tapestry will create at any time. If this number is reached, then requests will fail because a page instance is not available ... this can happen as part of a denial of service attack. For this value to have any meaning, it should be lower than the number of threads that the servlet container is configured to use when processing requests.  
...
h3. tapestry.page-pool.soft-limit  
_Starting in 5.2, this is only used if tapestry.page-pool-enabled is "true"._  
The number of pages in the page pool (for a given page name / locale combination) before which Tapestry will start to wait for existing pages to be made available. Under this limit of pages, Tapestry will simply create a new page instance if no existing instance is readily available. Once the soft limit is reached, Tapestry will wait a short period of time (the soft wait interval) to see if an existing page instance is made available. It will then create a new page instance (unless the hard limit has been reached).  
...
h3. tapestry.page-pool.soft-wait  
_Starting in 5.2, this is only used if tapestry.page-pool-enabled is "true"._  
The time interval that Tapestry will wait for a page instance to become available before deciding whether to create an entirely new page instance.  The default is "10 ms".  
h3. tapestry.production-mode  A flag (true or false) indicating whether the application is running in production or in development. The default is true, which means that runtime exceptions are not reported with full detail (only the root exception message is displayed, not the entire stack of exceptions, properties and other information shown in development mode).  
h3. tapestry.secure-enabled  
...

Full Content



1 Configuring Tapestry

1.1 Changes to web.xml
1.2 Tapestry Requests vs. Container Requests
1.3 Tapestry IoC Configuration
1.4 Configuration Symbols

2 Ignored Paths
3 Response Compression

3.1 Compression Configuration
3.2 StreamResponse




Related Articles


 
 Tapestry IoC Configuration



   

[jira] Commented: (TAP5-1374) Quickstart layout component uses deprecated IncludeStyleSheet annotation

2011-01-09 Thread JIRA

[ 
https://issues.apache.org/jira/browse/TAP5-1374?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12979279#action_12979279
 ] 

MichaƂ Minicki commented on TAP5-1374:
--

Should probably be changed to:

{code}
@Import(stylesheet="context:layout/layout.css")
{code}

> Quickstart layout component uses deprecated IncludeStyleSheet annotation
> 
>
> Key: TAP5-1374
> URL: https://issues.apache.org/jira/browse/TAP5-1374
> Project: Tapestry 5
>  Issue Type: Bug
>  Components: quickstart
>Affects Versions: 5.2.4
>Reporter: Javier Molina
>Priority: Minor
>


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.