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

Thomas Frühbeck fruehbeck at aon.at
Sun Feb 9 19:28:44 EST 2014


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

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


More information about the forge-dev mailing list