尝试使用Nustache来共享客户端和服务器胡子模板,但Nustache只是不能很好地使用我的应用程序.我在源代码中直接使用了他们的MVC应用程序示例中的代码,但每次尝试设置或添加视图引擎时都会出错.这是一个代码片段(来自一个动作方法,我也试过在global.asax中全局添加视图引擎并且有相同的错误):
ViewResult viewResult = View(new { test = "Jawesome" });
viewResult.ViewEngineCollection = new ViewEngineCollection
{
new NustacheViewEngine()
};
Run Code Online (Sandbox Code Playgroud)
这是错误:
[ArrayTypeMismatchException: Attempted to access an element as a type incompatible with the array.]
System.Collections.Generic.List`1.Insert(Int32 index, T item) +62
MyController.Index() in C:\src\projects\myproject\myproject.Web\Controllers\MyController.cs:83
lambda_method(Closure , ControllerBase , Object[] ) +79
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +264
...
Run Code Online (Sandbox Code Playgroud) 在wicket中创建TextField的优雅方法是什么,除了使用SimpleAttributeModifier手动设置组件的"value"属性之外,还使用默认值进行渲染?
例如,这有效:
TextField<String> headline = new TextField<String>("headline", new PropertyModel(backingObject, "headline"));
headline.add(new SimpleAttributeModifier("value", "default value"));
add(headline);
Run Code Online (Sandbox Code Playgroud)
但有更好的方法吗?