You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by "Dennis M. J. Yerger" <de...@hotmail.com> on 2012/10/31 20:31:33 UTC

Creating Pages during Postbacks

Those of you who are familiar with Web applications know that a page is first requested with a HTTP GET request. If this page contains a form, the form is normally submitted back to the same address with a POST request. This type of request is called a postback. Postbacks usually result in redirects to a new page. But here's the problem. When a Click page is requested, it must construct its controls before processing the request. But if the request is a postback that results in a redirect, the controls on the original page are never rendered, which means they are created for nothing. So my question is this: is there a way to get around constructing controls during a postback since they will never be rendered?
 		 	   		   		 	   		  

Other Template Languages

Posted by "Dennis M. J. Yerger" <de...@hotmail.com>.
Click currently supports Velocity, JSP, and Freemarker as view templates. Of course, Velocity is the easiest to use. However, there are reasons to choose other template languages. For example, XSLT is a possible alternative. It may not be as simple as Velocity, but it has the advantage of being standards-compliant. This also means that you can use it with virtually any framework, even one not based on Java. You can keep the same view template and change the framework that powers it transparently. Any thoughts?
 		 	   		  

RE: Creating Pages during Postbacks

Posted by "Dennis M. J. Yerger" <de...@hotmail.com>.
Thank you, Bob. Your answer makes sense. I look forward to sharing more of my thoughts on Click in the future.

Date: Thu, 1 Nov 2012 07:42:56 +0200
Subject: Re: Creating Pages during Postbacks
From: sabob1@gmail.com
To: dev@click.apache.org

Hi Dennis,

In the postback he form and fields should be created in order to process and validate the values and persist data. I would assume that if the values were incorrect you would render the page again to show the error messages. Only when everything is correct would you redirect to another page.


But to answer your question you could put conditional code around constructing your controls with either:
http://click.apache.org/docs/click-api/org/apache/click/Context.html#isPost()


or if you want to know if a specific form was submitted you could create just that form and check:
http://click.apache.org/docs/click-api/org/apache/click/control/Form.html#isFormSubmission()


Hope this helps.

Kind regards

Bob


On Wed, Oct 31, 2012 at 9:31 PM, Dennis M. J. Yerger <de...@hotmail.com> wrote:





Those of you who are familiar with Web applications know that a page is first requested with a HTTP GET request. If this page contains a form, the form is normally submitted back to the same address with a POST request. This type of request is called a postback. Postbacks usually result in redirects to a new page. But here's the problem. When a Click page is requested, it must construct its controls before processing the request. But if the request is a postback that results in a redirect, the controls on the original page are never rendered, which means they are created for nothing. So my question is this: is there a way to get around constructing controls during a postback since they will never be rendered?

 		 	   		   		 	   		  

 		 	   		  

Re: Creating Pages during Postbacks

Posted by Bob Schellink <sa...@gmail.com>.
Hi Dennis,

In the postback he form and fields should be created in order to process
and validate the values and persist data. I would assume that if the values
were incorrect you would render the page again to show the error messages.
Only when everything is correct would you redirect to another page.

But to answer your question you could put conditional code around
constructing your controls with either:
http://click.apache.org/docs/click-api/org/apache/click/Context.html#isPost()

or if you want to know if a specific form was submitted you could create
just that form and check:
http://click.apache.org/docs/click-api/org/apache/click/control/Form.html#isFormSubmission()

Hope this helps.

Kind regards

Bob


On Wed, Oct 31, 2012 at 9:31 PM, Dennis M. J. Yerger <
dennisyerger84@hotmail.com> wrote:

>  Those of you who are familiar with Web applications know that a page is
> first requested with a HTTP GET request. If this page contains a form, the
> form is normally submitted back to the same address with a POST request.
> This type of request is called a postback. Postbacks usually result in
> redirects to a new page. But here's the problem. When a Click page is
> requested, it must construct its controls before processing the request.
> But if the request is a postback that results in a redirect, the controls
> on the original page are never rendered, which means they are created for
> nothing. So my question is this: is there a way to get around constructing
> controls during a postback since they will never be rendered?
>