You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Khalid EL BOUKHARI <el...@gmail.com> on 2010/11/08 11:02:18 UTC

Do a POST with Tapestry and "Link"

Hi,
I need to do POST in Tapestry for example :

<form method=*"POST"* Action=*"*MyURL*"* name=*"name"*>

            <input type=*HIDDEN* name=*"FirstParam"* id=*"IdFirstParam"*value=
*"*Value*FrstParam"*/>

            <input type=*HIDDEN* name=*"SndParam"* id=*"IdSndParam"* value=*
"*Value*SndParam"*/>

</form>


When I try :


String data = URLEncoder.encode("*FirstParam*", "UTF-8") + "=" +
URLEncoder.encode("*FirstParam*", "UTF-8");
                    data += "&" + URLEncoder.encode("*SndParam*", "UTF-8") +
"=" + URLEncoder.encode("*SndParam"*, "UTF-8");
// Send data
URL url = new URL(*MyURL*);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();

But Tapestry tell me that I must use :
java.net.URL, org.apache.tapestry5.Link, org.apache.tapestry5.StreamResponse

Any one know how to do ?

Thanks in advance

*Khalid.*

Re: Do a POST with Tapestry and "Link"

Posted by Christian Köberl <ta...@gmail.com>.
It's not really clear what you want to do. With Tapestry you really don't
need to fiddling with URLEncoder or connections.

Which Tapestry Version are you targeting (3, 4 or 5)?

If you use 5 - take a look at the LinkSubmit component
(http://tapestry.apache.org/tapestry5.1/tapestry-core/ref/org/apache/tapestry5/corelib/components/LinkSubmit.html).

Simple form example with LinkSubmit:
<form t:type="form" t:id="myForm">
  <input type="text" t:type="TextField" t:id="myText" value="text" />
   # Submit me 
</form>
-- 
View this message in context: http://tapestry-users.832.n2.nabble.com/Do-a-POST-with-Tapestry-and-Link-tp5717358p5724205.html
Sent from the Tapestry Users 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