You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Joshua Jackson <jo...@gmail.com> on 2007/06/12 11:02:31 UTC

T5: Ajaxify Page with built in Scriptaculous

Hi all,

I'm having a rough time to Ajaxify my page with the built in
scriptaculous in T5. How do I process and display the streaming result
received from server with the built in scriptaculous bundled with T5?
Has anyone able to implement scriptaculous on their Page? Can you
please share it with us here.

Thanks in advance.

-- 
Let's create a highly maintainable and efficient code

YM!: thejavafreak
Blog: http://www.nagasakti.or.id/roller/joshua/

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


Re: T5: Ajaxify Page with built in Scriptaculous

Posted by Joshua Jackson <jo...@gmail.com>.
Hi Howard,

Thanks for the reply. This is a great news for the whole community, as
AJAX is something we can not avoid these days. You're right about
response is a full page HTML. How will the dispatcher only gives back
the data I need instead of the full page HTML?

On 6/12/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> My plans for Ajax is to introduce a new Dispatcher that recognizes the
> XHR request and handles the response different, rendering a response
> within the same request. What you are seeing is probably the result of
> the ac tion request sending a redirect to the client, then a full page
> of HTML.


Regards,

-- 
Let's create a highly maintainable and efficient code

YM!: thejavafreak
Blog: http://www.nagasakti.or.id/roller/joshua/

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


Re: T5: Ajaxify Page with built in Scriptaculous

Posted by Joshua Jackson <jo...@gmail.com>.
Thanks Bill,

It's working now :)

Regards

On 6/15/07, Bill Holloway <bi...@gmail.com> wrote:
> onMyAction() returns a textstream to the handleResponse javascript
> method on the client.  That's a handwritten method.  Not sure how
> you're getting the whole HTML of your page.
-- 
Let's create a highly maintainable and efficient code

YM!: thejavafreak
Blog: http://www.nagasakti.or.id/roller/joshua/

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


Re: T5: Ajaxify Page with built in Scriptaculous

Posted by Bill Holloway <bi...@gmail.com>.
onMyAction() returns a textstream to the handleResponse javascript
method on the client.  That's a handwritten method.  Not sure how
you're getting the whole HTML of your page.

On 6/14/07, Jun Tsai <ju...@gmail.com> wrote:
> 2007/6/14, Joshua Jackson <jo...@gmail.com>:
> >
> > Hi Bill
> >
> > Thanks alot for the example. It works great. But this returns the
> > whole page of HTML to the alert message. How do I get just the
> > TextStreamResponse and place it on my page?
> >
> > Thanks in advance.
>
>
>
> You may be see prototpye and scriptaculus.use js to update your page.
>
> --
> > Welcome to China Java Users Group(CNJUG).
> > http://cnjug.dev.java.net
>


-- 
"The future is here.  It's just not evenly distributed yet."

     -- Traditional

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


Re: T5: Ajaxify Page with built in Scriptaculous

Posted by Jun Tsai <ju...@gmail.com>.
2007/6/14, Joshua Jackson <jo...@gmail.com>:
>
> Hi Bill
>
> Thanks alot for the example. It works great. But this returns the
> whole page of HTML to the alert message. How do I get just the
> TextStreamResponse and place it on my page?
>
> Thanks in advance.



You may be see prototpye and scriptaculus.use js to update your page.

-- 
> Welcome to China Java Users Group(CNJUG).
> http://cnjug.dev.java.net

Re: T5: Ajaxify Page with built in Scriptaculous

Posted by Joshua Jackson <jo...@gmail.com>.
Hi Bill

Thanks alot for the example. It works great. But this returns the
whole page of HTML to the alert message. How do I get just the
TextStreamResponse and place it on my page?

Thanks in advance.

On 6/13/07, Bill Holloway <bi...@gmail.com> wrote:
> Joshua,
>
> here's a very simple example:
>
> Template:
...

-- 
Let's create a highly maintainable and efficient code

YM!: thejavafreak
Blog: http://www.nagasakti.or.id/roller/joshua/

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


Re: T5: Ajaxify Page with built in Scriptaculous

