[forge-dev] angular scaffold: parent/child relationship issues

Sebastien Blanc sblanc at redhat.com
Mon Feb 10 01:31:41 EST 2014


On 02/10/2014 01:28 AM, Thomas Frühbeck wrote:
> Hi,
> I wanted to work with AngularJS scaffold in Forge and ask for your help.
>
> With Forge2, I did not find the way to install the angularjs-scaffold-x
> as addon/plugin.
> Is there some guidance available on how to use oldstyle plugins as addons?
>
> Stepping back to Forge 1.4 I successfully created a simple parent/child
> application.
> On deployment on Wildfly 8.0.0 CR1 I found following issues:
>
> Setup: I created a parent and then a child, the child referencing the
> parent.
>
> Issue 1:
>    - w/o any modifications I got a StackOverflowError in
> org.codehaus.jackson.map.ser.BeanSerializer because infinite loop
> between parent/child
Hey ! Vineet will certainly give you the right answer but  which 
strategy option did you use to generate your REST endpoint ? You have to 
make sure to use "--strategy ROOT_AND_NESTED_DTO" this way your 
relations will be managed well.
i.e : "

|rest endpoint-from-entity --contentType application/json org.jboss.aerogear.judconcricket.model.* --strategy ROOT_AND_NESTED_DTO

|

>
> My solution was to:
>      - import org.codehaus.jackson/jackson-jaxrs maven dependency
> (because this is, what Wildfly seems to use per default)
>      - add @JsonManagedReference/@JsonBackReference on the
> parent.children and child.parent properties resp.
>
> Is there some simpler/more obvious fix for the problem?
>
> In Fasterxml Jackson 2.x there is a @JsonIdentityInfo, could this be a
> way to solve the issue?
> I seem to be unable to activate Fasterxml.Jackson on Wildfly :-/
>
> Issue 2:
>    - by above @JsonBackReference the child.parent property was not
> serialized and so the reference did not show up as selected in the
> parents <select> options
>
> My solution was to rewrite the EditChildController to check for
> parent.id from the parents side (because child.parent is empty):
>
>                       for (var idx=0; idx < item.children.length; idx++) {
>                           if (item.children[idx].id === $scope.child.id) {
>                               $scope.parentSelection = labelObject;
>                               $scope.child.parent = wrappedObject;
>                           }
>                       }
>
> Original code:
>                       if($scope.child.parent && item.id ==
> $scope.child.parent.id) {
>                           $scope.parentSelection = labelObject;
>                           $scope.child.parent = wrappedObject;
>                           self.original.parent = $scope.child.parent;
>                       }
>
> Again I ask for your expertise, if this is a problem I introduced by
> misusing @JsonBackReference or if this needs a fix in the scaffold.
>
> Thank you for your great work on Forge and this incredible AngularJS
> plugin :-)
>
> Thomas
> _______________________________________________
> forge-dev mailing list
> forge-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/forge-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/forge-dev/attachments/20140210/03fb8f4d/attachment.html 


More information about the forge-dev mailing list