Angular Material setup with BrowserAnimationsModule for Angular 4.4.6 app - angular-material

I am trying to get angular material working in my angular 4.4.6 app but get an error message in the browser when I try to import the BrowserAnimationsModule.
import { BrowserModule } from '#angular/platform-browser';
import { BrowserAnimationsModule } from '#angular/platform-browser/animations';
imports: [
CommonModule,
HttpModule,
FormsModule,
AngularFontAwesomeModule,
BrowserModule,
BrowserAnimationsModule,
RouterModule.forRoot([
{ path: 'register', component: RegisterComponent },
{ path: 'login', component: LoginComponent },
{ path: 'member-detail/:id', component: MemberDetailComponent },
{ path: 'member-listing', component: MemberListingComponent },
package.json
"dependencies": {
"#angular/animations": "^4.4.6",
"#angular/cdk": "^2.0.0-beta.12",
"#angular/common": "^4.4.6",
"#angular/compiler": "^4.4.6",
"#angular/compiler-cli": "^4.4.6",
"#angular/core": "^4.4.6",
"#angular/forms": "^4.4.6",
"#angular/http": "^4.4.6",
"#angular/material": "^2.0.0-beta.12",
"#angular/platform-browser": "^4.4.6",
"#angular/platform-browser-dynamic": "^4.4.6",
"#angular/platform-server": "^4.4.6",
Error message in browser:
An unhandled exception occurred while processing the request.
NodeInvocationException: document is not defined
ReferenceError: document is not defined
at DefaultDomRenderer2.module.exports.DefaultDomRenderer2.selectRootElement (C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:28722:72)
at BaseAnimationRenderer.selectRootElement (C:\Code\winowio_core\winowio_core\Client\dist\main-server.js:19174:106)
at createElement (C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:20127:23)
at createViewNodes (C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:23093:44)
at createRootView (C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:23022:5)
at Object.createProdRootView [as createRootView] (C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:23707:12)
at ComponentFactory_.module.exports.ComponentFactory_.create (C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:20813:46)
at ComponentFactoryBoundToModule.module.exports.ComponentFactoryBoundToModule.create (C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:14230:29)
at ApplicationRef_.module.exports.ApplicationRef_.bootstrap (C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:15719:57)
at C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:15502:81
Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance+d__7.MoveNext()
Stack Query Cookies Headers
NodeInvocationException: document is not defined
ReferenceError: document is not defined at DefaultDomRenderer2.module.exports.DefaultDomRenderer2.selectRootElement (C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:28722:72) at BaseAnimationRenderer.selectRootElement (C:\Code\winowio_core\winowio_core\Client\dist\main-server.js:19174:106) at createElement (C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:20127:23) at createViewNodes (C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:23093:44) at createRootView (C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:23022:5) at Object.createProdRootView [as createRootView] (C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:23707:12) at ComponentFactory_.module.exports.ComponentFactory_.create (C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:20813:46) at ComponentFactoryBoundToModule.module.exports.ComponentFactoryBoundToModule.create (C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:14230:29) at ApplicationRef_.module.exports.ApplicationRef_.bootstrap (C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:15719:57) at C:\Code\winowio_core\winowio_core\Client\dist\vendor.js:15502:81
Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance+d__7.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance+d__13.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Microsoft.AspNetCore.NodeServices.NodeServicesImpl+d__10.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Microsoft.AspNetCore.NodeServices.NodeServicesImpl+d__10.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Microsoft.AspNetCore.NodeServices.NodeServicesImpl+d__10.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper+d__29.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner+d__0.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
AspNetCore._Views_Home_Index_cshtml+d__12.MoveNext() in Index.cshtml
+
ViewData["Title"] = "Home Page";
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Razor.RazorView+d__16.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Razor.RazorView+d__15.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Microsoft.AspNetCore.Mvc.Razor.RazorView+d__14.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor+d__22.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor+d__21.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.ViewResult+d__26.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d__19.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d__24.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d__22.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d__17.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+d__15.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Builder.RouterMiddleware+d__4.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware+d__6.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.SpaServices.Webpack.ConditionalProxyMiddleware+d__6.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.SpaServices.Webpack.ConditionalProxyMiddleware+d__6.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware+d__7.MoveNext()

Ok, I came to this same exact issue.
Go to Views->Home->Index.cshtml and change
<app asp-prerender-module="ClientApp/dist/main-server">Loading...</app>
to:
<app asp-ng2-prerender-module="ClientApp/dist/main-server">Loading...</app>
Here is another stackoverflow question that's related.

Related

Running in docker receive "The 'ClientId' option must be provided"

ASP.NET with Microsoft-identity-web. If run webapp locally using dotnet app.dll everything is ok, but if package into an image and run in docker or kubernetes, each request will occur error:
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
An unhandled exception has occurred while executing the request.
System.ArgumentNullException: IDW10106: The 'ClientId' option must be provided.
at Microsoft.Identity.Web.MergedOptionsValidation.Validate(MergedOptions options)
at Microsoft.Identity.Web.MicrosoftIdentityWebAppAuthenticationBuilderExtensions.<>c__DisplayClass5_0.<AddMicrosoftIdentityWebAppInternal>b__3(OpenIdConnectOptions options, IServiceProvider serviceProvider, IOptionsMonitor'1 mergedOptionsMonitor, IOptionsMonitor'1 msIdOptionsMonitor, IOptions'1 msIdOptions)
at Microsoft.Extensions.Options.ConfigureNamedOptions'5.Configure(String name, TOptions options)
at Microsoft.Extensions.Options.OptionsFactory'1.Create(String name)
at Microsoft.Extensions.Options.OptionsMonitor'1.<>c__DisplayClass10_0.<Get>b__0()
at System.Lazy'1.ViaFactory(LazyThreadSafetyMode mode)
--- End of stack trace from previous location ---
at System.Lazy'1.CreateValue()
at Microsoft.AspNetCore.Authentication.AuthenticationHandler'1.InitializeAsync(AuthenticationScheme scheme, HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationHandlerProvider.GetHandlerAsync(HttpContext context, String authenticationScheme)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
appsettings.json:
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "xxx",
"TenantId": "xxx",
"ClientId": "xxx",
"CallbackPath": "/signin-oidc",
"ClientSecret": "xxx",
"ClientCertificates": []
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"MicrosoftGraph": {
"BaseUrl": "https://graph.microsoft.com/v1.0",
"Scopes": "user.read"
}
}
Dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:6.0
COPY ./apprelease /home/app

Cannot install dockprom

I am trying to install dockprom(https://github.com/stefanprodan/dockprom). I follow the stepsgiven by them but I am getting this errors:
ERROR: for caddy Cannot create container for service caddy: status
code not OK but 500: {"Message":"Unhandled exception: Filesharing has
been cancelled","StackTrace":" en
Docker.ApiServices.Mounting.FileSharing.d__6.MoveNext() en
C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.ApiServices\Mounting\FileSharing.cs:lĂ­nea
0\r\n--- Fin del seguimiento de la pila de la ubicaciĂłn anterior
donde se produjo la excepciĂłn ---\r\n en
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n en
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n en Docker.ApiServices.Mounting.FileSharing.d__4.MoveNext()
en
C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.ApiServices\Mounting\FileSharing.cs:lĂ­nea
47\r\n--- Fin del seguimiento de la pila de la ubicaciĂłn anterior
donde se produjo la excepciĂłn ---\r\n en
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n en
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n en
Docker.HttpApi.Controllers.FilesharingController.d__2.MoveNext() en
C:\workspaces\stable-2.3.x\src\github.com\docker\pinata\win\src\Docker.HttpApi\Controllers\FilesharingController.cs:lĂ­nea
21\r\n--- Fin del seguimiento de la pila de la ubicaciĂłn anterior
donde se produjo la excepciĂłn ---\r\n en
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n en
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n en
System.Threading.Tasks.TaskHelpersExtensions.d__1`1.MoveNext()\r\n---
Fin del seguimiento de la pila de la ubicaciĂłn anterior donde se
produjo la excepciĂłn ---\r\n en
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n en
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n en
System.Web.Http.Controllers.ApiControllerActionInvoker.d__1.MoveNext()\r\n---
Fin del seguimiento de la pila de la ubicaciĂłn anteCreating grafana
... error
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n en
System.Web.Http.Controllers.ActionFilterResult.d__5.MoveNext()\r\n---
Fin del seguimiento de la pila de la ubicaciĂłn anterior donde se
produjo la excepciĂłn ---\r\n en
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n en
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n en
System.Web.Http.Dispatcher.HttpControllerDispatcher.d__15.MoveNext()"}
And it is not only for caddy, I get same errors for Prometheus, caddy and Alertmanager

Xamarin.Android mvvmcross app crashes when launching with intent filter

When opening up the android application via a link, the android application crashes, with a NullReferenceExcetpion.
The NRE happens in the base.OnCreate(bundle) method. The base is of type MvxFragmentCompatActivity. I have also tried this with a standard MvxActivity.
I have had a look at the following questions (but to no avail)
ViewModel null when Activity started from IntentFilter
Open MvvmCross app via link with data
The Activity
[Activity(...)]
[IntentFilter(new[] { Intent.ActionView }, DataScheme = "https", DataHost = "my.link.com", DataPathPrefix = "/some/path/", Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable })]
public class MyActivity : MvxFragmentCompatActivity<MyViewModel>
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
//Other code here (never reached when triggered by IntentFilter)
}
}
The stack trace
Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
04-15 12:37:45.361 E/AndroidRuntime(26519): at MvvmCross.Platform.Mvx.Resolve[TService] () <0x9dcd9978 + 0x00038> in <filename unknown>:0
04-15 12:37:45.361 E/AndroidRuntime(26519): at MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContextHelpers.Current[T] () <0x9dcd9930 + 0x0001b> in <filename unknown>:0
04-15 12:37:45.361 E/AndroidRuntime(26519): at MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContextHelpers.Current () <0x9dcd9910 + 0x0000f> in <filename unknown>:0
04-15 12:37:45.361 E/AndroidRuntime(26519): at MvvmCross.Binding.Droid.Views.MvxLayoutInflater.Inflate (Int32 resource, Android.Views.ViewGroup root, Boolean attachToRoot) <0x9dcd7800 + 0x00033> in <filename unknown>:0
04-15 12:37:45.361 E/AndroidRuntime(26519): at Android.Views.LayoutInflater.n_Inflate_ILandroid_view_ViewGroup_Z (IntPtr jnienv, IntPtr native__this, Int32 resource, IntPtr native_root, Boolean attachToRoot) <0x9dcd7780 + 0x00063> in <filename unknown>:0
04-15 12:37:45.361 E/AndroidRuntime(26519): at (wrapper dynamic-method) System.Object:a2381224-dbcc-42b0-9aea-a687067e2004 (intptr,intptr,int,intptr,bool)
04-15 12:37:45.361 E/AndroidRuntime(26519): --- End of stack trace from previous location where exception was thrown ---
04-15 12:37:45.361 E/AndroidRuntime(26519): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x9dcdc6b8 + 0x0002b> in <filename unknown>:0
04-15 12:37:45.361 E/AndroidRuntime(26519): at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (IntPtr jobject, IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue* parms) <0x9dd046f0 + 0x000b3> in <filename unknown>:0
04-15 12:37:45.361 E/AndroidRuntime(26519): at Android.Support.V4.App.FragmentActivity.OnCreate (Android.OS.Bundle savedInstanceState) <0x9dcd6608 + 0x0014f> in <filename unknown>:0
04-15 12:37:45.361 E/AndroidRuntime(26519): at MvvmCross.Droid.Support.V7.AppCompat.MvxEventSourceAppCompatActivity.OnCreate (Android.OS.Bundle bundle) <0x9dcd5850 + 0x00037> in <filename unknown>:0
04-15 12:37:45.361 E/AndroidRuntime(26519): at MyMobileApp.Droid.Activities.MyActivity.OnCreate (Android.OS.Bundle bundle) <0x9dcd5400 + 0x0001b> in <filename unknown>:0
04-15 12:37:45.361 E/AndroidRuntime(26519): at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) <0x9dcd5380 + 0x00057> in <filename unknown>:0
04-15 12:37:45.361 E/AndroidRuntime(26519): at (wrapper dynamic-method) System.Object:e50a07b6-601f-425e-bac2-dd61e65b301f (intptr,intptr,intptr)
04-15 12:37:45.361 E/AndroidRuntime(26519): at md5af86c8db51f1d1641c99147539ead00a.MyActivity.n_onCreate(Native Method)
04-15 12:37:45.361 E/AndroidRuntime(26519): at md5af86c8db51f1d1641c99147539ead00a.MyActivity.onCreate(MyActivity.java:43)
04-15 12:37:45.361 E/AndroidRuntime(26519): at android.app.Activity.performCreate(Activity.java:5990)
04-15 12:37:45.361 E/AndroidRuntime(26519): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
04-15 12:37:45.361 E/AndroidRuntime(26519): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
04-15 12:37:45.361 E/AndroidRuntime(26519): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
04-15 12:37:45.361 E/AndroidRuntime(26519): at android.app.ActivityThread.access$800(ActivityThread.java:151)
04-15 12:37:45.361 E/AndroidRuntime(26519): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
04-15 12:37:45.361 E/AndroidRuntime(26519): at android.os.Handler.dispatchMessage(Handler.java:102)
04-15 12:37:45.361 E/AndroidRuntime(26519): at android.os.Looper.loop(Looper.java:135)
04-15 12:37:45.361 E/AndroidRuntime(26519): at android.app.ActivityThread.main(ActivityThread.java:5254)
I think this has to do with: https://github.com/MvvmCross/MvvmCross/issues/1192
Try something like this:
protected override void OnCreate(Bundle bundle)
{
var setup = MvxAndroidSetupSingleton.EnsureSingletonAvailable(ApplicationContext);
setup.EnsureInitialized();
base.OnCreate(bundle);
}

JSF1006: Cannot instantiate converter of type

I implemented the solution in:
Use enum in h:selectManyCheckbox
like this:
Converter:
#FacesConverter(value="genericEnumConverter")
public class GenericEnumConverter implements Converter {
private static final String ATTRIBUTE_ENUM_TYPE = "GenericEnumConverter.enumType";
#Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
if (value instanceof Enum) {
component.getAttributes().put(ATTRIBUTE_ENUM_TYPE, value.getClass());
return ((Enum<?>) value).name();
} else {
throw new ConverterException(new FacesMessage("Value is not an enum: " + value.getClass()));
}
}
#Override
#SuppressWarnings({"rawtypes", "unchecked"})
public Object getAsObject(FacesContext context, UIComponent component, String value) {
Class<Enum> enumType = (Class<Enum>) component.getAttributes().get(ATTRIBUTE_ENUM_TYPE);
try {
return Enum.valueOf(enumType, value);
} catch (IllegalArgumentException e) {
throw new ConverterException(new FacesMessage("Value is not an enum of type: " + enumType));
}
}
}
xhtml:
<p:selectManyCheckbox converter="genericEnumConverter" value="#{aView.newObject.someValue}">
<f:selectItems value="#{enumBean.someValues}" var="s" itemValue="#{s}" itemLabel = "#{s.name}"/>
</p:selectManyCheckbox>
But getting this error:
com.sun.faces.application.ApplicationImpl createConverter
SEVERE: JSF1006: Cannot instantiate converter of type
javax.faces.FacesException: Expression Error: Named Object: ' not found.
at com.sun.faces.application.ApplicationImpl.createConverter(ApplicationImpl.java:1334)
at com.sun.faces.facelets.tag.jsf.ValueHolderRule$LiteralConverterMetadata.applyMetadata(ValueHolderRule.java:85)
at com.sun.faces.facelets.tag.MetadataImpl.applyMetadata(MetadataImpl.java:81)
at javax.faces.view.facelets.MetaTagHandler.setAttributes(MetaTagHandler.java:129)
at javax.faces.view.facelets.DelegatingMetaTagHandler.setAttributes(DelegatingMetaTagHandler.java:102)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.doNewComponentActions(ComponentTagHandlerDelegateImpl.java:402)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:159)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at com.sun.faces.facelets.tag.ui.DefineHandler.applyDefinition(DefineHandler.java:103)
at com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:178)
at com.sun.faces.facelets.impl.DefaultFaceletContext$TemplateManager.apply(DefaultFaceletContext.java:395)
at com.sun.faces.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:366)
at com.sun.faces.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:108)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at com.sun.faces.facelets.tag.jsf.core.ViewHandler.apply(ViewHandler.java:186)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:184)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:82)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:308)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:367)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:346)
at com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:199)
at com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:155)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:82)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:152)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:744)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:509)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:233)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
It looks like converter is not registered to JSF, but I used:
#FacesConverter(value="genericEnumConverter")
Does anyone have any opinion about this?
I had the same error with JBoss + JSF 2.0 + SEAM. By adding the following lines of code, the problem was solved.
#Name("testConverter")
#Scope(ScopeType.CONVERSATION)
#org.jboss.seam.annotations.faces.Converter
#BypassInterceptors
public class TestConverter implements Converter {
...
}

.Net MVC4 Action Method parameter is null from jqGrid post

I have looked through many posts on this subject but so far I haven't resolved my problem. I am new to MVC / Jquery so I may have missed the answer.
I wish to return all rows from a jqGrid. I have used Oleg's example code for the jqGrid processing:
sendData = function (data) {
var dataToSend = JSON.stringify(data);
alert("The following data are sending to the server:\n" + dataToSend);
$.ajax({
type: "POST",
url: '#Url.Action("Update", "WatchList")',
dataType: "json",
data: dataToSend,
loadonce: true,
contentType: "application/json; charset=utf-8",
success: function (response, textStatus, jqXHR) {
// remove error div if exist
$('#' + grid[0].id + '_err').remove();
alert("Updates Complete");
},
error: function (jqXHR, textStatus, errorThrown) {
// remove error div if exist
$('#' + grid[0].id + '_err').remove();
// insert div with the error description before the grid
grid.closest('div.ui-jqgrid').before(
'<div id="' + grid[0].id + '_err" style="max-width:' + grid[0].style.width +
';"><div class="ui-state-error ui-corner-all" style="padding:0.7em;float:left;"><span class="ui-icon ui-icon-alert" ' +
'style="float:left; margin-right: .3em;"></span><span style="clear:left">' +
decodeErrorMessage(jqXHR, textStatus, errorThrown) + '</span></div><div style="clear:left"/></div>');
}
$("#sendAll").click(function () {
var localGridData = grid.jqGrid('getGridParam', 'data');
sendData(localGridData);
});
};
Fiddler output for the post is :
POST http://localhost:49323/WatchList/Update HTTP/1.1
Host: localhost:49323
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/json; charset=utf-8
X-Requested-With: XMLHttpRequest
Referer: http://localhost:49323/WatchList/Edit
Content-Length: 3645
Cookie: __RequestVerificationToken=flUoW7U12gHRfOVMNiLu_tW4G_oVI4TwxvAYKOU9arGI014KWFKUKjUbgjbZStLb7n1TGmU22NtoQjAb26bmjcccjg8x6skcL1zbP_o2y5I1; .ASPXAUTH=D968251D718DEF7CA0C9D4A6BD2750F9923CBF554FC0B058772C753C4305682578C207F7367B6D61F80F84CBDCA5C130126AE2CC5E1715FA897122DEB68B3B40C86816C32A6F047891794A732F4A7A3499064220077793B5F1313813FFC21D01
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
[{"Date":"Fri 22 March 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"0"},{"Date":"Sat 23 March 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"1"},{"Date":"Sun 24 March 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"2"},{"Date":"Mon 25 March 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"3"},{"Date":"Tue 26 March 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"4"},{"Date":"Wed 27 March 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"5"},{"Date":"Thu 28 March 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"6"},{"Date":"Fri 29 March 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"7"},{"Date":"Sat 30 March 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"8"},{"Date":"Sun 31 March 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"9"},{"Date":"Mon 1 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"10"},{"Date":"Tue 2 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"11"},{"Date":"Wed 3 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"12"},{"Date":"Thu 4 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"13"},{"Date":"Fri 5 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"14"},{"Date":"Sat 6 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"15"},{"Date":"Sun 7 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"16"},{"Date":"Mon 8 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"17"},{"Date":"Tue 9 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"18"},{"Date":"Wed 10 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"19"},{"Date":"Thu 11 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"20"},{"Date":"Fri 12 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"21"},{"Date":"Sat 13 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"22"},{"Date":"Sun 14 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"23"},{"Date":"Mon 15 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"24"},{"Date":"Tue 16 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"25"},{"Date":"Wed 17 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"26"},{"Date":"Thu 18 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"27"},{"Date":"Fri 19 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"28"},{"Date":"Sat 20 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"29"},{"Date":"Sun 21 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"30"},{"Date":"Mon 22 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"31"},{"Date":"Tue 23 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"32"}]
The parameter received by the controller is null? I don't have a model to bring the data directly into as the grids columns are dynamically created so I need to parse the raw data. What do I need in my controller action to get hold of the post data?
Your change must be close because the data is now being recognised but with the error
Invalid JSON primitive: griddata.]
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Invalid JSON primitive: griddata.
[ArgumentException: Invalid JSON primitive: griddata.]
System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject() +915
System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) +597
System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer) +108
System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) +211
System.Web.Script.Serialization.JavaScriptSerializer.DeserializeObject(String input) +86
System.Web.Mvc.JsonValueProviderFactory.GetDeserializedObject(ControllerContext controllerContext) +298
System.Web.Mvc.JsonValueProviderFactory.GetValueProvider(ControllerContext controllerContext) +123
System.Web.Mvc.<>c__DisplayClassc.<GetValueProvider>b__7(ValueProviderFactory factory) +59
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +145
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +171
System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +460
System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
System.Web.Mvc.ValueProviderFactoryCollection.GetValueProvider(ControllerContext controllerContext) +360
System.Web.Mvc.ControllerBase.get_ValueProvider() +85
System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +154
System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +199
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__1e(AsyncCallback asyncCallback, Object asyncState) +978
System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +161
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag, Int32 timeout) +92
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag) +53
System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +523
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__17(AsyncCallback asyncCallback, Object asyncState) +83
System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +161
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag, Int32 timeout) +92
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate endDelegate, Object tag, Int32 timeout) +97
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate endDelegate, Object tag) +53
System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +501
System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +161
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag, Int32 timeout) +92
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate endDelegate, Object tag, Int32 timeout) +97
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate endDelegate, Object tag) +53
System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +417
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +49
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__2(AsyncCallback asyncCallback, Object asyncState) +127
System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +161
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate`1 endDelegate, Object tag, Int32 timeout) +92
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate endDelegate, Object tag, Int32 timeout) +97
System.Web.Mvc.Async.AsyncResultWrapper.Begin(AsyncCallback callback, Object state, BeginInvokeDelegate beginDelegate, EndInvokeDelegate endDelegate, Object tag) +53
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +373
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +88
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +50
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
I have noticed that if I use the original code:
data: dataToSend,
the post data shows in Fiddler as :
[{"Date":"Fri 29 March 2013","id":"0"},{"Date":"Sat 30 March 2013","id":"1"},{"Date":"Sun 31 March 2013","id":"2"},{"Date":"Mon 1 April 2013","id":"3"},{"Date":"Tue 2 April 2013","id":"4"},{"Date":"Wed 3 April 2013","id":"5"},{"Date":"Thu 4 April 2013","id":"6"},{"Date":"Fri 5 April 2013","id":"7"},{"Date":"Sat 6 April 2013","id":"8"},{"Date":"Sun 7 April 2013","id":"9"},{"Date":"Mon 8 April 2013","id":"10"},{"Date":"Tue 9 April 2013","id":"11"},{"Date":"Wed 10 April 2013","id":"12"},{"Date":"Thu 11 April 2013","id":"13"},{"Date":"Fri 12 April 2013","id":"14"},{"Date":"Sat 13 April 2013","id":"15"},{"Date":"Sun 14 April 2013","id":"16"},{"Date":"Mon 15 April 2013","id":"17"},{"Date":"Tue 16 April 2013","id":"18"},{"Date":"Wed 17 April 2013","id":"19"},{"Date":"Thu 18 April 2013","id":"20"},{"Date":"Fri 19 April 2013","id":"21"},{"Date":"Sat 20 April 2013","id":"22"},{"Date":"Sun 21 April 2013","id":"23"},{"Date":"Mon 22 April 2013","id":"24"},{"Date":"Tue 23 April 2013","id":"25"},{"Date":"Wed 24 April 2013","id":"26"},{"Date":"Thu 25 April 2013","id":"27"},{"Date":"Fri 26 April 2013","id":"28"},{"Date":"Sat 27 April 2013","id":"29"},{"Date":"Sun 28 April 2013","id":"30"},{"Date":"Mon 29 April 2013","id":"31"},{"Date":"Tue 30 April 2013","Night":"False","Morning":"False","Afternoon":"False","Evening":"False","id":"32"}]
if using
data: {griddata:dataToSend},
the data shows in Fiddler as :
griddata=%5B%7B%22Date%22%3A%22Fri+29+March+2013%22%2C%22id%22%3A%220%22%7D%2C%7B%22Date%22%3A%22Sat+30+March+2013%22%2C%22id%22%3A%221%22%7D%2C%7B%22Date%22%3A%22Sun+31+March+2013%22%2C%22id%22%3A%222%22%7D%2C%7B%22Date%22%3A%22Mon+1+April+2013%22%2C%22id%22%3A%223%22%7D%2C%7B%22Date%22%3A%22Tue+2+April+2013%22%2C%22id%22%3A%224%22%7D%2C%7B%22Date%22%3A%22Wed+3+April+2013%22%2C%22id%22%3A%225%22%7D%2C%7B%22Date%22%3A%22Thu+4+April+2013%22%2C%22id%22%3A%226%22%7D%2C%7B%22Date%22%3A%22Fri+5+April+2013%22%2C%22id%22%3A%227%22%7D%2C%7B%22Date%22%3A%22Sat+6+April+2013%22%2C%22id%22%3A%228%22%7D%2C%7B%22Date%22%3A%22Sun+7+April+2013%22%2C%22id%22%3A%229%22%7D%2C%7B%22Date%22%3A%22Mon+8+April+2013%22%2C%22id%22%3A%2210%22%7D%2C%7B%22Date%22%3A%22Tue+9+April+2013%22%2C%22id%22%3A%2211%22%7D%2C%7B%22Date%22%3A%22Wed+10+April+2013%22%2C%22id%22%3A%2212%22%7D%2C%7B%22Date%22%3A%22Thu+11+April+2013%22%2C%22id%22%3A%2213%22%7D%2C%7B%22Date%22%3A%22Fri+12+April+2013%22%2C%22id%22%3A%2214%22%7D%2C%7B%22Date%22%3A%22Sat+13+April+2013%22%2C%22id%22%3A%2215%22%7D%2C%7B%22Date%22%3A%22Sun+14+April+2013%22%2C%22id%22%3A%2216%22%7D%2C%7B%22Date%22%3A%22Mon+15+April+2013%22%2C%22id%22%3A%2217%22%7D%2C%7B%22Date%22%3A%22Tue+16+April+2013%22%2C%22id%22%3A%2218%22%7D%2C%7B%22Date%22%3A%22Wed+17+April+2013%22%2C%22id%22%3A%2219%22%7D%2C%7B%22Date%22%3A%22Thu+18+April+2013%22%2C%22id%22%3A%2220%22%7D%2C%7B%22Date%22%3A%22Fri+19+April+2013%22%2C%22id%22%3A%2221%22%7D%2C%7B%22Date%22%3A%22Sat+20+April+2013%22%2C%22id%22%3A%2222%22%7D%2C%7B%22Date%22%3A%22Sun+21+April+2013%22%2C%22id%22%3A%2223%22%7D%2C%7B%22Date%22%3A%22Mon+22+April+2013%22%2C%22id%22%3A%2224%22%7D%2C%7B%22Date%22%3A%22Tue+23+April+2013%22%2C%22id%22%3A%2225%22%7D%2C%7B%22Date%22%3A%22Wed+24+April+2013%22%2C%22id%22%3A%2226%22%7D%2C%7B%22Date%22%3A%22Thu+25+April+2013%22%2C%22id%22%3A%2227%22%7D%2C%7B%22Date%22%3A%22Fri+26+April+2013%22%2C%22id%22%3A%2228%22%7D%2C%7B%22Date%22%3A%22Sat+27+April+2013%22%2C%22id%22%3A%2229%22%7D%2C%7B%22Date%22%3A%22Sun+28+April+2013%22%2C%22id%22%3A%2230%22%7D%2C%7B%22Date%22%3A%22Mon+29+April+2013%22%2C%22id%22%3A%2231%22%7D%2C%7B%22Date%22%3A%22Tue+30+April+2013%22%2C%22Night%22%3A%22False%22%2C%22Morning%22%3A%22False%22%2C%22Afternoon%22%3A%22False%22%2C%22Evening%22%3A%22False%22%2C%22id%22%3A%2232%22%7D%5D
Try modifying like this:
function sendData(data) {
var dataToSend = JSON.stringify(data);
alert("The following data are sending to the server:\n" + dataToSend);
$.ajax({
type: "POST",
url: '#Url.Action("WatchList", "Update")',
dataType: "json",
data: {griddata:dataToSend},
loadonce: true,
contentType: "application/json; charset=utf-8",
success: function (response, textStatus, jqXHR) {
// remove error div if exist
$('#' + grid[0].id + '_err').remove();
alert("Updates Complete");
},
error: function (jqXHR, textStatus, errorThrown) {
// remove error div if exist
$('#' + grid[0].id + '_err').remove();
// insert div with the error description before the grid
grid.closest('div.ui-jqgrid').before(
'<div id="' + grid[0].id + '_err" style="max-width:' + grid[0].style.width +
';"><div class="ui-state-error ui-corner-all" style="padding:0.7em;float:left;"><span class="ui-icon ui-icon-alert" ' +
'style="float:left; margin-right: .3em;"></span><span style="clear:left">' +
decodeErrorMessage(jqXHR, textStatus, errorThrown) + '</span></div><div style="clear:left"/></div>');
}
$("#sendAll").click(function () {
var localGridData = grid.jqGrid('getGridParam', 'data');
sendData(localGridData);
});
};
In controller:
public ActionResult WatchList(string griddata) {
........
}

Resources