Fixing IOC-60, Custom Parameters do not play a role in resolving chains
[castle.git] / MonoRail / Castle.MonoRail.ActiveRecordScaffold / NewAction.cs
blob8a66e1eea4d09da6bd8dcd8d28d52f2ef0de642a
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.MonoRail.ActiveRecordScaffold
17 using System;
18 using Castle.Components.Binder;
19 using Castle.MonoRail.Framework;
21 using Castle.Components.Common.TemplateEngine;
24 /// <summary>
25 /// Renders an inclusion form
26 /// </summary>
27 /// <remarks>
28 /// Searchs for a template named <c>new{name}</c>
29 /// </remarks>
30 public class NewAction : AbstractScaffoldAction
32 protected object instance;
34 public NewAction(Type modelType, ITemplateEngine templateEngine, bool useModelName, bool useDefaultLayout) :
35 base(modelType, templateEngine, useModelName, useDefaultLayout)
39 protected override string ComputeTemplateName(Controller controller)
41 return String.Format(@"{0}\new{1}", controller.Name, Model.Type.Name);
44 protected override void PerformActionProcess(Controller controller)
46 base.PerformActionProcess(controller);
48 if (instance == null)
50 instance = Activator.CreateInstance(Model.Type);
52 // instance = binder.BindObject(Model.Type,
53 // Model.Type.Name,
54 // builder.BuildSourceNode(controller.Request.QueryString) );
57 controller.PropertyBag["prefix"] = Model.Type.Name;
58 controller.PropertyBag["instance"] = instance;
61 protected override void RenderStandardHtml(Controller controller)
63 SetUpHelpers(controller);
64 RenderFromTemplate("new.vm", controller);