Right way to handle the logic inside the view, especially when mediator only has access to the model ?

vishwas.gagrani's Avatar


09 Oct, 2012 07:46 AM

I have noticed this problem many times.
Also went through this : http://knowledge.robotlegs.org/discussions/questions/433-if-i-dont-...
however yet a doubt in mind

It's mentioned there in the Robotlegs knowledge base "Mediator should not contain the logic". But the problem i face is that many times much of the logic inside the view is dependdent upon many of the variables inside statsModel.
The way i handle is to make an initView function in mediator ( that is called when mediator is created), that passes all useful variables from statsmodel into the view. This way all the useful variables can be accessed by view.

However this can't be done everytime, and i end up with a logic inside mediator that uses mediator variables to decide the fate of view.

I want to know what's the right way to handle the situation.


  1. 1 Posted by neil on 09 Oct, 2012 12:24 PM

    neil's Avatar

    I usually either have changeable logic as compositable classes that can be set on the view, or some form of adaptor that wraps the view, does its stuff, then dispatches to the mediator to pass on.

  2. 2 Posted by Bruce on 18 Oct, 2012 02:04 PM

    Bruce's Avatar

    I have a similar issue. Say my service executes, and updates my model. My mediator stufs the model data into the view.

    However, what if I want to use the same data in another view, but the format of the data required by the view is slightly different. Maybe I need to compute a "total" for a datagrid or the data should be alpha vs numeric or it wants percentage as 0.15 vs 15

    Because the "orientation" of the data is really view specific, it would seem to me that this logic should not be in the model. The natural place seems to be in the mediator?

  3. 3 Posted by neil on 18 Oct, 2012 02:23 PM

    neil's Avatar

    @bruce if a total field uses a different algorithm for each view, then maybe it should be in the view?

    or again you could encapsulate that logic in a function or class that can be passed into the view.

  4. 4 Posted by Bruce on 19 Oct, 2012 06:45 PM

    Bruce's Avatar

    Yeah, I have the logic in the view now ... seemed like the most sensible place for it ..

  5. 5 Posted by neil on 23 Oct, 2012 05:10 PM

    neil's Avatar

    can this thread be closed now?

  6. vishwas.gagrani closed this discussion on 23 Oct, 2012 05:24 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac