You need to sign in to do that
Don't have an account?
Sabina
Why is apex:form interfering with JSONGenerator?
Hello,
I am trying to display an angularjs table and add some Visualforce + Apex filters to it.
I am creating the JSON string in the Apex controller with
then format it for Visualforce to retrieve it:
In Visualforce I can use angularjs ui-grid using this tableJson without problems
Everything is displaying perfectly.
However, if I add <apex:form> to the page (for the filters), I get this error:
System.JSONGenerator is not serializable.
All I did was to add apex:form to the page, no content inside the form yet.
and it stopped working. Does anyone have an idea why?
Many thanks!
I am trying to display an angularjs table and add some Visualforce + Apex filters to it.
I am creating the JSON string in the Apex controller with
JSONGenerator tableJson = JSON.createGenerator(true); tableJson.writeStartArray(); tableJson.writeStartObject(); tableJson.writeStringField('name', 'value'); // etc tableJson.writeEndObject(); tableJson.writeEndArray();
then format it for Visualforce to retrieve it:
public String getTableJson() { return tableJson.getAsString(); }
In Visualforce I can use angularjs ui-grid using this tableJson without problems
<div ng-app="report"> <div ng-controller="MainCtrl"> <div id="grid1" ui-grid-grouping="true" ui-grid="gridOptions" class="grid"> </div> </div> </div> <script type="text/javascript"> var report = angular.module('report', ['ngTouch', 'ui.grid', 'ui.grid.grouping']); angular.module('report').factory('cellStyle', function(uiGridConstants, $http){ // cfg and $http together at last }); report.controller('MainCtrl', ['$scope', 'uiGridGroupingConstants', function ($scope, uiGridGroupingConstants) { $scope.gridOptions = { data: {!tableJson}, onRegisterApi: function(gridApi) { $scope.gridApi = gridApi; } } }]); </script>
Everything is displaying perfectly.
However, if I add <apex:form> to the page (for the filters), I get this error:
System.JSONGenerator is not serializable.
All I did was to add apex:form to the page, no content inside the form yet.
<apex:form></apex:form> <div ng-app="report"><!-- content here --></div> <script><!-- content here --></script>
and it stopped working. Does anyone have an idea why?
Many thanks!
I marked my JSONGenerator tableJson as transient and it worked!
Leaving this here as that error message didn't return any Google results. Someone else might need it.