You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by coriolisguy <es...@yahoo.com> on 2011/04/02 06:53:47 UTC

XHR request to return a test/xml payload

Hi All,

I have an ajax request that needs to return a text/xml payload. I need to
dynamically make the URL string in the browser to send to the server. What
should the format of that URL be?

Thanks


--
View this message in context: http://tapestry.1045711.n5.nabble.com/XHR-request-to-return-a-test-xml-payload-tp4277254p4277254.html
Sent from the Tapestry - User 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


Re: XHR request to return a test/xml payload

Posted by based2 <ba...@free.fr>.
http://code.google.com/p/tapestry-addons/

--
View this message in context: http://tapestry.1045711.n5.nabble.com/XHR-request-to-return-a-test-xml-payload-tp4277254p4278996.html
Sent from the Tapestry - User 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


Re: XHR request to return a test/xml payload

Posted by Richard Hill <ri...@su3analytics.com>.
If you want to make ajax requests from your own javascript, you can do
the following:

In MyPage.java put the following method (handler):

public StreamResponse onMyMethod() {

   // Construct your xml string
   String xml = ....

   return new TextStreamResponse("text/xml", xml);

}

Then in your javascript you can call this by making an ajax GET request
to:

GET /mypage:mymethod

You can pass in parameters as a context:

GET /mypage:mymethod/100

and change your handler to:

public StreamResponse onMyMethod(int arg) { ... }


You can also POST data as well, or pass args in the url query string in
a GET. You can access these parameters via Tapestry's request obj:

GET /mypage:mymethod?param=arg


@Inject
private Request request;

public StreamResponse onMyMethod() { 

  String arg = request.getParameter("param");

  ....

}

 
Hope that helps,

Richard








On Fri, 2011-04-01 at 21:53 -0700, coriolisguy wrote:
> Hi All,
> 
> I have an ajax request that needs to return a text/xml payload. I need to
> dynamically make the URL string in the browser to send to the server. What
> should the format of that URL be?
> 
> Thanks
> 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/XHR-request-to-return-a-test-xml-payload-tp4277254p4277254.html
> Sent from the Tapestry - User 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
> 



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


Re: XHR request to return a test/xml payload

Posted by David Uttley <du...@democracysystems.com>.
Hi,

I do the following in the page code so that I don't have to manipulate urls, you never know if the format could change;

	@Inject
	private ComponentResources resources;

	public String getUrl() {
		return resources.createEventLink("someEvent", 'some context').toURI();
	}

And then reference that in the .tml using ${url}

You could then return a JSONObject with the payload.

Hope this helps.

Dave


On 2 Apr 2011, at 05:53, coriolisguy wrote:

> Hi All,
> 
> I have an ajax request that needs to return a text/xml payload. I need to
> dynamically make the URL string in the browser to send to the server. What
> should the format of that URL be?
> 
> Thanks
> 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/XHR-request-to-return-a-test-xml-payload-tp4277254p4277254.html
> Sent from the Tapestry - User 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
> 


Re: XHR request to return a test/xml payload

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Sat, 02 Apr 2011 01:53:47 -0300, coriolisguy <es...@yahoo.com>  
wrote:

> Hi All,

Hi!

> I have an ajax request that needs to return a text/xml payload.

Return a StreamResponse (TextStreamResponse will probably be useful to you.

> I need to dynamically make the URL string in the browser to send to the  
> server.

I'm not following you.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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