You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Legolas Woodland <le...@gmail.com> on 2006/09/26 23:08:30 UTC
can we post to another web application from a button action ?
Hi
Thank you for reading my post
I need to use *post* method to send some parameters to a web site,
now , in my web application which is based on jsf , i do not know how i
can do this as parameters has their name and also i should compute their
values before i post them to other web site.
should we do this in button action method or there are some other ways?
thanks
RE: can we post to another web application from a button action ?
Posted by "Wabner, Thomas (EXT)" <th...@siemens.com>.
Hi,
we have had the same problems. We have solved them via creating our own
form component (a la like the s:form in the sandbox of tomahawk but with
some changes) and it works quite nice.
If you are interested, I can send you the implementation.
The idea behind is to create a from with some extra attributes for
servername, port, method, applicationRoot and such like this.
The only one problem is you cannot use the commandButton or commandLink
in this form. But with <f:verbatim><input type="submit"/></f:verbatim>
it is easy.
Hope this helps,
- waffel
-----Original Message-----
From: Andrew Robinson [mailto:andrew.rw.robinson@gmail.com]
Sent: Donnerstag, 28. September 2006 17:29
To: MyFaces Discussion
Subject: Re: can we post to another web application from a button action
?
It would be a GET method. If you want to post to a new site and
display the result to the user, you would probably need to render a
form that is submitted to the new site and then force the form to post
on load.
The other alternative, is to post it yourself on the back end using
HttpUrlConnection and then simply stream the output to the browser.
Note that this can be tricky with relative links in the page as well
as cookies (so that will not be an easy solution).
On 9/27/06, legolas wood <ka...@gmail.com> wrote:
> Will that method (redirect and return null) post to that URL ?
> the web site that i should pass the parameters just works with POST
> method and no other mechanism.
> thanks
>
>
> Andrew Robinson wrote:
> > Do you want to send him/her to that page or do you want to just post
> > data and "ignore" the response from that website?
> >
> > If you want to send them, create a navigation rule with the full URL
> > (if it is static) with a "redirect" set. Then return that action
> > result.
> >
> > If you want to send them but the URL is dynamic:
> > 1) create a custom navigation handler that performs a redirect
> > -or-
> > 2) redirect and return null:
> >
> > public String myAction()
> > {
> > // your business code
> >
> > FacesContext facesContext = FacesContext.getCurrentInstance();
> > facesContext.getExternalContext().redirect(someURL);
> > facesContext.responseComplete();
> > return null;
> > }
> >
> > On 9/26/06, Legolas Woodland <le...@gmail.com> wrote:
> >> Thank you for reply.
> >> what about sending them from server side ?
> >> if i send user to that url from serverside i can make my database
change
> >> and then send him/her to other web site.
> >> can i have an action for outputlink and also send the user to other
web
> >> site?
> >> for example in action binding i made database change and when
he/she
> >> clicked on it i post the parameter to that website?
> >>
> >> thanks
> >>
> >> Andrew Robinson wrote:
> >> > Do you want to post from the client or the server? If from the
client,
> >> > just use the "normal" method. You can use h:outputLink with
embedded
> >> > f:param elements.
> >> >
> >> > On 9/26/06, Legolas Woodland <le...@gmail.com> wrote:
> >> >>
> >> >> Hi
> >> >> Thank you for reading my post
> >> >> I need to use post method to send some parameters to a web
site,
> >> >> now , in my web application which is based on jsf , i do not
know
> >> >> how i can
> >> >> do this as parameters has their name and also i should compute
their
> >> >> values
> >> >> before i post them to other web site.
> >> >>
> >> >> should we do this in button action method or there are some
other
> >> ways?
> >> >> thanks
> >> >>
> >> >
> >>
> >>
> >
>
>
Re: can we post to another web application from a button action ?
Posted by Andrew Robinson <an...@gmail.com>.
It would be a GET method. If you want to post to a new site and
display the result to the user, you would probably need to render a
form that is submitted to the new site and then force the form to post
on load.
The other alternative, is to post it yourself on the back end using
HttpUrlConnection and then simply stream the output to the browser.
Note that this can be tricky with relative links in the page as well
as cookies (so that will not be an easy solution).
On 9/27/06, legolas wood <ka...@gmail.com> wrote:
> Will that method (redirect and return null) post to that URL ?
> the web site that i should pass the parameters just works with POST
> method and no other mechanism.
> thanks
>
>
> Andrew Robinson wrote:
> > Do you want to send him/her to that page or do you want to just post
> > data and "ignore" the response from that website?
> >
> > If you want to send them, create a navigation rule with the full URL
> > (if it is static) with a "redirect" set. Then return that action
> > result.
> >
> > If you want to send them but the URL is dynamic:
> > 1) create a custom navigation handler that performs a redirect
> > -or-
> > 2) redirect and return null:
> >
> > public String myAction()
> > {
> > // your business code
> >
> > FacesContext facesContext = FacesContext.getCurrentInstance();
> > facesContext.getExternalContext().redirect(someURL);
> > facesContext.responseComplete();
> > return null;
> > }
> >
> > On 9/26/06, Legolas Woodland <le...@gmail.com> wrote:
> >> Thank you for reply.
> >> what about sending them from server side ?
> >> if i send user to that url from serverside i can make my database change
> >> and then send him/her to other web site.
> >> can i have an action for outputlink and also send the user to other web
> >> site?
> >> for example in action binding i made database change and when he/she
> >> clicked on it i post the parameter to that website?
> >>
> >> thanks
> >>
> >> Andrew Robinson wrote:
> >> > Do you want to post from the client or the server? If from the client,
> >> > just use the "normal" method. You can use h:outputLink with embedded
> >> > f:param elements.
> >> >
> >> > On 9/26/06, Legolas Woodland <le...@gmail.com> wrote:
> >> >>
> >> >> Hi
> >> >> Thank you for reading my post
> >> >> I need to use post method to send some parameters to a web site,
> >> >> now , in my web application which is based on jsf , i do not know
> >> >> how i can
> >> >> do this as parameters has their name and also i should compute their
> >> >> values
> >> >> before i post them to other web site.
> >> >>
> >> >> should we do this in button action method or there are some other
> >> ways?
> >> >> thanks
> >> >>
> >> >
> >>
> >>
> >
>
>
Re: can we post to another web application from a button action ?
Posted by legolas wood <ka...@gmail.com>.
Will that method (redirect and return null) post to that URL ?
the web site that i should pass the parameters just works with POST
method and no other mechanism.
thanks
Andrew Robinson wrote:
> Do you want to send him/her to that page or do you want to just post
> data and "ignore" the response from that website?
>
> If you want to send them, create a navigation rule with the full URL
> (if it is static) with a "redirect" set. Then return that action
> result.
>
> If you want to send them but the URL is dynamic:
> 1) create a custom navigation handler that performs a redirect
> -or-
> 2) redirect and return null:
>
> public String myAction()
> {
> // your business code
>
> FacesContext facesContext = FacesContext.getCurrentInstance();
> facesContext.getExternalContext().redirect(someURL);
> facesContext.responseComplete();
> return null;
> }
>
> On 9/26/06, Legolas Woodland <le...@gmail.com> wrote:
>> Thank you for reply.
>> what about sending them from server side ?
>> if i send user to that url from serverside i can make my database change
>> and then send him/her to other web site.
>> can i have an action for outputlink and also send the user to other web
>> site?
>> for example in action binding i made database change and when he/she
>> clicked on it i post the parameter to that website?
>>
>> thanks
>>
>> Andrew Robinson wrote:
>> > Do you want to post from the client or the server? If from the client,
>> > just use the "normal" method. You can use h:outputLink with embedded
>> > f:param elements.
>> >
>> > On 9/26/06, Legolas Woodland <le...@gmail.com> wrote:
>> >>
>> >> Hi
>> >> Thank you for reading my post
>> >> I need to use post method to send some parameters to a web site,
>> >> now , in my web application which is based on jsf , i do not know
>> >> how i can
>> >> do this as parameters has their name and also i should compute their
>> >> values
>> >> before i post them to other web site.
>> >>
>> >> should we do this in button action method or there are some other
>> ways?
>> >> thanks
>> >>
>> >
>>
>>
>
Re: can we post to another web application from a button action ?
Posted by Andrew Robinson <an...@gmail.com>.
Then I would recommend one of the redirect methods. That way, your
action runs then the new URL is loaded in the browser for the external
site.
On 9/27/06, Legolas Woodland <le...@gmail.com> wrote:
> Thank you Andrew.
> I should show that page to user because user will continue on that page
> until his/her operation complete
> that web site will send user back to my web site.
> url will be dynamic because i should pass some parameters to that web page.
> Andrew Robinson wrote:
> > Do you want to send him/her to that page or do you want to just post
> > data and "ignore" the response from that website?
> >
> > If you want to send them, create a navigation rule with the full URL
> > (if it is static) with a "redirect" set. Then return that action
> > result.
> >
> > If you want to send them but the URL is dynamic:
> > 1) create a custom navigation handler that performs a redirect
> > -or-
> > 2) redirect and return null:
> >
> > public String myAction()
> > {
> > // your business code
> >
> > FacesContext facesContext = FacesContext.getCurrentInstance();
> > facesContext.getExternalContext().redirect(someURL);
> > facesContext.responseComplete();
> > return null;
> > }
> >
> > On 9/26/06, Legolas Woodland <le...@gmail.com> wrote:
> >> Thank you for reply.
> >> what about sending them from server side ?
> >> if i send user to that url from serverside i can make my database change
> >> and then send him/her to other web site.
> >> can i have an action for outputlink and also send the user to other web
> >> site?
> >> for example in action binding i made database change and when he/she
> >> clicked on it i post the parameter to that website?
> >>
> >> thanks
> >>
> >> Andrew Robinson wrote:
> >> > Do you want to post from the client or the server? If from the client,
> >> > just use the "normal" method. You can use h:outputLink with embedded
> >> > f:param elements.
> >> >
> >> > On 9/26/06, Legolas Woodland <le...@gmail.com> wrote:
> >> >>
> >> >> Hi
> >> >> Thank you for reading my post
> >> >> I need to use post method to send some parameters to a web site,
> >> >> now , in my web application which is based on jsf , i do not know
> >> >> how i can
> >> >> do this as parameters has their name and also i should compute their
> >> >> values
> >> >> before i post them to other web site.
> >> >>
> >> >> should we do this in button action method or there are some other
> >> ways?
> >> >> thanks
> >> >>
> >> >
> >>
> >>
> >
>
>
Re: can we post to another web application from a button action ?
Posted by Legolas Woodland <le...@gmail.com>.
Thank you Andrew.
I should show that page to user because user will continue on that page
until his/her operation complete
that web site will send user back to my web site.
url will be dynamic because i should pass some parameters to that web page.
Andrew Robinson wrote:
> Do you want to send him/her to that page or do you want to just post
> data and "ignore" the response from that website?
>
> If you want to send them, create a navigation rule with the full URL
> (if it is static) with a "redirect" set. Then return that action
> result.
>
> If you want to send them but the URL is dynamic:
> 1) create a custom navigation handler that performs a redirect
> -or-
> 2) redirect and return null:
>
> public String myAction()
> {
> // your business code
>
> FacesContext facesContext = FacesContext.getCurrentInstance();
> facesContext.getExternalContext().redirect(someURL);
> facesContext.responseComplete();
> return null;
> }
>
> On 9/26/06, Legolas Woodland <le...@gmail.com> wrote:
>> Thank you for reply.
>> what about sending them from server side ?
>> if i send user to that url from serverside i can make my database change
>> and then send him/her to other web site.
>> can i have an action for outputlink and also send the user to other web
>> site?
>> for example in action binding i made database change and when he/she
>> clicked on it i post the parameter to that website?
>>
>> thanks
>>
>> Andrew Robinson wrote:
>> > Do you want to post from the client or the server? If from the client,
>> > just use the "normal" method. You can use h:outputLink with embedded
>> > f:param elements.
>> >
>> > On 9/26/06, Legolas Woodland <le...@gmail.com> wrote:
>> >>
>> >> Hi
>> >> Thank you for reading my post
>> >> I need to use post method to send some parameters to a web site,
>> >> now , in my web application which is based on jsf , i do not know
>> >> how i can
>> >> do this as parameters has their name and also i should compute their
>> >> values
>> >> before i post them to other web site.
>> >>
>> >> should we do this in button action method or there are some other
>> ways?
>> >> thanks
>> >>
>> >
>>
>>
>
Re: can we post to another web application from a button action ?
Posted by Andrew Robinson <an...@gmail.com>.
Do you want to send him/her to that page or do you want to just post
data and "ignore" the response from that website?
If you want to send them, create a navigation rule with the full URL
(if it is static) with a "redirect" set. Then return that action
result.
If you want to send them but the URL is dynamic:
1) create a custom navigation handler that performs a redirect
-or-
2) redirect and return null:
public String myAction()
{
// your business code
FacesContext facesContext = FacesContext.getCurrentInstance();
facesContext.getExternalContext().redirect(someURL);
facesContext.responseComplete();
return null;
}
On 9/26/06, Legolas Woodland <le...@gmail.com> wrote:
> Thank you for reply.
> what about sending them from server side ?
> if i send user to that url from serverside i can make my database change
> and then send him/her to other web site.
> can i have an action for outputlink and also send the user to other web
> site?
> for example in action binding i made database change and when he/she
> clicked on it i post the parameter to that website?
>
> thanks
>
> Andrew Robinson wrote:
> > Do you want to post from the client or the server? If from the client,
> > just use the "normal" method. You can use h:outputLink with embedded
> > f:param elements.
> >
> > On 9/26/06, Legolas Woodland <le...@gmail.com> wrote:
> >>
> >> Hi
> >> Thank you for reading my post
> >> I need to use post method to send some parameters to a web site,
> >> now , in my web application which is based on jsf , i do not know
> >> how i can
> >> do this as parameters has their name and also i should compute their
> >> values
> >> before i post them to other web site.
> >>
> >> should we do this in button action method or there are some other ways?
> >> thanks
> >>
> >
>
>
Re: can we post to another web application from a button action ?
Posted by Legolas Woodland <le...@gmail.com>.
Thank you for reply.
what about sending them from server side ?
if i send user to that url from serverside i can make my database change
and then send him/her to other web site.
can i have an action for outputlink and also send the user to other web
site?
for example in action binding i made database change and when he/she
clicked on it i post the parameter to that website?
thanks
Andrew Robinson wrote:
> Do you want to post from the client or the server? If from the client,
> just use the "normal" method. You can use h:outputLink with embedded
> f:param elements.
>
> On 9/26/06, Legolas Woodland <le...@gmail.com> wrote:
>>
>> Hi
>> Thank you for reading my post
>> I need to use post method to send some parameters to a web site,
>> now , in my web application which is based on jsf , i do not know
>> how i can
>> do this as parameters has their name and also i should compute their
>> values
>> before i post them to other web site.
>>
>> should we do this in button action method or there are some other ways?
>> thanks
>>
>
Re: can we post to another web application from a button action ?
Posted by Andrew Robinson <an...@gmail.com>.
Do you want to post from the client or the server? If from the client,
just use the "normal" method. You can use h:outputLink with embedded
f:param elements.
On 9/26/06, Legolas Woodland <le...@gmail.com> wrote:
>
> Hi
> Thank you for reading my post
> I need to use post method to send some parameters to a web site,
> now , in my web application which is based on jsf , i do not know how i can
> do this as parameters has their name and also i should compute their values
> before i post them to other web site.
>
> should we do this in button action method or there are some other ways?
> thanks
>