Redirect in a FormHandler

View: New views
4 Messages — Rating Filter:   Alert me  

Redirect in a FormHandler

by Roland Whitehead :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We've done a some work on the FormMailer FormHandler and have wrapped  
it into a jar file and generally tidied it up. We've been asked to add  
a redirect on success (similar to the original FormMail.pl cgi). Has  
anyone done a redirect from within a FormHandler? We've tried to trick  
it by outputting some javascript to redirect the current browser  
window to a new relative URL but this doesn't work - the javascript  
isn't even rendered. Any suggestions?


Roland
--
QURU Ltd, London

Re: Redirect in a FormHandler

by Janne Jalkanen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Throwing a RedirectException does not work?

You could, of course, also use TemplateManager.requestResource() to  
write Javascript into the <head> directly.

/Janne

On 22 Jun 2009, at 20:48, Roland Whitehead wrote:

> We've done a some work on the FormMailer FormHandler and have  
> wrapped it into a jar file and generally tidied it up. We've been  
> asked to add a redirect on success (similar to the original  
> FormMail.pl cgi). Has anyone done a redirect from within a  
> FormHandler? We've tried to trick it by outputting some javascript  
> to redirect the current browser window to a new relative URL but  
> this doesn't work - the javascript isn't even rendered. Any  
> suggestions?
>
>
> Roland
> --
> QURU Ltd, London


Re: Redirect in a FormHandler

by Roland Whitehead :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We've tried throwing a RedirectException but a formhandler is actually  
defined as a plugin and plugins will only throw PluginExceptions. As  
RedirectExceptions are acutally WikiExceptions (and thus on a  
different fork to pluginExceptions) it just won't compile.

We're going to have a crack at writing to the header of the page and  
see what we can do. It seems very odd that the formplugin does not  
allow you to redirect to a different page according to success or  
failure - we rather think that this is one of the more obvious things  
that it should do. Perhaps we shouldn't be building this functionality  
into our handler but more into the formplugin. Does anyone else have a  
view on this?


Roland
--
QURU Ltd, London

On 23 Jun 2009, at 21:51, Janne Jalkanen wrote:

>
> Throwing a RedirectException does not work?
>
> You could, of course, also use TemplateManager.requestResource() to  
> write Javascript into the <head> directly.
>
> /Janne
>
> On 22 Jun 2009, at 20:48, Roland Whitehead wrote:
>
>> We've done a some work on the FormMailer FormHandler and have  
>> wrapped it into a jar file and generally tidied it up. We've been  
>> asked to add a redirect on success (similar to the original  
>> FormMail.pl cgi). Has anyone done a redirect from within a  
>> FormHandler? We've tried to trick it by outputting some javascript  
>> to redirect the current browser window to a new relative URL but  
>> this doesn't work - the javascript isn't even rendered. Any  
>> suggestions?
>>
>>
>> Roland
>> --
>> QURU Ltd, London
>
>


Re: Redirect in a FormHandler

by Janne Jalkanen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I think it sounds like a valid idea; perhaps we should allow in 3.0 a  
plugin to throw a WikiException?

(Forms are one of the older components in JSPWiki, and frankly, I  
still don't quite understand how they work :-)

/Janne

On 25 Jun 2009, at 20:13, Roland Whitehead wrote:

> We've tried throwing a RedirectException but a formhandler is  
> actually defined as a plugin and plugins will only throw  
> PluginExceptions. As RedirectExceptions are acutally WikiExceptions  
> (and thus on a different fork to pluginExceptions) it just won't  
> compile.
>
> We're going to have a crack at writing to the header of the page and  
> see what we can do. It seems very odd that the formplugin does not  
> allow you to redirect to a different page according to success or  
> failure - we rather think that this is one of the more obvious  
> things that it should do. Perhaps we shouldn't be building this  
> functionality into our handler but more into the formplugin. Does  
> anyone else have a view on this?
>
>
> Roland
> --
> QURU Ltd, London
>
> On 23 Jun 2009, at 21:51, Janne Jalkanen wrote:
>
>>
>> Throwing a RedirectException does not work?
>>
>> You could, of course, also use TemplateManager.requestResource() to  
>> write Javascript into the <head> directly.
>>
>> /Janne
>>
>> On 22 Jun 2009, at 20:48, Roland Whitehead wrote:
>>
>>> We've done a some work on the FormMailer FormHandler and have  
>>> wrapped it into a jar file and generally tidied it up. We've been  
>>> asked to add a redirect on success (similar to the original  
>>> FormMail.pl cgi). Has anyone done a redirect from within a  
>>> FormHandler? We've tried to trick it by outputting some javascript  
>>> to redirect the current browser window to a new relative URL but  
>>> this doesn't work - the javascript isn't even rendered. Any  
>>> suggestions?
>>>
>>>
>>> Roland
>>> --
>>> QURU Ltd, London
>>
>>