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