You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Lenny Primak <lp...@hope.nyc.ny.us> on 2011/10/27 08:21:57 UTC

Safari (for example) browser history and form exception

Safari has a friendly (overly friendly) URL completion, and it picks up Tapestry forms,
which gives an ugly exception:

For example for when I start typing pallet, the url URL https://www.XXX.com/stage/test/palletpage.srch.searchform comes
up from the previous history.
An unexpected application exception has occurred.

Forms require that the request method be POST and that the t:formdata query parameter have values.


Is there any way to prevent this or make an exception friendlier?
For example, I am pretty sure that GET method is never valid on a form,
so this should redirect to the actual page.

What do you guys think?


Re: Safari (for example) browser history and form exception

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 28 Mar 2012 13:56:28 -0300, Lenny Primak <lp...@hope.nyc.ny.us>  
wrote:

> 2) The problem occurs in all browsers that have address bar 'smart'  
> completion. It is too smart and appends Tapestry form URLs which should  
> not be appended.

I've had some problems with Firefox autocompleting form field values. The  
solution has been to add autocomplete="false" to all forms.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Safari (for example) browser history and form exception

Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
1) Not sure.  The only time I see this problem is when the user types a stale form submit link into the title bar
2) The problem occurs in all browsers that have address bar 'smart' completion.
It is too smart and appends Tapestry form URLs which should not be appended.

On Mar 28, 2012, at 11:20 AM, pradeepchy wrote:

> Hi lprimak-
> 
> I was facing the same issue but after applying the changes you have
> suggested, problem got resolved. There are few questions which are not clear
> to me-
> 1) Why this problem occurs. In my case, user  hits a link, which will open a
> form to make entries.What is happening is when user clicks the link, it
> throws the exception. It works well in most of the cases but on very few
> occasions it throws exception.
> 
> 2) The problem occurs only in IE browsers. Is this  specific to IE browsers.
> 
> Can you please share your experience.
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Safari-for-example-browser-history-and-form-exception-tp4942074p5600864.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


Re: Safari (for example) browser history and form exception

Posted by pradeepchy <pr...@gmail.com>.
Hi lprimak-

I was facing the same issue but after applying the changes you have
suggested, problem got resolved. There are few questions which are not clear
to me-
1) Why this problem occurs. In my case, user  hits a link, which will open a
form to make entries.What is happening is when user clicks the link, it
throws the exception. It works well in most of the cases but on very few
occasions it throws exception.

2) The problem occurs only in IE browsers. Is this  specific to IE browsers.

Can you please share your experience.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Safari-for-example-browser-history-and-form-exception-tp4942074p5600864.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: Safari (for example) browser history and form exception

Posted by lprimak <lp...@hope.nyc.ny.us>.
Steve, your snippet expired me to redirect to the user's actually intended
page:
AppModule.java ---------

    /**
65	+	     * silently redirect the user to the intended page when browsing
through
66	+	     * tapestry forms through browser history
67	+	     */
68	+	
69	+	    public RequestExceptionHandler decorateRequestExceptionHandler(
70	+	            final ComponentSource componentSource,
71	+	            final Response response,
72	+	            final RequestExceptionHandler oldHandler)
73	+	    {
74	+	        return new RequestExceptionHandler()
75	+	        {
76	+	            @Override
77	+	            public void handleRequestException(Throwable exception)
throws IOException
78	+	            {
79	+	                if (!exception.getMessage().contains("Forms require
that the request method be POST and that the t:formdata query parameter have
values"))
80	+	                {
81	+	                    oldHandler.handleRequestException(exception);
82	+	                    return;
83	+	                }
84	+	                ComponentResources cr =
componentSource.getActivePage().getComponentResources();
85	+	                Link link = cr.createEventLink("");
86	+	                String uri = link.toRedirectURI().replaceAll(":", "");
87	+	                response.sendRedirect(uri);
88	+	            }
89	+	        };
90	+	    }

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Safari-for-example-browser-history-and-form-exception-tp4942074p4946765.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: Safari (for example) browser history and form exception

Posted by Steve Eynon <st...@alienfactory.co.uk>.
That particular exception is quite a bane for it happens a lot on live
public sties when they're crawled by various bots, and the logs fill
up quick! (Along with the IllegalArgException thrown when the URL
contains spaces.)

That said, I don't believe it is up to Tapestry to make exceptions to
the rule and handle these cases any differently. T5 is being strict
and believe that to be right, otherwise where do you draw the line?

What I would like to see, however, are more bespoke exceptions being
thrown so I can more easily identify them in my exception handling

Currently, my code reads something like:

if (exception.getMessage().contains("Forms require that the request
method be POST") {
    doRedirect();
}

which is brittle and nasty. I'd much rather have:

if (exception instanceof MalformedContextUrl) {
    doRedirect();
}

Steve.

On 27 October 2011 14:21, Lenny Primak <lp...@hope.nyc.ny.us> wrote:
> Safari has a friendly (overly friendly) URL completion, and it picks up Tapestry forms,
> which gives an ugly exception:
>
> For example for when I start typing pallet, the url URL https://www.XXX.com/stage/test/palletpage.srch.searchform comes
> up from the previous history.
> An unexpected application exception has occurred.
>
> Forms require that the request method be POST and that the t:formdata query parameter have values.
>
>
> Is there any way to prevent this or make an exception friendlier?
> For example, I am pretty sure that GET method is never valid on a form,
> so this should redirect to the actual page.
>
> What do you guys think?
>
>

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