FubuContinuation.RedirectTo from a PostHandler to a GetHandler

51 views
Skip to first unread message

David Craft

unread,
Feb 7, 2012, 10:02:01 AM2/7/12
to FubuMVC Development Group
Hi,

I've reached a dead end with the fubucontinuations that I'm hoping you
guys can help me with:

I post some information to a PostHandler which takes a PostInputModel
as follows:

public class PostHandler
{
public FubuContinuation Execute(PostInputModel inputModel)
{
return FubuContinuation.RedirectTo<GetHandler>(
x => x.Execute(new GetInputModel
{
Id = inputModel.Id
}));
}
}

The inputModel is populated correctly with an Id, However when the
Continuation arrives at the GetHandler the Id of the GetInputModel is
blank.

Any ideas?

Dave

Gary Cox

unread,
Feb 7, 2012, 10:24:29 AM2/7/12
to fubumv...@googlegroups.com
Change your code like so:

public class PostHandler
       {
               public FubuContinuation Execute(PostInputModel inputModel)
               {
                       return FubuContinuation.RedirectTo(new GetHandler
                                                               {
                                                                       Id = inputModel.Id
                                                               });
               }
       } 

The generic implementation is more of a pointer to the action and doesn't actually pass your created model.


--
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 at http://groups.google.com/group/fubumvc-devel?hl=en.




--
Thank you,
Gary Cox

Gary Cox

unread,
Feb 7, 2012, 10:26:51 AM2/7/12
to fubumv...@googlegroups.com
Doh! I messed that up, use your model type:

public class PostHandler
       {
               public FubuContinuation Execute(PostInputModel inputModel)
               {
                         public FubuContinuation Execute(PostInputModel inputModel)
                         {
                                   return FubuContinuation.RedirectTo(new  GetInputModel 
                                                               {
                                                                       Id = inputModel.Id
                                                               });
                                 } 
               }
       } 

On Tue, Feb 7, 2012 at 9:02 AM, David Craft <david...@icheque.com> wrote:
--
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 at http://groups.google.com/group/fubumvc-devel?hl=en.

Joshua Arnold

unread,
Feb 7, 2012, 1:40:24 PM2/7/12
to fubumv...@googlegroups.com
@David,

You're requesting a Redirect from the FubuContinuation so you're getting an HTTP redirect. Unless your values are specified as route inputs or query string parameters, you're not going to have anything set. The handlers convention allows you to specify route inputs via the "get_{Property}_handler" naming convention. In your case, it would be: "get_Id_handler". 

On Tue, Feb 7, 2012 at 9:02 AM, David Craft <david...@icheque.com> wrote:

David Craft

unread,
Feb 13, 2012, 10:22:17 AM2/13/12
to FubuMVC Development Group
Hi thanks both of you,

I've finally had a chance to play with this. Here are my findings:

To get this to work I had to do the following:

1. Create a Get_Id_Handler like Josh suggested.
2. Create a new input Model called GetIdInputModel with the Id
property on it.
3. Finally call RedirectTo with a new GetIdInputModel like Gary
suggested.

Then it seems to work fine.

public class PostHandler
{
public FubuContinuation Execute(PostInputModel
inputModel)
{
return FubuContinuation.RedirectTo(
x => x.Execute(new GetIdInputModel
{

Id = inputModel.Id
}));
}
}

Josh is there a good reference (apart from code) where I can read a
bit more about the handler conventions. Perhaps I should update the
fubu continuation recipe with these findings? Think it's worth it?

Dave

David Craft

unread,
Feb 13, 2012, 10:27:09 AM2/13/12
to FubuMVC Development Group
Edit. Here is the full code with a working redirect.
====================================

public class GetIdInputModel
{
public Guid Id { get; set; }
}

public class Get_Id_Handler
{
public Get_Id_Handler()
{
}

public ViewModel Execute(GetIdInputModel inputModel)
{
// inputModel.Id is now populated

return new ViewModel();
}
}


public class PostHandler
{
public FubuContinuation Execute(PostInputModel
inputModel)
{
return FubuContinuation.RedirectTo(new
GetIdInputModel { Id = inputModel.Id });
}
}
Reply all
Reply to author
Forward
0 new messages