You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Stéphane Poirier <st...@gmail.com> on 2007/06/20 16:56:44 UTC

[Trinidad] Submit to external link

Hi,

My problem include 2 know issues in the same time:

When a use hit the "Enter" key in a inputText, I want the form to submit.
There are 2 different destinations where to redirect :
- refresh the same page with an error message if input is not correct
- redirect to an external link if input is OK

My problem is: with an external link, I don't think a standard Action can bu
used to redirect, so I can't simply add a Javascript to call onClick() on a
commandButton (to simulate the Enter key submit)

Anyone knows how to achieve this?

Thanks in advance!

Re: [Trinidad] Submit to external link

Posted by Martin Marinschek <ma...@gmail.com>.
Hi Stephane,

sure you can do a redirect in your action-method - you have access to
all servlet-specific methods by casting:

facesContext.getExternalContext().getResponse()

to HttpServletResponse and then call:

response.sendRedirect(response.encodeRedirectURL(contextPath + "/maps"));

regards,

Martin

On 6/20/07, Adam Winer <aw...@gmail.com> wrote:
> I'd just handle this on the server:  set defaultCommand
> on the enclosing form, and make the actionListener
> on the server do the redirect.
>
> -- Adam
>
>
>
> On 6/20/07, Stéphane Poirier <st...@gmail.com> wrote:
> > Hi,
> >
> > My problem include 2 know issues in the same time:
> >
> > When a use hit the "Enter" key in a inputText, I want the form to submit.
> > There are 2 different destinations where to redirect :
> > - refresh the same page with an error message if input is not correct
> > - redirect to an external link if input is OK
> >
> > My problem is: with an external link, I don't think a standard Action can bu
> > used to redirect, so I can't simply add a Javascript to call onClick() on a
> > commandButton (to simulate the Enter key submit)
> >
> > Anyone knows how to achieve this?
> >
> > Thanks in advance!
>


-- 

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Re: [Trinidad] Submit to external link

Posted by Stéphane Poirier <st...@gmail.com>.
Nice and easy solution! Thanks!

On 6/20/07, Adam Winer <aw...@gmail.com> wrote:
>
> I'd just handle this on the server:  set defaultCommand
> on the enclosing form, and make the actionListener
> on the server do the redirect.
>
> -- Adam
>
>
>
> On 6/20/07, Stéphane Poirier <st...@gmail.com> wrote:
> > Hi,
> >
> > My problem include 2 know issues in the same time:
> >
> > When a use hit the "Enter" key in a inputText, I want the form to
> submit.
> > There are 2 different destinations where to redirect :
> > - refresh the same page with an error message if input is not correct
> > - redirect to an external link if input is OK
> >
> > My problem is: with an external link, I don't think a standard Action
> can bu
> > used to redirect, so I can't simply add a Javascript to call onClick()
> on a
> > commandButton (to simulate the Enter key submit)
> >
> > Anyone knows how to achieve this?
> >
> > Thanks in advance!
>

Re: [Trinidad] Submit to external link

Posted by Adam Winer <aw...@gmail.com>.
I'd just handle this on the server:  set defaultCommand
on the enclosing form, and make the actionListener
on the server do the redirect.

-- Adam



On 6/20/07, Stéphane Poirier <st...@gmail.com> wrote:
> Hi,
>
> My problem include 2 know issues in the same time:
>
> When a use hit the "Enter" key in a inputText, I want the form to submit.
> There are 2 different destinations where to redirect :
> - refresh the same page with an error message if input is not correct
> - redirect to an external link if input is OK
>
> My problem is: with an external link, I don't think a standard Action can bu
> used to redirect, so I can't simply add a Javascript to call onClick() on a
> commandButton (to simulate the Enter key submit)
>
> Anyone knows how to achieve this?
>
> Thanks in advance!