Hi,

Thanks for the prompt reply, I'll have a look at the Struts2 AngularJS
archetype
But I meant AngularJS interceptor (
https://docs.angularjs.org/api/ng/service/$http) which is still client
side, AngularJS interceptor is meant to intercept {name:"abc",address:"abc"}
and change it to {customer:{name:"abc",address:"abc"}}

I'm looking at the source code for the REST plugin, looks like the magic
happens in ContentTypeInterceptor, this gets the payload from http
inputstream then maps it to the action. If I want to use
{name:"abc",address:"abc"},
looks like I have to use @ModelDriven ?

Is it fine to just use REST plugin's ContentTypeInterceptor and the
JsonLibHandler and include them in my web application ?
i.e. are they fairly standalone-ish ? or do they have dependencies with
other components in the REST plugin ?



On Wed, Nov 19, 2014 at 4:59 PM, Lukasz Lenart <lukaszlen...@apache.org>
wrote:

> 2014-11-19 9:51 GMT+01:00 foo bar <linut...@gmail.com>:
> > Hi guys,
> >
> > I'm currently looking into ease of development of using AngularJS with
> > Struts2.
> > I'm wondering what is the best practice in general
> > ie. AngularJS with $resource or $http, Struts2 with what plugin ?
> > Is the REST + convention plugin a must to support AngularJS's RESTful
> > nature ?
> >
> > I'm currently using Struts2 with no REST plugin and notice that if I do
> > something like this
> >
> > CustomerService.save($scope.newCustomer);
> >
> > In Chrome's Developer tools, Content-Type:application/json;charset=UTF-8
> > and data is a JSON string but it's in the Request Payload
> > Normally it's Content-Type:application/x-www-form-urlencoded and data is
> in
> > Form Data
> >
> > I have
> >
> > private Customer customer;
> >
> > in my Action class and the approriate getter and setter, but they are not
> > called by the framework
> > I understand that I can get the data via http request's inputstream, but
> > then I have to transfer the data to my Customer object manually (I use
> > Gson) and I think that will bypass all my interceptors, especially
> > validation.
> >
> > Did a bit of research on the internet and it seems that using the REST
> > plugin should work, but it needs a bit of modification on the AngularJS
> > part ($http interceptor ?)
> >
> > Struts2 won't populate my Customer object with this (which is normal
> plain
> > AngularJS)
> >
> > {name:"abc",address:"abc"}
> >
> > Have to change to
> >
> > {customer:{name:"abc",address:"abc"}}
>
> Maybe start with Struts AngularJS archetype first? Because it looks
> like I you're mixing things - client side ($http) and server side
> (interceptor)
>
>
> http://struts.apache.org/release/2.3.x/docs/struts-2-maven-archetypes.html#Struts2MavenArchetypes-TheAngularJSArchetype(struts2-archetype-angularjs)
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

Reply via email to