Synchronizing arbitrary JSF attributes with the client

In the previous chapters of the tutorial you've seen how to synchronize JSF bean attributes with the AngularJS
model. Now we go a step further. You aren't limited to visible attributes when it comes to synchronizing the AngularJS
model with the JSF backend.

The qualified name of the JSF bean. The corresponding Json object in the AngularJS scope has the same name.

direction

(none)

Possible values: clientToServer, serverToClient and both.

Sending JSF beans to the client

To send an arbitrary JSF bean attribute or an entire JSF bean to the client add the attribute "direction" to the <ngsync /> tag. This example is part of
the AngularJS tetris demo. It sends an array of complex objects to the client:

Complex beans

AngularFaces uses a Json serializer to convert beans into JSon objects. Currently Gson and Jackson are supported.

Sometimes using a Json serializer makes for clumsy data structures. For
instance, the playground of the AngularTetris demo is a simple two-dimensional array of integers. However, I had to
chose a much more complicated data structure because AngularJS had difficulties to access the cells in two nested
ng-repeat directives. I suspect I did something wrong, but I also suppose that what feels a natural data structure
in Java doesn't always result in a simple AngularJS model.

A particular nasty problem are arrays and hash maps. Because of Java's type erasure, there's no simple way to
send a table back to the server. Everything's fine until the table grows at the client side. Gson doesn't know the
type of the array, so it can't simply add rows to the table on the server side. AngularFaces 2.1 supports
two-way synchronization, but it's not without limitations.

Sending AngularJS model values to the server

Starting with AngularFaces 2.1, <ngsync /> can send AngularJS models to the server. As mentioned above, Java's type erasure imposes
restrictions when it comes to synchronize tables and hash maps.

Currently, the only way to send values back to the server are input
fields. Of course you can add an <h:inputText> rendered invisible by CSS. The next request automatically sends
values stored in the hidden field back to the server.

Two-way synchronizing

<ngsync /> synchronizes the AngularJS model with the JSF bean on every request. After the request, the AngularJS scope is updated with the
values of the JSF bean (which may have been modified in the meantime).

Synchronizing arbitrary JSF attributes with the client

In the previous chapters of the tutorial you've seen how to synchronize JSF bean attributes with the AngularJS
model. Now we go a step further. You aren't limited to visible attributes when it comes to synchronizing the AngularJS
model with the JSF backend.

The qualified name of the JSF bean. The corresponding Json object in the AngularJS scope has the same name.

direction

(none)

Possible values: clientToServer, serverToClient and both.

Sending JSF beans to the client

To send an arbitrary JSF bean attribute or an entire JSF bean to the client add the attribute "direction" to the <ngsync /> tag. This example is part of
the AngularJS tetris demo. It sends an array of complex objects to the client:

Complex beans

AngularFaces uses a Json serializer to convert beans into JSon objects. Currently Gson and Jackson are supported.

Sometimes using a Json serializer makes for clumsy data structures. For
instance, the playground of the AngularTetris demo is a simple two-dimensional array of integers. However, I had to
chose a much more complicated data structure because AngularJS had difficulties to access the cells in two nested
ng-repeat directives. I suspect I did something wrong, but I also suppose that what feels a natural data structure
in Java doesn't always result in a simple AngularJS model.

A particular nasty problem are arrays and hash maps. Because of Java's type erasure, there's no simple way to
send a table back to the server. Everything's fine until the table grows at the client side. Gson doesn't know the
type of the array, so it can't simply add rows to the table on the server side. AngularFaces 2.1 supports
two-way synchronization, but it's not without limitations.

Sending AngularJS model values to the server

Starting with AngularFaces 2.1, <ngsync /> can send AngularJS models to the server. As mentioned above, Java's type erasure imposes
restrictions when it comes to synchronize tables and hash maps.

Currently, the only way to send values back to the server are input
fields. Of course you can add an <h:inputText> rendered invisible by CSS. The next request automatically sends
values stored in the hidden field back to the server.

Two-way synchronizing

<ngsync /> synchronizes the AngularJS model with the JSF bean on every request. After the request, the AngularJS scope is updated with the
values of the JSF bean (which may have been modified in the meantime).

