Partial doesn't recognize category/HTTP method?

25 views
Skip to first unread message

Matt S.

unread,
May 17, 2013, 9:49:33 PM5/17/13
to fubumv...@googlegroups.com
I'm messing around with validation and wanted to try a couple of scenarios. I tried using an endpoint nearly identical to this LoFiEndpoint and this AjaxEndpoint. In either case, if I have a view that outputs a partial for the input model, I get the below error regarding a duplicate behavior chain model.

FubuCore Error 2108:  
More than one behavior chain matching criteria:  Type: FubuMVC.HelloValidation.Ajax.TestItem


I'm using this.Partial[[TestItem]]() in Spark to render the partial. I'm using a partial because my view consists of 2 forms; one is for the endpoint in question with a view that uses the TestItem model and kicks out a form for the same model.

By "nearly identical" above, I mean that my endpoints only differ by their convention (my action methods are simply "Get" and "Post" with a convention to add such a constraint for HTTP method). My convention seems to work for all other actions I've used it for without issue.

I'm using the latest public NuGet versions. Is this something missed because nobody has tried this particular pattern (same input model for 2 actions, but of different HTTP methods) with a partial?

Jeremy D. Miller

unread,
May 17, 2013, 9:57:26 PM5/17/13
to fubumv...@googlegroups.com
I don't know that we've ever tried that with a Partial.  I had to go research that for awhile, but yeah, you're right.  PartialInvoker doesn't account for HTTP method.  I did not account for the pattern you're trying to do here.

Where exactly are you getting the exception?  When you try to render the form?  this.FormFor() should be using the POST automatically.
 
Jeremy D. Miller
The Shade Tree Developer
jeremy...@yahoo.com



From: Matt S. <ven...@gmail.com>
To: fubumv...@googlegroups.com
Sent: Fri, May 17, 2013 8:49:36 PM
Subject: [fubumvc] Partial doesn't recognize category/HTTP method?
--
You received this message because you are subscribed to the Google Groups "FubuMVC Development Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fubumvc-deve...@googlegroups.com.
To post to this group, send email to fubumv...@googlegroups.com.
Visit this group at http://groups.google.com/group/fubumvc-devel?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Joshua Arnold

unread,
May 17, 2013, 11:54:39 PM5/17/13
to fubumv...@googlegroups.com
For what it's worth, Matt: I usually just do a subclass for a "template" in this particular case.

Matt S.

unread,
May 18, 2013, 8:40:50 AM5/18/13
to fubumv...@googlegroups.com
I figured as much. I'm always trying weird things, it seems. In this case, my Login view is also showing a partial for the Register view.

I am getting the exception on the partial invoke. Here is the rest of that stack trace.

