Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4023202
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:34:11+00:00 2026-05-20T10:34:11+00:00

I’m trying to figure out to create a behavior that will copy a boolean

  • 0

I’m trying to figure out to create a behavior that will copy a boolean site configuration value to an output model.

This way I don’t have to copy the bool in each action who’s view requires it, but can simply add the behavior to the controller actions that need this value.

In some of the older versions of FubuMVC, I believe behaviors could modify the output model after it’s left the controller. But I’m not sure how to do this in the more recent versions of FubuMVC (or I’ve forgotten).

Can anyone give me an example of or point me in the direction of the best practice for copying a site configuration value to an output model?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:34:12+00:00Added an answer on May 20, 2026 at 10:34 am

    Let’s say I had an output model called HomeViewModel that had a property called FooterText that I wanted loaded from settings object (let’s say HomeSettings) that was retrieved from the container (i.e. StructureMap).

    The Behavior

    My behavior would look something like this:

    public class HomeFooterBehavior : BasicBehavior
    {
        private readonly HomeSettings _settings;
        private readonly IFubuRequest _request;
    
        public HomeFooterBehavior(HomeSettings settings, IFubuRequest request)
            : base(PartialBehavior.Executes)
        {
            _settings = settings;
            _request = request;
        }
    
        protected override DoNext performInvoke()
        {
            SetupFooter();
    
            return DoNext.Continue;
        }
    
        public void SetupFooter()
        {
            var viewModel = _request.Find<HomeViewModel>().First();
    
            viewModel.HomeFooterText = _settings.FooterText;
        }
    }
    

    This behavior takes in the HomeSettings object and the IFubuRequest object (both injected dependencies) and then gets the HomeViewModel (output model) from the request and then sets the HomeFooterText property on the output model based on the value from the settings object.

    NOTE: I’m assuming that you’ve already got your HomeSettings object wired up in the container (for example, using the ISettingsProvider stuff built into FubuMVC). If you don’t already have this, let me know and I can post some code on how to do that.

    Wiring Up The Convention

    To wire up the behavior, you’ll need to define the convention through an IConfigurationAction, for example:

    public class HomeFooterBehaviorConfiguration : IConfigurationAction
    {
        public void Configure(BehaviorGraph graph)
        {
            graph.Actions()
                .Where(x => x.HasOutput && 
                            x.OutputType().Equals(typeof(HomeViewModel)))
                .Each(x => x.AddAfter(Wrapper.For<HomeFooterBehavior>()));
        }
    }
    

    This is a real dumb convention for demonstration purposes. In your project, you might make it a little more generic. For example, any output model that has an attribute on it, or implements a specific interface, etc. In fact, you might want to inspect all output models to see if they contain any properties that match a certain criteria (for example, all properties that end with “Settings” – like “FooterSettings” or something).

    Don’t be afraid to define wide sweeping conventions like this due to performance concerns since all this convention code runs at start-up time and not on every request.

    Note the “AddAfter” call and the “Wrapper.For” call. That’s the key in that it places your behavior after the controller action is executed, but before the view is rendered.

    Now that you have your behavior and your convention defined, it’s time to wire it up in your FubuRegistry.

    Wiring Up Your Convention in your FubuRegistry

    After the call to “Routes.” in your FubuRegistry, add a line like this:

    ApplyConvention<HomeFooterBehaviorConfiguration>();
    

    Recompile and it should work.

    Please let me know if you run into any problems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.