Synchronizing arbitrary JSF attributes with the client

In the previous chapters of the tutorial you've seen how to synchronize JSF bean attributes with the AngularJS
model. Now we go a step further. You aren't limited to visible attributes when it comes to synchronizing the AngularJS
model with the JSF backend.

The qualified name of the JSF bean. The corresponding Json object in the AngularJS scope has the same name.

direction

(none)

Possible values: clientToServer, serverToClient and both.

Sending JSF beans to the client

To send an arbitrary JSF bean attribute or an entire JSF bean to the client add the attribute "direction" to the <ngsync /> tag. This example is part of
the AngularJS tetris demo. It sends an array of complex objects to the client:

Complex beans

AngularFaces uses a Json serializer to convert beans into JSon objects. Currently Gson and Jackson are supported.

Sometimes using a Json serializer makes for clumsy data structures. For
instance, the playground of the AngularTetris demo is a simple two-dimensional array of integers. However, I had to
chose a much more complicated data structure because AngularJS had difficulties to access the cells in two nested
ng-repeat directives. I suspect I did something wrong, but I also suppose that what feels a natural data structure
in Java doesn't always result in a simple AngularJS model.

A particular nasty problem are arrays and hash maps. Because of Java's type erasure, there's no simple way to
send a table back to the server. Everything's fine until the table grows at the client side. Gson doesn't know the
type of the array, so it can't simply add rows to the table on the server side. AngularFaces 2.1 supports
two-way synchronization, but it's not without limitations.

Sending AngularJS model values to the server

Starting with AngularFaces 2.1, <ngsync /> can send AngularJS models to the server. As mentioned above, Java's type erasure imposes
restrictions when it comes to synchronize tables and hash maps.

Currently, the only way to send values back to the server are input
fields. Of course you can add an <h:inputText> rendered invisible by CSS. The next request automatically sends
values stored in the hidden field back to the server.

Two-way synchronizing

<ngsync /> synchronizes the AngularJS model with the JSF bean on every request. After the request, the AngularJS scope is updated with the
values of the JSF bean (which may have been modified in the meantime).

Synchronizing arbitrary JSF attributes with the client

In the previous chapters of the tutorial you've seen how to synchronize JSF bean attributes with the AngularJS
model. Now we go a step further. You aren't limited to visible attributes when it comes to synchronizing the AngularJS
model with the JSF backend.

The qualified name of the JSF bean. The corresponding Json object in the AngularJS scope has the same name.

direction

(none)

Possible values: clientToServer, serverToClient and both.

Sending JSF beans to the client

To send an arbitrary JSF bean attribute or an entire JSF bean to the client add the attribute "direction" to the <ngsync /> tag. This example is part of
the AngularJS tetris demo. It sends an array of complex objects to the client:

Complex beans

AngularFaces uses a Json serializer to convert beans into JSon objects. Currently Gson and Jackson are supported.

Sometimes using a Json serializer makes for clumsy data structures. For
instance, the playground of the AngularTetris demo is a simple two-dimensional array of integers. However, I had to
chose a much more complicated data structure because AngularJS had difficulties to access the cells in two nested
ng-repeat directives. I suspect I did something wrong, but I also suppose that what feels a natural data structure
in Java doesn't always result in a simple AngularJS model.

A particular nasty problem are arrays and hash maps. Because of Java's type erasure, there's no simple way to
send a table back to the server. Everything's fine until the table grows at the client side. Gson doesn't know the
type of the array, so it can't simply add rows to the table on the server side. AngularFaces 2.1 supports
two-way synchronization, but it's not without limitations.

Sending AngularJS model values to the server

Starting with AngularFaces 2.1, <ngsync /> can send AngularJS models to the server. As mentioned above, Java's type erasure imposes
restrictions when it comes to synchronize tables and hash maps.

Currently, the only way to send values back to the server are input
fields. Of course you can add an <h:inputText> rendered invisible by CSS. The next request automatically sends
values stored in the hidden field back to the server.

Two-way synchronizing

<ngsync /> synchronizes the AngularJS model with the JSF bean on every request. After the request, the AngularJS scope is updated with the
values of the JSF bean (which may have been modified in the meantime).