[FubuException: FubuCore Error 2108:  
More than one behavior chain matching criteria:  Type: MyApp.Website.Features.Register.RegisterInputModel, CategoryOrHttpMethod: None, CategoryMode: Relaxed, TypeMode: InputModelOnly, MethodName: 
Matches:
register   -- IndexEndpoint.Get(RegisterInputModel request) : RegisterInputModel
register   -- IndexEndpoint.Post(RegisterInputModel input) : AjaxContinuation]
   FubuMVC.Core.Registration.Querying.<>c__DisplayClasse.<find>b__a() in c:\BuildAgent\work\6ff6894a9badaff7\src\FubuMVC.Core\Registration\Querying\ChainResolutionCache.cs:74
   FubuMVC.Core.Registration.Querying.ChainResolutionCache.Find(ChainSearch search) in c:\BuildAgent\work\6ff6894a9badaff7\src\FubuMVC.Core\Registration\Querying\ChainResolutionCache.cs:81
   FubuMVC.Core.Registration.Querying.ChainResolutionCache.FindUnique(Object model, String category) in c:\BuildAgent\work\6ff6894a9badaff7\src\FubuMVC.Core\Registration\Querying\ChainResolutionCache.cs:109
   FubuMVC.Core.Registration.Querying.<>c__DisplayClass2.<For>b__1(IChainResolver r) in c:\BuildAgent\work\6ff6894a9badaff7\src\FubuMVC.Core\Registration\Querying\ChainInterrogator.cs:51
   FubuMVC.Core.Registration.Querying.ChainInterrogator`1.findAnswerFromResolver(Object model, Func`2 finder) in c:\BuildAgent\work\6ff6894a9badaff7\src\FubuMVC.Core\Registration\Querying\ChainInterrogator.cs:25
   FubuMVC.Core.Registration.Querying.ChainInterrogator`1.processForwarder(Object model, Func`1 forwarderSource, Func`2 finder) in c:\BuildAgent\work\6ff6894a9badaff7\src\FubuMVC.Core\Registration\Querying\ChainInterrogator.cs:32
   FubuMVC.Core.Registration.Querying.ChainInterrogator`1.For(Object model, String categoryOrMethod) in c:\BuildAgent\work\6ff6894a9badaff7\src\FubuMVC.Core\Registration\Querying\ChainInterrogator.cs:48
   FubuMVC.Core.Security.AuthorizationPreviewService.IsAuthorized(Object model) in c:\BuildAgent\work\6ff6894a9badaff7\src\FubuMVC.Core\Security\AuthorizationPreviewService.cs:61
   FubuMVC.Core.UI.PartialInvoker.Invoke() in c:\BuildAgent\work\6ff6894a9badaff7\src\FubuMVC.Core\UI\PartialInvoker.cs:34
   FubuMVC.Core.UI.PartialExpressionExtensions.InvokePartial(IFubuPage page, String prefix) in c:\BuildAgent\work\ea27ef6190757424\src\FubuMVC.Core.View\PartialExpressionExtensions.cs:33
   FubuMVC.Core.UI.PartialExpressionExtensions.Partial(IFubuPage page) in c:\BuildAgent\work\ea27ef6190757424\src\FubuMVC.Core.View\PartialExpressionExtensions.cs:12
   Viewc8e917497dc645c09af0102782d9119e.RenderViewLevel0() +1882
   Spark.SparkViewBase.DelegateFirstRender(Action render) +9
   Viewc8e917497dc645c09af0102782d9119e.Render() +156
   FubuMVC.Spark.Rendering.FubuSparkViewDecorator.Render() in c:\BuildAgent\work\ea27ef6190757424\src\FubuMVC.Spark\Rendering\FubuSparkView.cs:135
   FubuMVC.Core.View.ViewWriter`1.Write(String mimeType, T resource) in c:\BuildAgent\work\ea27ef6190757424\src\FubuMVC.Core.View\ViewWriter.cs:32
   FubuMVC.Core.Resources.Conneg.Media`1.Write(String mimeType, T resource) in c:\BuildAgent\work\6ff6894a9badaff7\src\FubuMVC.Core\Resources\Conneg\Media.cs:40
   FubuMVC.Core.Resources.Conneg.OutputBehavior`1.Write() in c:\BuildAgent\work\6ff6894a9badaff7\src\FubuMVC.Core\Resources\Conneg\OutputBehavior.cs:53
   FubuMVC.Core.Resources.Conneg.OutputBehavior`1.afterInsideBehavior() in c:\BuildAgent\work\6ff6894a9badaff7\src\FubuMVC.Core\Resources\Conneg\OutputBehavior.cs:33
   FubuMVC.Core.Behaviors.BasicBehavior.Invoke() in c:\BuildAgent\work\6ff6894a9badaff7\src\FubuMVC.Core\Behaviors\BasicBehavior.cs:31
   FubuMVC.Core.Behaviors.WrappingBehavior.<Invoke>b__0() in c:\BuildAgent\work\6ff6894a9badaff7\src\FubuMVC.Core\Behaviors\WrappingBehavior.cs:13
   FubuMVC.Diagnostics.Runtime.Tracing.BehaviorTracer.invoke(Action action) in c:\BuildAgent\work\48f78f17652f6d5c\src\FubuMVC.Diagnostics\Runtime\Tracing\BehaviorTracer.cs:26


I originally had the GET input as a separate class. Then, I decided to try PRG with the Register action, since the Login does a non Ajax POST. I was going to POST to the Register action, then redirect back to the Url from the query string. When I did that, I wasn't getting validation, so I switched to this pattern (same input class for GET and POST) to support the lo-fi scenario. That's when I saw this behavior.

Matt S.

unread,
May 18, 2013, 8:50:17 AM5/18/13
to fubumv...@googlegroups.com
Josh,

Before I posted, I did subclass my input model to use for the GET instead. The exception went away then. However, I wasn't sure if your lo-fi scenario for validation would work then. I admit, I didn't dig into the code to see if you have it looking for an exact class match when redirecting to the corresponding GET of a validation failed POST, or if you were looking for any class that can be assigned from the POST's input type.

In the end, this all made me start looking seriously at the client-side continuation package (very slick, btw). My thought is to use Ajax (avoid the lo-fi for now), have separate model types for GET vs POST, and have my POST return an AjaxContinuation with an added NavigateTo for redirecting upon success (note what I'm doing all this for in my reply to Jeremy above).

FYI, this also led me to finally submitting that PR for class-level validation rule registration we talked about last month (my Register action wants a rule to compare Password to PasswordConfirmation). ;-)
Reply all
Reply to author
Forward
0 new messages