ContextPageReset demo

Description
This page displays the @ContextPageReset annotation in a class.

Its purpose is to trigger the same behavior than a @PageReset, but base on the presence of a token as page context.

This functionality is disabled by default as it might create regressions (if your application contains page named "reset"). To enable it, add the ContextPageResetFilter to your Module class

By default, "reset" is the context token marker listened to trigger a method annotated with @ContextPageReset. This token can be overriden with a Symbol (see services documentation).

A method "void onActivate()" also have to be present in the page to trigger the reset with Tapestry 5.3.
  • Submit a value
  • Refresh the page on will, the value keeps persisted in the Page class
  • Refresh the page with "reset" context, the value gets deleted by method "resetPersist()" in the Page class
Notice the /reset appended to the URL, marker of a required reset.


In Action
Set a persistant value : Value to submit :

Value persisted :



Refresh page

Refresh page and reset




TML Source code

		<!-- form -->
		<t:form>
			<fieldset>
				<legend>Set a persistant value :</legend>
				Value to submit : <t:textfield value="value"/>
		        <t:submit/><br/><br/>
				Value persisted : ${value }
	        </fieldset>
		</t:form>
		<br/><hr/><br/>
		<t:pagelink page="components/contextpagereset/example1">Refresh page</t:pagelink><br/><br/>
		<t:pagelink page="components/contextpagereset/example1" context="literal:reset">Refresh page and reset</t:pagelink><br/><br/>
	



Java code

	Example1.java :
	
	public class Example1
	{
	    @Persist
	    @Property
	    private String value;
	
	    // required for Tapestry 5.3 compatibility
	    void onActivate()
	    {
	
	    }
	
	    @ContextPageReset
	    void resetPersist()
	    {
	        value = null;
	    }
	}
	
	
	AppModule :
	
	public void contributeComponentRequestHandler(OrderedConfiguration<ComponentRequestFilter> configuration)
    {
        configuration.addInstance("ContextPageResetFilter", ContextPageResetFilter.class);
    }