I'm in the exact same situation, but I'm having problems getting the Json
interceptor to work - my config can't find the interceptor. Result type
"json" works fine, so I thought it should be available. Could you give an
example of your config so that I can check if I'm missing something obvious?

Regards
Peter

On Fri, Nov 21, 2014 at 8:56 AM, foo bar <linut...@gmail.com> wrote:

> Hi Lukasz,
>
> Yes indeed, JSON plugin is all I need, thanks !
>
> In case anyone else experiencing the same issue, this is what I did
>
> In AngularJS
>
> CustomerService.save({customer:$scope.newCustomer});
>
> You could also do
>
> $http.post('customer/add',
> {customer:$scope.newCustomer}).success().error();
>
> AngularJS will send this to the server
>
> Content-Type:application/json;charset=UTF-8
> Request Payload:{"customer":{"name":"abc","address":"abc"}}
>
> JSON interceptor intercepts, reads data from http request inputstream,
> populates Customer object in my action class
> Action returns "show"
>
> <result name="show" type="json"><param
> name="root">customer</param></result>
>
> Response is {"id":1,"name":"abc","address":"abc"}
>
> Response is read by AngularJS
>
> If you specify <result name="show" type="json"></result>, then response
> will have all your objects that have getters in your action
>
> On Thu, Nov 20, 2014 at 4:16 PM, Lukasz Lenart <lukaszlen...@apache.org>
> wrote:
>
> > 2014-11-19 11:20 GMT+01:00 foo bar <linut...@gmail.com>:
> > > 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 ?
> >
> > Yes if you want to expose customer entity and not action's properties
> > (name and address)
> >
> > > 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 ?
> >
> > Maybe JSON plugin is all you need? Then action can simply return and
> > accept JSON (there is an interceptor that do all the magic)
> >
> >
> > 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
> >
> >
>



-- 
PETER BJÖRKMAN - CTO / SYSTEMS ARCHITECT
josh / together is better / www.josh.se
gävlegatan 12b / 113 30 stockholm / sweden
phone +46 709 687 884 / skype peter_josh

Reply via email to