Going to give an example of editing a username of an existing user.
This is going to be quite long but should hopefully serve as a good
example of how the approaches contrast with Fubu's. It may be that I
don't fully understand Fubu's approach yet and that I'm missing
something.
Syntax might not be spot on as I'm doing this straight into the text
box but the essence will be correct.
In MVC:
public ViewResult Index()
{
var user = GetUser();
ViewData.Model = new UserViewModel
{
Username = user.Username
};
return View("Index");
}
[AcceptVerbs(HttpVerbs.Post)]
ActionResult Index(UserViewModel model)
{
if (ModelState.IsValid)
{
// update user and save, etc
return Redirect("Somewhere");
}
ViewData.Model = model;
return View("Index");
}
In OpenRasta:
UserViewModel Get()
{
var user = GetUser();
return new UserViewModel
{
Username = user.Username
};
}
OperationResult Post(UserViewModel model)
{
if (IsValid(model))
{
// update user and save, etc
return new OperationResult.SeeOther { RedirectUri =
"somewhere" };
}
return new OperationResult.OK { ResponseResource =
model };
}
Now as I understand it in Fubu you do a FubuContinuation.Redirect or a
FubuContinuation.Transfer which effectively calls the GET side of the
pair again. In this scenario that would mean I lose what the user
entered into the invalid form so I can't show it to them again. Now
this doesn't make sense so is where I think I must be grasping the
sharp and prickly end of the stick.
I haven't looked at the Fubu code in much depth but it seems to me
that if I'm not getting it completely wrong it would be useful to also
have something like FubuContinuation.Render(model) for the path where
you want it render what you have at that point. Then you would have a
trio of redirect, do something else or render what I've got.
Thoughts?
To unsubscribe from this group, send email to fubumvc-deve...@googlegroups.com.
http://notesdotnet.wordpress.com/2010/03/06/redirecting-in-fubu/
it's a different way of approaching but seems like it will work fine.
Adam
On Monday, March 8, 2010, Garry Shutler <ga...@robustsoftware.co.uk> wrote:
> Just seen Chad's response and another post from Jeremy came in while I was writing mine. Will review in the morning with extra feedback if applicable.Garry Shutler
>
> http://blog.robustsoftware.co.uk
> http://twitter.com/gshutler
>
>
> On 7 March 2010 22:10, Garry Shutler <ga...@robustsoftware.co.uk> wrote:
>
> Yeah, Joshua mentioned you guys do everything via ajax which is why this scenario hasn't raised it's head before.
> I agree on your second point. Having a method returning a FubuContinuation / ActionResult / OperationResult rather than a specific type is a nice way of saying "look more than one type of result might be coming out the other end here". Much more transparent.
>
>
> Whether you want to alter the behaviour of the current Transfer method rather than add an additional one is a call for yourselves. What you are suggesting seems to fit the bill though.
>
>
> Your third point is probably where you would end up if you wanted to rely heavily on conventions. This would probably be where I would eventually end up but I would like the option to start off with the stepping stone of your first point before making the leap (as no doubt other people who are new to the framework would). Again, that's your call.
>
>
> I'm going to mention something in OpenRasta. It's just an approach that might be worth considering:
> Poking yesterday around I saw that it appears you currently determine the view to render based on the return type of method being invoked. OR determines the view to render based on the type of the object returned from the method, subtle difference but can be quite powerful. It also leads to (what I think is) a greater separation between the processing of a request and the rendering of it. It's undoubtedly more complicated though so there's a balance to be struck.
>
>
> Thanks for your time, I'm hitting the sack now so won't be replying for about 9 hours.Garry Shutler
>
> http://blog.robustsoftware.co.uk
> http://twitter.com/gshutler
>
>
> On 7 March 2010 21:32, Jeremy D. Miller <jeremy...@yahoo.com> wrote:
>
> Ok, 3 options for you then (and this isn't really the scenario I was thinking for FubuContinuation anyway):
>
> 1. Return FubuContinuation.Transfer( the model you want shown ), and it goes right to the view w/ no second action getting put in there. I need a bit of work to get there to the "Inferred Action" / view w/o a corresponding action, but that's on the plate anyway. I need to add some conventional and explicit configuration to add behavior chains with no ActionCall, but there's absolutely nothing in the Fubu runtime model that forces you to have one in the first place.
>
> 2.) We could go back to the ISupportOverride model, but I hate that. Too weird, too much indirection. I like having the action return the FubuContinuation because it makes it obvious that
> there's a possible split in the workflow.
>
> 3.) If it's strictly for the Crud scenorio of "go forward if valid", just have a convention in Fubu that puts a behavior in front of every action that would need to be validated that redirects or continues to the basic action/view/output/whatever chain if it's valid or does the redirect for you if it's invalid. If you're doing a lot of this kind of stuff, that might be worth the extra complexity to avoid the repetitive coding.
>
>
> We do all of our form submissions w/ Ajax, so we never have to deal with this scenario.
>
>
> Jeremy D. Miller
> The Shade Tree Developer <http://codebetter.com/blogs/jeremy.miller>
> jeremy...@yahoo.com
Just to clarify what OpenRasta actually does and does not do...
OpenRasta has a reentrant pipeline in only one scenario, which is the
one where the system itself trips over, and we still want to do
content negotiation on the resulting error. It's a corner case that
exists as a fail safe.
As for the "weird workflow" code you talk about, not sure what you
refer to. I assume it's the ordering of pipeline contributors within a
pipeline. I believe you guys use a policy to inject your behaviors at
known points by doing it yourself, OR uses a fluent api to give
ordering guarantee to components, and platform-level known stages that
are guaranteed to exist for people not to trip over themselves by
taking on too many expectations.
Starting nested container scopes is only done when the system wants to
execute sub-requests, as opposed to simply execute other operations
within the same context, for server-side aggregation of content.
But as you say, because of some defaults that existed in RC, we have a
lot of singletons, which makes reexecuting a new pipeline on a new
resource a bit bad. This is corrected in RTM, so you can simply ask
for the IPipeline, and call one of the extension methods to execute
whatever you want on wahtever new input data you have found, and get /
replace the result...
Seb
On Mar 7, 4:54 pm, Adam Schroder <adamschro...@gmail.com> wrote:
> I had this very same question and was answered very succinctly by
> nieve just 12 hours ago. Checkout this blog post. It will explain all.
>
> http://notesdotnet.wordpress.com/2010/03/06/redirecting-in-fubu/
>
> it's a different way of approaching but seems like it will work fine.
>
> Adam
>
>
>
> On Monday, March 8, 2010, Garry Shutler <ga...@robustsoftware.co.uk> wrote:
> > Just seen Chad's response and another post from Jeremy came in while I was writing mine. Will review in the morning with extra feedback if applicable.Garry Shutler
>
> >http://blog.robustsoftware.co.uk
> >http://twitter.com/gshutler
>
> > On 7 March 2010 22:10, Garry Shutler <ga...@robustsoftware.co.uk> wrote:
>
> > Yeah, Joshua mentioned you guys do everything via ajax which is why this scenario hasn't raised it's head before.
> > I agree on your second point. Having a method returning a FubuContinuation / ActionResult / OperationResult rather than a specific type is a nice way of saying "look more than one type of result might be coming out the other end here". Much more transparent.
>
> > Whether you want to alter the behaviour of the current Transfer method rather than add an additional one is a call for yourselves. What you are suggesting seems to fit the bill though.
>
> > Your third point is probably where you would end up if you wanted to rely heavily on conventions. This would probably be where I would eventually end up but I would like the option to start off with the stepping stone of your first point before making the leap (as no doubt other people who are new to the framework would). Again, that's your call.
>
> > I'm going to mention something in OpenRasta. It's just an approach that might be worth considering:
> > Poking yesterday around I saw that it appears you currently determine the view to render based on the return type of method being invoked. OR determines the view to render based on the type of the object returned from the method, subtle difference but can be quite powerful. It also leads to (what I think is) a greater separation between the processing of a request and the rendering of it. It's undoubtedly more complicated though so there's a balance to be struck.
>
> > Thanks for your time, I'm hitting the sack now so won't be replying for about 9 hours.Garry Shutler
>
> >http://blog.robustsoftware.co.uk
> >http://twitter.com/gshutler
>
> > On 7 March 2010 21:32, Jeremy D. Miller <jeremydmil...@yahoo.com> wrote:
>
> > Ok, 3 options for you then (and this isn't really the scenario I was thinking for FubuContinuation anyway):
>
> > 1. Return FubuContinuation.Transfer( the model you want shown ), and it goes right to the view w/ no second action getting put in there. I need a bit of work to get there to the "Inferred Action" / view w/o a corresponding action, but that's on the plate anyway. I need to add some conventional and explicit configuration to add behavior chains with no ActionCall, but there's absolutely nothing in the Fubu runtime model that forces you to have one in the first place.
>
> > 2.) We could go back to the ISupportOverride model, but I hate that. Too weird, too much indirection. I like having the action return the FubuContinuation because it makes it obvious that
> > there's a possible split in the workflow.
>
> > 3.) If it's strictly for the Crud scenorio of "go forward if valid", just have a convention in Fubu that puts a behavior in front of every action that would need to be validated that redirects or continues to the basic action/view/output/whatever chain if it's valid or does the redirect for you if it's invalid. If you're doing a lot of this kind of stuff, that might be worth the extra complexity to avoid the repetitive coding.
>
> > We do all of our form submissions w/ Ajax, so we never have to deal with this scenario.
>
> > Jeremy D. Miller
> > The Shade Tree Developer <http://codebetter.com/blogs/jeremy.miller>
>
> > From: Garry Shutler <ga...@robustsoftware.co.uk>
> > To: fubumvc-de...@googlegroups.c
>
> > --
> > You received this message because you are subscribed to the Google Groups "FubuMVC Development Group" group.
> > To post to this group, send email to fubumv...@googlegroups.com.
> > To unsubscribe from this group, send email to fubumvc-deve...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/fubumvc-devel?hl=en.- Hide quoted text -
>
> - Show quoted text -