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
Thank you Joost and Thiago, May be may question wasn't clear. So what I need that a method return an object that make a post with the previous params. I hope that is more clear now. Cheers, Khalid.
Re: Do a post with Tapestry and Link
Thank you I'll try that.
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: Problem with context
Thanks for your response. Sorry my question wasn't clair. What I want to ask for is : This redirection is done with a return class in my java file. The correspondig tml file is empty (just html/html ). In my Junit test file I create a Document who gets my page but it return an application exception: Document myIndexPage = pageTester.renderPage(Index). index.tml is the redirection page.
Problem with context
Hi, I'm developing some unit tests. In my application I have a fake (not to be displayed) page that redirect me to a page with some form. The problem is that Tapestry returns an error page : java.lang.RuntimeException Page Error did not generate any markup when rendered. This could be because its template file could not be located, or because a render phase method in the page prevented rendering. Hide uninteresting stack frames Stack trace - org.apache.tapestry5.internal.services.PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:67) - $PageMarkupRenderer_129039e1ce0.renderPageMarkup($PageMarkupRenderer_129039e1ce0.java) - org.apache.tapestry5.internal.services.PageResponseRendererImpl.renderPageResponse(PageResponseRendererImpl.java:61) - $PageResponseRenderer_129039e1ca3.renderPageResponse($PageResponseRenderer_129039e1ca3.java) - org.apache.tapestry5.internal.services.PageRenderRequestHandlerImpl.handle(PageRenderRequestHandlerImpl.java:63) Before that a was a problem with the context, so my solution was : TestableRequest request = pageTester.getService(TestableRequest.class); request.loadParameter(DATA, tutu); Assert.assertEquals(request.getParameter(DATA), tutu); In this URL ( http://tapestry.apache.org/tapestry5.1/guide/unit-testing-pages.html)a found a solution : Object[] context = new Object[]{ abc, 123 }; Document doc = tester.invoke(new ComponentInvocation(new PageLinkTarget(MyPage), context)); But invoke method and ComonentInvocation are not recorgnized by Eclipse. Any Idea please? -- KEB