Posted by Jun Tsai <ju...@gmail.com>.
I had test it. works fine.
2007/6/14, Bill Holloway <bi...@gmail.com>:
>
> Joshua,
>
> here's a very simple example:
>
> Template:
>
> <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
> <script type="text/javascript" src="${prototype}"></script>
> <script type="text/javascript" src="${scriptaculous}"></script>
> <body>
>
> <script type="text/javascript">
>
>         function handleResponse (xhrResponse)
>         {
>                 alert (xhrResponse.responseText);
>         }
>
>         function asyncCall ()
>         {
>                 new Ajax.Request ('${theLink}', {asynchronous:true,
> onSuccess:handleResponse});
>         }
> </script>
>
> <button onclick="asyncCall();">Do AJAX Call</button>
>
> </body>
> </html>
>
> Class:
> public class AjaxPage
> {
>         @Inject
>         private ComponentResources _resources;
>
>         @Inject
>         @Path("${tapestry.scriptaculous}/prototype.js")
>         private Asset _prototype;
>
>         @Inject
>         @Path("${tapestry.scriptaculous}/scriptaculous.js")
>         private Asset _scriptaculous;
>
>         /**
>          * Generates a URI to the server-side function for the XHR
>          * to use.
>          *
>          * @return the link
>          */
>         public String getTheLink ()
>         {
>                 Link l = _resources.createActionLink ("myAction", false);
>                 return l.toURI();
>         }
>
>         /**
>          * This is a server-side method called via XHR that returns
>          * some text.
>          *
>          * @return some text
>          */
>         StreamResponse onMyAction ()
>         {
>                 return new TextStreamResponse ("type/text", "Five bucks
> below the
> belt.  That's how I roll.");
>         }
>
>         /**
>          * @return the prototype
>          */
>         public Asset getPrototype ()
>         {
>                 return _prototype;
>         }
>
>         /**
>          * @param prototype the prototype to set
>          */
>         public void setPrototype (Asset prototype)
>         {
>                 _prototype = prototype;
>         }
>
>         /**
>          * @return the scriptaculous
>          */
>         public Asset getScriptaculous ()
>         {
>                 return _scriptaculous;
>         }
>
>         /**
>          * @param scriptaculous the scriptaculous to set
>          */
>         public void setScriptaculous (Asset scriptaculous)
>         {
>                 _scriptaculous = scriptaculous;
>         }
>
> }
>
>
>
>
> On 6/13/07, Joshua Jackson <jo...@gmail.com> wrote:
> > Hi Massimo
> >
> > Thanks for the response. How do you exatcly implement the response?
> >
> > What I assume is that you do something like this:
> >         public StreamResponse onAction(){
> >                 return new TextStreamResponse("text/xml",
> "<employees><employee
> > name=\"joshua\" /></employees>");
> >         }
> >
> > And then process it with prototype inside your html page?
> >
> > Or do you have any other approach for this?
> >
> > Thanks in advance
> >
> > On 6/13/07, Massimo Lusetti <ml...@gmail.com> wrote:
> >
> > > I'm eager to see this implemented but i could say that right now with
> > > StreamResponse is fairly easy to accomplish this. Thanks to the T5
> > > flexibility.
> >
> > --
> > Let's create a highly maintainable and efficient code
> >
> > YM!: thejavafreak
> > Blog: http://www.nagasakti.or.id/roller/joshua/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> "The future is here.  It's just not evenly distributed yet."
>
>      -- Traditional
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Welcome to China Java Users Group(CNJUG).
http://cnjug.dev.java.net

Re: T5: Ajaxify Page with built in Scriptaculous

Posted by Mike_R <Mi...@gmx.net>.


> Hi, i copy & paste this example but it don't work , do i missing something
> ?


Could you post the error? I saw some inline expansions ( ${theLink} ) so
maybe you get the error because you're not running the tapestry
5.0.5-SNAPSHOT release.
-- 
View this message in context: http://www.nabble.com/T5%3A-Ajaxify-Page-with-built-in-Scriptaculous-tf3906419.html#a11115088
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: T5: Ajaxify Page with built in Scriptaculous

Posted by Fidel Chavarria <fi...@gmail.com>.

Hi, i copy & paste this example but it don't work , do i missing something ?


texomaleo wrote:
> 
> Joshua,
> 
> here's a very simple example:
> 
> Template:
> 
> <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
> <script type="text/javascript" src="${prototype}"></script>
> <script type="text/javascript" src="${scriptaculous}"></script>
> <body>
> 
> <script type="text/javascript">
> 
> 	function handleResponse (xhrResponse)
> 	{
> 		alert (xhrResponse.responseText);
> 	}
> 
> 	function asyncCall ()
> 	{
> 		new Ajax.Request ('${theLink}', {asynchronous:true,
> onSuccess:handleResponse});
> 	}
> </script>
> 
> <button onclick="asyncCall();">Do AJAX Call</button>
> 
> </body>
> </html>
> 
> Class:
> public class AjaxPage
> {
> 	@Inject
> 	private ComponentResources _resources;
> 	
> 	@Inject
> 	@Path("${tapestry.scriptaculous}/prototype.js")
> 	private Asset _prototype;
> 	
> 	@Inject
> 	@Path("${tapestry.scriptaculous}/scriptaculous.js")
> 	private Asset _scriptaculous;
> 	
> 	/**
> 	 * Generates a URI to the server-side function for the XHR
> 	 * to use.
> 	 *
> 	 * @return the link
> 	 */
> 	public String getTheLink ()
> 	{
> 		Link l = _resources.createActionLink ("myAction", false);
> 		return l.toURI();
> 	}
> 	
> 	/**
> 	 * This is a server-side method called via XHR that returns
> 	 * some text.
> 	 *
> 	 * @return some text
> 	 */
> 	StreamResponse onMyAction ()
> 	{
> 		return new TextStreamResponse ("type/text", "Five bucks below the
> belt.  That's how I roll.");
> 	}
> 
> 	/**
> 	 * @return the prototype
> 	 */
> 	public Asset getPrototype ()
> 	{
> 		return _prototype;
> 	}
> 
> 	/**
> 	 * @param prototype the prototype to set
> 	 */
> 	public void setPrototype (Asset prototype)
> 	{
> 		_prototype = prototype;
> 	}
> 
> 	/**
> 	 * @return the scriptaculous
> 	 */
> 	public Asset getScriptaculous ()
> 	{
> 		return _scriptaculous;
> 	}
> 
> 	/**
> 	 * @param scriptaculous the scriptaculous to set
> 	 */
> 	public void setScriptaculous (Asset scriptaculous)
> 	{
> 		_scriptaculous = scriptaculous;
> 	}
> 
> }
> 
> 
> 
> 
> On 6/13/07, Joshua Jackson <jo...@gmail.com> wrote:
>> Hi Massimo
>>
>> Thanks for the response. How do you exatcly implement the response?
>>
>> What I assume is that you do something like this:
>>         public StreamResponse onAction(){
>>                 return new TextStreamResponse("text/xml",
>> "<employees><employee
>> name=\"joshua\" /></employees>");
>>         }
>>
>> And then process it with prototype inside your html page?
>>
>> Or do you have any other approach for this?
>>
>> Thanks in advance
>>
>> On 6/13/07, Massimo Lusetti <ml...@gmail.com> wrote:
>>
>> > I'm eager to see this implemented but i could say that right now with
>> > StreamResponse is fairly easy to accomplish this. Thanks to the T5
>> > flexibility.
>>
>> --
>> Let's create a highly maintainable and efficient code
>>
>> YM!: thejavafreak
>> Blog: http://www.nagasakti.or.id/roller/joshua/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> -- 
> "The future is here.  It's just not evenly distributed yet."
> 
>      -- Traditional
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-Ajaxify-Page-with-built-in-Scriptaculous-tf3906419.html#a11109026
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: T5: Ajaxify Page with built in Scriptaculous

Posted by Bill Holloway <bi...@gmail.com>.
Joshua,

here's a very simple example:

Template:

<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<script type="text/javascript" src="${prototype}"></script>
<script type="text/javascript" src="${scriptaculous}"></script>
<body>

<script type="text/javascript">

	function handleResponse (xhrResponse)
	{
		alert (xhrResponse.responseText);
	}

	function asyncCall ()
	{
		new Ajax.Request ('${theLink}', {asynchronous:true,
onSuccess:handleResponse});
	}
</script>

<button onclick="asyncCall();">Do AJAX Call</button>

</body>
</html>

Class:
public class AjaxPage
{
	@Inject
	private ComponentResources _resources;
	
	@Inject
	@Path("${tapestry.scriptaculous}/prototype.js")
	private Asset _prototype;
	
	@Inject
	@Path("${tapestry.scriptaculous}/scriptaculous.js")
	private Asset _scriptaculous;
	
	/**
	 * Generates a URI to the server-side function for the XHR
	 * to use.
	 *
	 * @return the link
	 */
	public String getTheLink ()
	{
		Link l = _resources.createActionLink ("myAction", false);
		return l.toURI();
	}
	
	/**
	 * This is a server-side method called via XHR that returns
	 * some text.
	 *
	 * @return some text
	 */
	StreamResponse onMyAction ()
	{
		return new TextStreamResponse ("type/text", "Five bucks below the
belt.  That's how I roll.");
	}

	/**
	 * @return the prototype
	 */
	public Asset getPrototype ()
	{
		return _prototype;
	}

	/**
	 * @param prototype the prototype to set
	 */
	public void setPrototype (Asset prototype)
	{
		_prototype = prototype;
	}

	/**
	 * @return the scriptaculous
	 */
	public Asset getScriptaculous ()
	{
		return _scriptaculous;
	}

	/**
	 * @param scriptaculous the scriptaculous to set
	 */
	public void setScriptaculous (Asset scriptaculous)
	{
		_scriptaculous = scriptaculous;
	}

}




On 6/13/07, Joshua Jackson <jo...@gmail.com> wrote:
> Hi Massimo
>
> Thanks for the response. How do you exatcly implement the response?
>
> What I assume is that you do something like this:
>         public StreamResponse onAction(){
>                 return new TextStreamResponse("text/xml", "<employees><employee
> name=\"joshua\" /></employees>");
>         }
>
> And then process it with prototype inside your html page?
>
> Or do you have any other approach for this?
>
> Thanks in advance
>
> On 6/13/07, Massimo Lusetti <ml...@gmail.com> wrote:
>
> > I'm eager to see this implemented but i could say that right now with
> > StreamResponse is fairly easy to accomplish this. Thanks to the T5
> > flexibility.
>
> --
> Let's create a highly maintainable and efficient code
>
> YM!: thejavafreak
> Blog: http://www.nagasakti.or.id/roller/joshua/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
"The future is here.  It's just not evenly distributed yet."

     -- Traditional

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


Re: T5: Ajaxify Page with built in Scriptaculous

Posted by Massimo Lusetti <ml...@gmail.com>.
On 6/13/07, Joshua Jackson <jo...@gmail.com> wrote:

> And then process it with prototype inside your html page?

Yep.

> Or do you have any other approach for this?

You may or may not use TextStreamResponse but that pretty much the
same of what i'm using right now

Ciao
-- 
Massimo
http://meridio.blogspot.com

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


Re: T5: Ajaxify Page with built in Scriptaculous

Posted by Joshua Jackson <jo...@gmail.com>.
Hi Massimo

Thanks for the response. How do you exatcly implement the response?

What I assume is that you do something like this:
	public StreamResponse onAction(){
		return new TextStreamResponse("text/xml", "<employees><employee
name=\"joshua\" /></employees>");
	}

And then process it with prototype inside your html page?

Or do you have any other approach for this?

Thanks in advance

On 6/13/07, Massimo Lusetti <ml...@gmail.com> wrote:

> I'm eager to see this implemented but i could say that right now with
> StreamResponse is fairly easy to accomplish this. Thanks to the T5
> flexibility.

-- 
Let's create a highly maintainable and efficient code

YM!: thejavafreak
Blog: http://www.nagasakti.or.id/roller/joshua/

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


Re: T5: Ajaxify Page with built in Scriptaculous

Posted by Massimo Lusetti <ml...@gmail.com>.
On 6/12/07, Howard Lewis Ship <hl...@gmail.com> wrote:

> My plans for Ajax is to introduce a new Dispatcher that recognizes the
> XHR request and handles the response different, rendering a response
> within the same request. What you are seeing is probably the result of
> the ac tion request sending a redirect to the client, then a full page
> of HTML.

I'm eager to see this implemented but i could say that right now with
StreamResponse is fairly easy to accomplish this. Thanks to the T5
flexibility.

-- 
Massimo
http://meridio.blogspot.com

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


Re: T5: Ajaxify Page with built in Scriptaculous

Posted by Howard Lewis Ship <hl...@gmail.com>.
My plans for Ajax is to introduce a new Dispatcher that recognizes the
XHR request and handles the response different, rendering a response
within the same request. What you are seeing is probably the result of
the ac tion request sending a redirect to the client, then a full page
of HTML.

On 6/12/07, Joshua Jackson <jo...@gmail.com> wrote:
> Hi all,
>
> I'm having a rough time to Ajaxify my page with the built in
> scriptaculous in T5. How do I process and display the streaming result
> received from server with the built in scriptaculous bundled with T5?
> Has anyone able to implement scriptaculous on their Page? Can you
> please share it with us here.
>
> Thanks in advance.
>
> --
> Let's create a highly maintainable and efficient code
>
> YM!: thejavafreak
> Blog: http://www.nagasakti.or.id/roller/joshua/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

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