Bravo :-)
> In the example web project layouts are defined directly in views. As much as
> like this approach, I don't think it will be possible with Spark, due to the
> way it renders. However the BaseViewEngine#ResolveView method gets layout
> paths as parameter. Unfortunately F# is pretty obsure for me at the moment
> and I couldn't find where in code these layout names are resolved. Is this
> implemented already?
So in previous design the view engine was also responsible for
implementing the "convention" for resolving the views/layouts. I
separated that since I dont think this responsibility should lie with
them.
Currently this is how it looks
ViewRequest -> IViewFolderLayout -> IViewEngine
A controller can "decide" to render a view. It creates a viewrequest,
which is handed to DefaultViewFolderLayout so it fills the possible
locations. The view engine then tries to load the view sources from
these locations. The ViewRendererService coordinates these steps.
> 2. HtmlResult
> This is F# and not MonoRail question. In my workaround for the Form.For
> functionality I needed implicit cast operator for HtmlResult. Are cast
> operators overloadable in F#? I couldn't find an answer on MSDN.
This is a good question. I'm not sure myself. Do you need to
implicitly cast HtmlResult to string?
> 3. IoC container integration
> Right, MEF is indeed awesome at framework level - agreed. But at application
> level I'd still prefer Windsor or Autofac. Having used implemented Windsor
> for your project could you give some more details on wiring it up with
> MR+++?
Two steps:
1 - Add a reference to Castle.MonoRail.Extension.Windsor.dll
2 - On your global.asax.cs
public class Global : System.Web.HttpApplication, IContainerAccessor
{
private static WindsorContainer container;
void Application_Start(object sender, EventArgs e)
{
// routes
container = new WindsorContainer(new XmlInterpreter());
container.Register(AllTypes.FromThisAssembly().
Where(t => t.Name.EndsWith("Controller")).
Configure(r =>
r.LifeStyle.Transient.Configuration().Named("\\" +
r.Implementation.Name)));
container.Register(AllTypes.FromThisAssembly().
Where(t => t.Name.EndsWith("Component")).
Configure(r =>
r.LifeStyle.Transient.Configuration().Named("viewcomponents\\" +
r.Implementation.Name)));
container.Register(AllTypes.FromThisAssembly().
Where(t => t.Name.EndsWith("Filter")).
Configure(c => c.LifeStyle.Transient));
}
public IWindsorContainer Container
{
get { return container; }
}
void Application_End(object sender, EventArgs e)
{
if (container != null) container.Dispose();
}
}
> 4. Implementation status
> It seems that the ActionName and HttpMethod attributes haven't been
> implemented yet. Especially the second one interests me. How could I help?
Get more acquainted with F# :-)
My idea is to make the action name be explicit about the verb it
supports. HttpMethod is more like a backward-compatible way to do
that.
Actions would have the following method accessibility:
Home | Get only
PostCreate | Action Create : Post only
PutUpdate | Action Update : Put only (but supporting the fake post
with _method = PUT)
DeleteRemove | Action Remove : Delete only (ditto)
That would make easier to support two methods with different semantics
Create and PostCreate are very explicit in their goals.
I'd guess you'd need the following to get this done
- test cases for MethodInfoActionDescriptor (see Mvc.Typed.Descriptor.fs)
- change the MethodInfoActionDescriptor to expose the action name
without the verb (if present), save the verb from the name or
attribute).
- Implement the MethodInfoActionDescriptor.SatisfyRequest
Bonus points:
- I'd love a test case for DefaultActionSelector
(Mvc.Typed.ProgModel.fs) too, to make sure it is correctly filtering
the available actions based on the result of SatisfyRequest
- maybe refactor PocoControllerExecutor moving the selection of action
candidates to DefaultActionSelector?
--
Cheers,
hammett
http://hammett.castleproject.org/
- We (Henry and I) noticed that is fairly common to have VC with
"actions", especially when combined with ajax
- therefore VC in MR3 is a controller implementing a interface
IViewComponent, that defines the default action.
- layout wise, they should live in a viewcomponents folder.
The principle remains the same, though. Controllers are flat and
vertical, hence not composable. ViewComponents is the way to aggregate
content/logic within views.
> --
> You received this message because you are subscribed to the Google Groups "Castle Project Development List" group.
> To post to this group, send email to castle-pro...@googlegroups.com.
> To unsubscribe from this group, send email to castle-project-d...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/castle-project-devel?hl=en.
ViewComponent.Render<Foo>(vc => vc.SomeSection = @<td> @item.Name </ td>)
And on your vc view you must invoke the property supplying the desired arguments. With the blade support for lambdas, the sky is the limit.
It's important to note that this approach isn't restricted to blade (or razor) views. If you can declare a inline template function with your ve, you should be done.
On Sun, Aug 14, 2011 at 10:15 AM, Tomek Pluskiewicz <ploo...@gmail.com> wrote:
> OK, so I've started experimenting with implementing Spark View Engine for
> MR3Bravo :-)
> --
> You received this message because you are subscribed to the Google Groups
> "Castle Project Development List" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/castle-project-devel/-/tS2fpk1r7rIJ.
> To post to this group, send email to castle-pro...@googlegroups.com.
> To unsubscribe from this group, send email to
> castle-project-d...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/castle-project-devel?hl=en.
>
--
Cheers,
hammett
http://hammett.castleproject.org/
$ git diff master other/master/
fatal: ambiguous argument 'other/master/': unknown revision or path not in the w
orking tree.
Use '--' to separate paths from revisions
$ git remote -v
origin g...@github.com:castleproject/Castle.MonoRail3.git (fetch)
origin g...@github.com:castleproject/Castle.MonoRail3.git (push)
other https://github.com/ploosqva/Castle.MonoRail3.git (fetch)
other https://github.com/ploosqva/Castle.MonoRail3.git (push)
hammett@HAMMETT-LAPTOP /c/dev/github/castle/Castle.MonoRail3 (master)
$ git branch -r
origin/HEAD -> origin/master
origin/hammett_exp
origin/master
origin/viewcpnts
other/HEAD -> other/master
hammett@HAMMETT-LAPTOP /c/dev/github/castle/Castle.MonoRail3 (master)
$ git branch
* master
HEAD also didn't work.
$ git diff master other/HEAD
warning: ignoring dangling symref refs/remotes/other/HEAD.
warning: ignoring dangling symref refs/remotes/other/HEAD.
fatal: ambiguous argument 'other/HEAD': unknown revision or path not
in the working tree.
Use '--' to separate paths from revisions
On Sun, Aug 14, 2011 at 10:15 AM, Tomek Pluskiewicz <ploo...@gmail.com> wrote:
> In the example web project layouts are defined directly in views. As much as> like this approach, I don't think it will be possible with Spark, due to the
> way it renders. However the BaseViewEngine#ResolveView method gets layout
> paths as parameter. Unfortunately F# is pretty obsure for me at the moment
> and I couldn't find where in code these layout names are resolved. Is this
> implemented already?So in previous design the view engine was also responsible for
implementing the "convention" for resolving the views/layouts. I
separated that since I dont think this responsibility should lie with
them.Currently this is how it looks
ViewRequest -> IViewFolderLayout -> IViewEngine
A controller can "decide" to render a view. It creates a viewrequest,
which is handed to DefaultViewFolderLayout so it fills the possible
locations. The view engine then tries to load the view sources from
these locations. The ViewRendererService coordinates these steps.
> 2. HtmlResult
> This is F# and not MonoRail question. In my workaround for the Form.For
> functionality I needed implicit cast operator for HtmlResult. Are cast
> operators overloadable in F#? I couldn't find an answer on MSDN.This is a good question. I'm not sure myself. Do you need to
implicitly cast HtmlResult to string?
Just change the signature on ViewRequest. Also change ViewResult and
variations.
> Also I'm not sure where is that ViewRequest really created.
I believe the implementation of ActionResults does.
> Another thing I find missing is the possibility to choose View/Layout on
> ContentNegotiatedResult. Otherwise how is is possible to choose layout and
> view when client requests html?
Actually it is possible, since you can customize the "action" for a
mime type. Something like
var result = new ContentNegotiatedResult(..);
result.When(MimeType.Html, () => new ViewResult(...));
> I need the implicit cast temporarily until there is a better way to wrap up
> transitions with Spark. Verbose enough I just didn't want another ToString()
> call and I was surprised I couldn't find that implicit casting... For now I
> simply derived in C#.
What's the signature in C#? I may try to translate it to f# here and test it...
Thanks!
First switch to ploosqva/master:
$ git checkout ploosqva/master
Then do format patch comparing to origin:
git format-patch origin
This should generate patch files for individual commits.
HTH
$ git config --list
core.symlinks=false
core.autocrlf=false
color.diff=auto
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
user.name=hammett
user.email=ham...@gmail.com
gui.fontdiff=-family Consolas -size 11 -weight normal -slant roman
-underline 0 -overstrike 0
gui.recentrepo=C:/dev/personal/wp7/NprNews
diff.external=C:/dev/tools/WinMerge/git-diff-wrapper.sh
diff.tool=winmerge
merge.tool=diffmerge
mergetool.diffmerge.cmd=git-merger-wrapper.sh $PWD/$LOCAL $PWD/$BASE
$PWD/$REMOTE $PWD/$MERGED
mergetool.diffmerge.trustexitcode=false
mergetool.diffmerge.keepbackup=false
core.autocrlf=false
difftool.prompt=false