[MonoRail Help] Custom Views for Scaffolding

I just downloaded the latest version of the Castle MonoRail assemblies.  For a while, I have been wary of using the Scaffolding for controller and View because the views seem to stumble over nullable data types in the Model classes.  While that seem to still be a problem (maybe I’ll write a patch for it), I have started to use Scaffolding for the controllers and the customizing the Views.

Here are a list of the parameters available in the PropertyBag along with the names of the files you should create.  I’m using NVelocity, so my views end with the .VM extension.

List View

View Name: List.vm
$Items : a listing of all the records for the given model

New View

This is the view that collects information for a new record.  The form action should point to the Create controller action.

View Name: new{classname}.vm  (e.g.: if you have a model called Study, your view name will be newStudy.vm)
${classname} : is the item that you’re editing.

When creating for elements, you should name them with the format name=”classname.propertyname” (e.g.: for the Study model, if I have a property called Name, then I should add a form element with the name “Study.Name”.

Create View

There is none… this controller action just redirects to the list view after the new record is created.

Edit View

View Name: edit.vm
Query String:
id : the primary key of the record (I’m not sure what happens with models using composite keys)
The form elements have the same name format as the Create view, which is name=”classname.propertyname”.

[I'm still working to gather information on the child collection properties and the available options for those collections]

Confirm View

This is the delete confirmation view.  I usually use the JavaScript ‘confirm’ method and the do a redirect to the delete action.

View Name: confirm.vm
$classname : the record to delete
QueryString:
id: the primary key of the record to delete.

Remove View

There is no view for this action.  The controller just redirects to the list view.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>