You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Paul Ferraro <pm...@columbia.edu> on 2004/12/01 00:19:28 UTC

Re: Sending Form data to an external page

Why not just use a regular html form and populate the form elements 
using the Any component?

<form action="http://paypal.com/transfer.do" method="post">
    Amount: <input name="amount" type="text"/>
    <input jwcid="@Any" name="fromAcct" value="ognl:accountNumber1" 
type="hidden"/>
    <input jwcid="@Any" name="toAcct" value="ognl:accountNumber2" 
type="hidden"/>
    <!-- etc.. -->
</form>

To answer your specific questions...

1.) Although I am not familiar with this section of the book, the 
functionality provided by throwing a "RedirectException" is fairly 
simple.  All it does is forward to a specified url if the url is 
relative, or redirect to a specified url if the url is absolute.  If you 
want to send a query string along with, you'll need to construct the url 
manually.
e.g.

StringBuffer buffer = new StringBuffer("http://paypal.com/transfer.do");
buffer.append("?fromAcct=").append(accountNumber1);
buffer.append("&toAcct=").append(accountNumber2);
buffer.append("&amount=").append(amount);
throw new RedirectException(buffer.toString());

2.) You can hardwire names to any type of form element like this:

<input jwcid="customName@Hidden" value=""/>

generates...

<input name="customName" value="" type="hidden"/>

Paul

dwm@vigilantms.com wrote:

>What is the best way to send form data to an external page.  I'm trying to
>set up a form to take the items out of a shopping cart and post them to a
>PayPal cart, which expects specified parameters.    According to chapter 8
>in TIA, the RedirectionException should send the request parameters by
>calling the RequestDispatcher and invoking the forward() method, but they
>don't seem to be sent.   
>
>Also,  Is there a way to control the "name" field of the hidden component so
>that the field matches what PayPal expects and not the name the framework
>generates?
>
>David Moran
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>  
>


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


RE: Sending Form data to an external page

Posted by dw...@vigilantms.com.
Thanks,  I knew there was a simple way to do this.   I forgot about using
the Any component. 

-----Original Message-----
From: Paul Ferraro [mailto:pmf8@columbia.edu] 
Sent: Tuesday, November 30, 2004 6:19 PM
To: Tapestry users
Subject: Re: Sending Form data to an external page

Why not just use a regular html form and populate the form elements 
using the Any component?

<form action="http://paypal.com/transfer.do" method="post">
    Amount: <input name="amount" type="text"/>
    <input jwcid="@Any" name="fromAcct" value="ognl:accountNumber1" 
type="hidden"/>
    <input jwcid="@Any" name="toAcct" value="ognl:accountNumber2" 
type="hidden"/>
    <!-- etc.. -->
</form>

To answer your specific questions...

1.) Although I am not familiar with this section of the book, the 
functionality provided by throwing a "RedirectException" is fairly 
simple.  All it does is forward to a specified url if the url is 
relative, or redirect to a specified url if the url is absolute.  If you 
want to send a query string along with, you'll need to construct the url 
manually.
e.g.

StringBuffer buffer = new StringBuffer("http://paypal.com/transfer.do");
buffer.append("?fromAcct=").append(accountNumber1);
buffer.append("&toAcct=").append(accountNumber2);
buffer.append("&amount=").append(amount);
throw new RedirectException(buffer.toString());

2.) You can hardwire names to any type of form element like this:

<input jwcid="customName@Hidden" value=""/>

generates...

<input name="customName" value="" type="hidden"/>

Paul

dwm@vigilantms.com wrote:

>What is the best way to send form data to an external page.  I'm trying to
>set up a form to take the items out of a shopping cart and post them to a
>PayPal cart, which expects specified parameters.    According to chapter 8
>in TIA, the RedirectionException should send the request parameters by
>calling the RequestDispatcher and invoking the forward() method, but they
>don't seem to be sent.   
>
>Also,  Is there a way to control the "name" field of the hidden component
so
>that the field matches what PayPal expects and not the name the framework
>generates?
>
>David Moran
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>  
>


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




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