You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by bjornharvold <bj...@harvold.com> on 2007/05/01 21:42:06 UTC
Tapestry 5 Mixins Remoting JSON
I have a front-end that wants JSON data from the back-end. Using a regular
webapp I would integrate JSON-RPC. I started out doing this with my t5 app
and quickly realized I had to write something to put the jsonrpc bridge in
the session (like a listener) and then some component that would have access
to the session and use the bridge. Then I thought of the mixins, which I
admittedly don't yet fully understand..... but then again I guess it's not
fully implemented either ;-)
How would something like auto-complete and validation be done with t5 using
mixins.... or is it still better to use jsonrpc as I described above? I am
looking at the mixin page and don't really find anything useful there.
thx
bjorn
--
View this message in context: http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10274739
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: Tapestry 5 Mixins Remoting JSON
Posted by Alexandru Dragomir <al...@gmail.com>.
The function rpcFunction() is the async part.
I'm using dojo , so the function looks like :
function rpcFunction() {
var kw = {
url: "${urlFromClass}",
load: function(type, data, evt) {
// do what you want with "data" retrieved from server
side
},
method: "GET",
mimetype:"text/json"
};
dojo.io.bind(kw);
}
Alex
On 5/2/07, Bill Holloway <bi...@gmail.com> wrote:
>
> Also, what do you do with yourUrl once you have it? In addition, the
> JSONRpcClient constructor expects to be talking to a servlet. T5 is a
> ServletFilter.
>
> Bill
>
> On 5/2/07, bjornharvold <bj...@harvold.com> wrote:
> >
> > That's great.... but is this asynchronous?
> >
> >
> > Alexandru Dragomir wrote:
> > >
> > > Yes , you could do like this :
> > >
> > > template:
> > >
> > >
> > >
> > > <script>
> > >
> > > rpcFunction() {
> > > var yourUrl=${urlFromClass}
> > > .....
> > > }
> > > </script>
> > >
> > >
> > > component class :
> > >
> > > @Inject
> > > private ComponentResources resources;
> > >
> > > public String getUrlFromClass() {
> > > return resources.createActionLInk("rpcTrigger",false).toString();
> > > }
> > >
> > > StreamResponse onRpcTrigger() {
> > > //build your json object and wrapp it in a StreamResponse
> > > return streamResponse;
> > > }
> > >
> > > hope i haven't forgot anything.
> > >
> > > Alex
> > >
> > >
> > > On 5/2/07, bjornharvold <bj...@harvold.com> wrote:
> > >>
> > >>
> > >> Sounds interesting. I looked at component events. Are you saying that
> you
> > >> can
> > >> invoke a component action based on a javascript event such as
> > >> "mouseDown"?
> > >> To me it seems that you can only invoke based on a submit action. I
> want
> > >> the
> > >> UI, through AJAX, to talk to some service and get JSON data back. The
> URL
> > >> to
> > >> the json data could be as simple as a link to a jsp that creates the
> json
> > >> data string.
> > >>
> > >> When I meant jsonrpc-bridge I meant the specific open source
> > >> implementation
> > >> here: http://oss.metaparadigm.com/jsonrpc/index.html
> > >>
> > >>
> > >> Alexandru Dragomir wrote:
> > >> >
> > >> > I didn't get what you meant by jsonrpc bridge.
> > >> > The way i do it and it works fine is implementing an "onAction"
> method
> > >> > that
> > >> > returns StreamResponse :
> > >> >
> > >> > StreamResponse onActionFromYourComp() {....}
> > >> >
> > >> > The method returns a json object wrapped by the StreamResponse.
> > >> > Mixins are useful when you want to add new ajax behavior to already
> > >> > existent
> > >> > "non ajax" aware components(if i'm not wrong.. ).
> > >> >
> > >> > hope it helps,
> > >> > Alex
> > >> >
> > >> >
> > >> > On 5/1/07, bjornharvold <bj...@harvold.com> wrote:
> > >> >>
> > >> >>
> > >> >> I have a front-end that wants JSON data from the back-end. Using a
> > >> >> regular
> > >> >> webapp I would integrate JSON-RPC. I started out doing this with
> my t5
> > >> >> app
> > >> >> and quickly realized I had to write something to put the jsonrpc
> > >> bridge
> > >> >> in
> > >> >> the session (like a listener) and then some component that would
> have
> > >> >> access
> > >> >> to the session and use the bridge. Then I thought of the mixins,
> which
> > >> I
> > >> >> admittedly don't yet fully understand..... but then again I guess
> it's
> > >> >> not
> > >> >> fully implemented either ;-)
> > >> >>
> > >> >> How would something like auto-complete and validation be done with
> t5
> > >> >> using
> > >> >> mixins.... or is it still better to use jsonrpc as I described
> above?
> > >> I
> > >> >> am
> > >> >> looking at the mixin page and don't really find anything useful
> there.
> > >> >>
> > >> >> thx
> > >> >> bjorn
> > >> >> --
> > >> >> View this message in context:
> > >> >>
> > >>
> http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10274739
> > >> >> 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
> > >> >>
> > >> >>
> > >> >
> > >> >
> > >>
> > >> --
> > >> View this message in context:
> > >>
> http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10291531
> > >> 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
> > >>
> > >>
> > >
> > >
> >
> > --
> > View this message in context:
> http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10293059
> > 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
> >
> >
>
>
> --
> "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: Tapestry 5 Mixins Remoting JSON
Posted by Bill Holloway <bi...@gmail.com>.
Also, what do you do with yourUrl once you have it? In addition, the
JSONRpcClient constructor expects to be talking to a servlet. T5 is a
ServletFilter.
Bill
On 5/2/07, bjornharvold <bj...@harvold.com> wrote:
>
> That's great.... but is this asynchronous?
>
>
> Alexandru Dragomir wrote:
> >
> > Yes , you could do like this :
> >
> > template:
> >
> >
> >
> > <script>
> >
> > rpcFunction() {
> > var yourUrl=${urlFromClass}
> > .....
> > }
> > </script>
> >
> >
> > component class :
> >
> > @Inject
> > private ComponentResources resources;
> >
> > public String getUrlFromClass() {
> > return resources.createActionLInk("rpcTrigger",false).toString();
> > }
> >
> > StreamResponse onRpcTrigger() {
> > //build your json object and wrapp it in a StreamResponse
> > return streamResponse;
> > }
> >
> > hope i haven't forgot anything.
> >
> > Alex
> >
> >
> > On 5/2/07, bjornharvold <bj...@harvold.com> wrote:
> >>
> >>
> >> Sounds interesting. I looked at component events. Are you saying that you
> >> can
> >> invoke a component action based on a javascript event such as
> >> "mouseDown"?
> >> To me it seems that you can only invoke based on a submit action. I want
> >> the
> >> UI, through AJAX, to talk to some service and get JSON data back. The URL
> >> to
> >> the json data could be as simple as a link to a jsp that creates the json
> >> data string.
> >>
> >> When I meant jsonrpc-bridge I meant the specific open source
> >> implementation
> >> here: http://oss.metaparadigm.com/jsonrpc/index.html
> >>
> >>
> >> Alexandru Dragomir wrote:
> >> >
> >> > I didn't get what you meant by jsonrpc bridge.
> >> > The way i do it and it works fine is implementing an "onAction" method
> >> > that
> >> > returns StreamResponse :
> >> >
> >> > StreamResponse onActionFromYourComp() {....}
> >> >
> >> > The method returns a json object wrapped by the StreamResponse.
> >> > Mixins are useful when you want to add new ajax behavior to already
> >> > existent
> >> > "non ajax" aware components(if i'm not wrong.. ).
> >> >
> >> > hope it helps,
> >> > Alex
> >> >
> >> >
> >> > On 5/1/07, bjornharvold <bj...@harvold.com> wrote:
> >> >>
> >> >>
> >> >> I have a front-end that wants JSON data from the back-end. Using a
> >> >> regular
> >> >> webapp I would integrate JSON-RPC. I started out doing this with my t5
> >> >> app
> >> >> and quickly realized I had to write something to put the jsonrpc
> >> bridge
> >> >> in
> >> >> the session (like a listener) and then some component that would have
> >> >> access
> >> >> to the session and use the bridge. Then I thought of the mixins, which
> >> I
> >> >> admittedly don't yet fully understand..... but then again I guess it's
> >> >> not
> >> >> fully implemented either ;-)
> >> >>
> >> >> How would something like auto-complete and validation be done with t5
> >> >> using
> >> >> mixins.... or is it still better to use jsonrpc as I described above?
> >> I
> >> >> am
> >> >> looking at the mixin page and don't really find anything useful there.
> >> >>
> >> >> thx
> >> >> bjorn
> >> >> --
> >> >> View this message in context:
> >> >>
> >> http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10274739
> >> >> 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
> >> >>
> >> >>
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10291531
> >> 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
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10293059
> 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
>
>
--
"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: Tapestry 5 Mixins Remoting JSON
Posted by bjornharvold <bj...@harvold.com>.
That's great.... but is this asynchronous? Oh yes, so I just plug in that url
into my ajax call and off i go.
Alexandru Dragomir wrote:
>
> Yes , you could do like this :
>
> template:
>
>
>
> <script>
>
> rpcFunction() {
> var yourUrl=${urlFromClass}
> .....
> }
> </script>
>
>
> component class :
>
> @Inject
> private ComponentResources resources;
>
> public String getUrlFromClass() {
> return resources.createActionLInk("rpcTrigger",false).toString();
> }
>
> StreamResponse onRpcTrigger() {
> //build your json object and wrapp it in a StreamResponse
> return streamResponse;
> }
>
> hope i haven't forgot anything.
>
> Alex
>
>
> On 5/2/07, bjornharvold <bj...@harvold.com> wrote:
>>
>>
>> Sounds interesting. I looked at component events. Are you saying that you
>> can
>> invoke a component action based on a javascript event such as
>> "mouseDown"?
>> To me it seems that you can only invoke based on a submit action. I want
>> the
>> UI, through AJAX, to talk to some service and get JSON data back. The URL
>> to
>> the json data could be as simple as a link to a jsp that creates the json
>> data string.
>>
>> When I meant jsonrpc-bridge I meant the specific open source
>> implementation
>> here: http://oss.metaparadigm.com/jsonrpc/index.html
>>
>>
>> Alexandru Dragomir wrote:
>> >
>> > I didn't get what you meant by jsonrpc bridge.
>> > The way i do it and it works fine is implementing an "onAction" method
>> > that
>> > returns StreamResponse :
>> >
>> > StreamResponse onActionFromYourComp() {....}
>> >
>> > The method returns a json object wrapped by the StreamResponse.
>> > Mixins are useful when you want to add new ajax behavior to already
>> > existent
>> > "non ajax" aware components(if i'm not wrong.. ).
>> >
>> > hope it helps,
>> > Alex
>> >
>> >
>> > On 5/1/07, bjornharvold <bj...@harvold.com> wrote:
>> >>
>> >>
>> >> I have a front-end that wants JSON data from the back-end. Using a
>> >> regular
>> >> webapp I would integrate JSON-RPC. I started out doing this with my t5
>> >> app
>> >> and quickly realized I had to write something to put the jsonrpc
>> bridge
>> >> in
>> >> the session (like a listener) and then some component that would have
>> >> access
>> >> to the session and use the bridge. Then I thought of the mixins, which
>> I
>> >> admittedly don't yet fully understand..... but then again I guess it's
>> >> not
>> >> fully implemented either ;-)
>> >>
>> >> How would something like auto-complete and validation be done with t5
>> >> using
>> >> mixins.... or is it still better to use jsonrpc as I described above?
>> I
>> >> am
>> >> looking at the mixin page and don't really find anything useful there.
>> >>
>> >> thx
>> >> bjorn
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10274739
>> >> 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
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10291531
>> 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
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10293059
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: Tapestry 5 Mixins Remoting JSON
Posted by bjornharvold <bj...@harvold.com>.
That's great.... but is this asynchronous?
Alexandru Dragomir wrote:
>
> Yes , you could do like this :
>
> template:
>
>
>
> <script>
>
> rpcFunction() {
> var yourUrl=${urlFromClass}
> .....
> }
> </script>
>
>
> component class :
>
> @Inject
> private ComponentResources resources;
>
> public String getUrlFromClass() {
> return resources.createActionLInk("rpcTrigger",false).toString();
> }
>
> StreamResponse onRpcTrigger() {
> //build your json object and wrapp it in a StreamResponse
> return streamResponse;
> }
>
> hope i haven't forgot anything.
>
> Alex
>
>
> On 5/2/07, bjornharvold <bj...@harvold.com> wrote:
>>
>>
>> Sounds interesting. I looked at component events. Are you saying that you
>> can
>> invoke a component action based on a javascript event such as
>> "mouseDown"?
>> To me it seems that you can only invoke based on a submit action. I want
>> the
>> UI, through AJAX, to talk to some service and get JSON data back. The URL
>> to
>> the json data could be as simple as a link to a jsp that creates the json
>> data string.
>>
>> When I meant jsonrpc-bridge I meant the specific open source
>> implementation
>> here: http://oss.metaparadigm.com/jsonrpc/index.html
>>
>>
>> Alexandru Dragomir wrote:
>> >
>> > I didn't get what you meant by jsonrpc bridge.
>> > The way i do it and it works fine is implementing an "onAction" method
>> > that
>> > returns StreamResponse :
>> >
>> > StreamResponse onActionFromYourComp() {....}
>> >
>> > The method returns a json object wrapped by the StreamResponse.
>> > Mixins are useful when you want to add new ajax behavior to already
>> > existent
>> > "non ajax" aware components(if i'm not wrong.. ).
>> >
>> > hope it helps,
>> > Alex
>> >
>> >
>> > On 5/1/07, bjornharvold <bj...@harvold.com> wrote:
>> >>
>> >>
>> >> I have a front-end that wants JSON data from the back-end. Using a
>> >> regular
>> >> webapp I would integrate JSON-RPC. I started out doing this with my t5
>> >> app
>> >> and quickly realized I had to write something to put the jsonrpc
>> bridge
>> >> in
>> >> the session (like a listener) and then some component that would have
>> >> access
>> >> to the session and use the bridge. Then I thought of the mixins, which
>> I
>> >> admittedly don't yet fully understand..... but then again I guess it's
>> >> not
>> >> fully implemented either ;-)
>> >>
>> >> How would something like auto-complete and validation be done with t5
>> >> using
>> >> mixins.... or is it still better to use jsonrpc as I described above?
>> I
>> >> am
>> >> looking at the mixin page and don't really find anything useful there.
>> >>
>> >> thx
>> >> bjorn
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10274739
>> >> 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
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10291531
>> 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
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10293059
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: Tapestry 5 Mixins Remoting JSON
Posted by Andreas Andreou <an...@di.uoa.gr>.
Better have getUrlFromClass generate a url for a {0} parameter (insted of
jsmith)
then (at runtime) have javascript that replaces {0} with whatever value you
want.
On 5/8/07, bjornharvold <bj...@harvold.com> wrote:
>
>
> Thank you for the lightning response!
>
> the parameter "jsmith" is of course the runtime text the user enters as
> his
> username so there is no way for me to hard code that into the
> getUrlFromClass method. Javascript is the only thing that knows what the
> username is at the time of checking. Can I use the getUrlFromClass, as
> described before, have it generate the url on my template and then have
> javascript append jsmith to the url?
>
> So url I get from tapestry component:
> var url = ${urlFromClass}
>
> At runtime:
> var url = ${urlFromClass} + "/" + username;
>
> Would that work? And what can the method rpcTrigger expect as incoming
> parameter for username?
>
> thanks in advance
> bjorn
> --
> View this message in context:
> http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10379890
> 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
>
>
--
Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
Tapestry / Tacos developer
Open Source / JEE Consulting
Re: Tapestry 5 Mixins Remoting JSON
Posted by bjornharvold <bj...@harvold.com>.
Thank you for the lightning response!
the parameter "jsmith" is of course the runtime text the user enters as his
username so there is no way for me to hard code that into the
getUrlFromClass method. Javascript is the only thing that knows what the
username is at the time of checking. Can I use the getUrlFromClass, as
described before, have it generate the url on my template and then have
javascript append jsmith to the url?
So url I get from tapestry component:
var url = ${urlFromClass}
At runtime:
var url = ${urlFromClass} + "/" + username;
Would that work? And what can the method rpcTrigger expect as incoming
parameter for username?
thanks in advance
bjorn
--
View this message in context: http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10379890
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: Tapestry 5 Mixins Remoting JSON
Posted by bjornharvold <bj...@harvold.com>.
WORKS GREAT!
:-D
--
View this message in context: http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10384351
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: Tapestry 5 Mixins Remoting JSON
Posted by Andreas Andreou <an...@di.uoa.gr>.
Just a small comment on this and a quick way to make it more elegant -
make it generate
href="yourlink/parameter1/parameter2" onclick="rpcFunction(this.href);retrurn
false"
On 5/8/07, Alexandru Dragomir <al...@gmail.com> wrote:
>
> The parameters should be in the "urlFromClass" above.
>
> So you could have it like this :
>
> public String getUrlFromClass() {
> return resources.createActionLink
> ("rpcTrigger",false,"jsmith").toString();
>
> }
>
> In my workspace i made a dirty ajax version of actionLink which generates
> as href attribute this :
>
> href="javascript:rpcFunction('yourlink/parameter1/parameter2')"
>
> instead of
>
> href="yourlink/parameter1/parameter2"
>
> So , the parameters should be passed in the same way you do it for
> ActionLink component(and you have 2 options : use the actionLink
> component
> or build the link in your class as shown above). The only difference is
> that
> there is a javascript function that does the request.
>
> Alex
>
>
> On 5/8/07, bjornharvold <bj...@harvold.com> wrote:
> >
> >
> > Alexandru,
> >
> > How could you add runtime parameters to this Ajax call? e.g. you want to
> > call isUsernameAvailable with parameter "jsmith"?
> >
> > Thanks
> > bjorn
> > --
> > View this message in context:
> >
> http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10378474
> > 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
> >
> >
>
--
Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
Tapestry / Tacos developer
Open Source / JEE Consulting
Re: Tapestry 5 Mixins Remoting JSON
Posted by Alexandru Dragomir <al...@gmail.com>.
The parameters should be in the "urlFromClass" above.
So you could have it like this :
public String getUrlFromClass() {
return resources.createActionLink("rpcTrigger",false,"jsmith").toString();
}
In my workspace i made a dirty ajax version of actionLink which generates
as href attribute this :
href="javascript:rpcFunction('yourlink/parameter1/parameter2')"
instead of
href="yourlink/parameter1/parameter2"
So , the parameters should be passed in the same way you do it for
ActionLink component(and you have 2 options : use the actionLink component
or build the link in your class as shown above). The only difference is that
there is a javascript function that does the request.
Alex
On 5/8/07, bjornharvold <bj...@harvold.com> wrote:
>
>
> Alexandru,
>
> How could you add runtime parameters to this Ajax call? e.g. you want to
> call isUsernameAvailable with parameter "jsmith"?
>
> Thanks
> bjorn
> --
> View this message in context:
> http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10378474
> 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: Tapestry 5 Mixins Remoting JSON
Posted by bjornharvold <bj...@harvold.com>.
Alexandru,
How could you add runtime parameters to this Ajax call? e.g. you want to
call isUsernameAvailable with parameter "jsmith"?
Thanks
bjorn
--
View this message in context: http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10378474
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: Tapestry 5 Mixins Remoting JSON
Posted by Alexandru Dragomir <al...@gmail.com>.
Yes , you could do like this :
template:
<span id="test" onclick="rpcFunction();"/>
<script>
rpcFunction() {
var yourUrl=${urlFromClass}
.....
}
</script>
component class :
@Inject
private ComponentResources resources;
public String getUrlFromClass() {
return resources.createActionLInk("rpcTrigger",false).toString();
}
StreamResponse onRpcTrigger() {
//build your json object and wrapp it in a StreamResponse
return streamResponse;
}
hope i haven't forgot anything.
Alex
On 5/2/07, bjornharvold <bj...@harvold.com> wrote:
>
>
> Sounds interesting. I looked at component events. Are you saying that you
> can
> invoke a component action based on a javascript event such as "mouseDown"?
> To me it seems that you can only invoke based on a submit action. I want
> the
> UI, through AJAX, to talk to some service and get JSON data back. The URL
> to
> the json data could be as simple as a link to a jsp that creates the json
> data string.
>
> When I meant jsonrpc-bridge I meant the specific open source
> implementation
> here: http://oss.metaparadigm.com/jsonrpc/index.html
>
>
> Alexandru Dragomir wrote:
> >
> > I didn't get what you meant by jsonrpc bridge.
> > The way i do it and it works fine is implementing an "onAction" method
> > that
> > returns StreamResponse :
> >
> > StreamResponse onActionFromYourComp() {....}
> >
> > The method returns a json object wrapped by the StreamResponse.
> > Mixins are useful when you want to add new ajax behavior to already
> > existent
> > "non ajax" aware components(if i'm not wrong.. ).
> >
> > hope it helps,
> > Alex
> >
> >
> > On 5/1/07, bjornharvold <bj...@harvold.com> wrote:
> >>
> >>
> >> I have a front-end that wants JSON data from the back-end. Using a
> >> regular
> >> webapp I would integrate JSON-RPC. I started out doing this with my t5
> >> app
> >> and quickly realized I had to write something to put the jsonrpc bridge
> >> in
> >> the session (like a listener) and then some component that would have
> >> access
> >> to the session and use the bridge. Then I thought of the mixins, which
> I
> >> admittedly don't yet fully understand..... but then again I guess it's
> >> not
> >> fully implemented either ;-)
> >>
> >> How would something like auto-complete and validation be done with t5
> >> using
> >> mixins.... or is it still better to use jsonrpc as I described above? I
> >> am
> >> looking at the mixin page and don't really find anything useful there.
> >>
> >> thx
> >> bjorn
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10274739
> >> 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
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10291531
> 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: Tapestry 5 Mixins Remoting JSON
Posted by bjornharvold <bj...@harvold.com>.
Sounds interesting. I looked at component events. Are you saying that you can
invoke a component action based on a javascript event such as "mouseDown"?
To me it seems that you can only invoke based on a submit action. I want the
UI, through AJAX, to talk to some service and get JSON data back. The URL to
the json data could be as simple as a link to a jsp that creates the json
data string.
When I meant jsonrpc-bridge I meant the specific open source implementation
here: http://oss.metaparadigm.com/jsonrpc/index.html
Alexandru Dragomir wrote:
>
> I didn't get what you meant by jsonrpc bridge.
> The way i do it and it works fine is implementing an "onAction" method
> that
> returns StreamResponse :
>
> StreamResponse onActionFromYourComp() {....}
>
> The method returns a json object wrapped by the StreamResponse.
> Mixins are useful when you want to add new ajax behavior to already
> existent
> "non ajax" aware components(if i'm not wrong.. ).
>
> hope it helps,
> Alex
>
>
> On 5/1/07, bjornharvold <bj...@harvold.com> wrote:
>>
>>
>> I have a front-end that wants JSON data from the back-end. Using a
>> regular
>> webapp I would integrate JSON-RPC. I started out doing this with my t5
>> app
>> and quickly realized I had to write something to put the jsonrpc bridge
>> in
>> the session (like a listener) and then some component that would have
>> access
>> to the session and use the bridge. Then I thought of the mixins, which I
>> admittedly don't yet fully understand..... but then again I guess it's
>> not
>> fully implemented either ;-)
>>
>> How would something like auto-complete and validation be done with t5
>> using
>> mixins.... or is it still better to use jsonrpc as I described above? I
>> am
>> looking at the mixin page and don't really find anything useful there.
>>
>> thx
>> bjorn
>> --
>> View this message in context:
>> http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10274739
>> 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
>>
>>
>
>
--
View this message in context: http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10291531
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: Tapestry 5 Mixins Remoting JSON
Posted by Alexandru Dragomir <al...@gmail.com>.
I didn't get what you meant by jsonrpc bridge.
The way i do it and it works fine is implementing an "onAction" method that
returns StreamResponse :
StreamResponse onActionFromYourComp() {....}
The method returns a json object wrapped by the StreamResponse.
Mixins are useful when you want to add new ajax behavior to already existent
"non ajax" aware components(if i'm not wrong.. ).
hope it helps,
Alex
On 5/1/07, bjornharvold <bj...@harvold.com> wrote:
>
>
> I have a front-end that wants JSON data from the back-end. Using a regular
> webapp I would integrate JSON-RPC. I started out doing this with my t5 app
> and quickly realized I had to write something to put the jsonrpc bridge in
> the session (like a listener) and then some component that would have
> access
> to the session and use the bridge. Then I thought of the mixins, which I
> admittedly don't yet fully understand..... but then again I guess it's not
> fully implemented either ;-)
>
> How would something like auto-complete and validation be done with t5
> using
> mixins.... or is it still better to use jsonrpc as I described above? I am
> looking at the mixin page and don't really find anything useful there.
>
> thx
> bjorn
> --
> View this message in context:
> http://www.nabble.com/Tapestry-5-Mixins-Remoting-JSON-tf3676880.html#a10274739
> 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
>
>