What is the difference between MVC "action based" and "component based"?

8

This Answer of this question answers the advantages and disadvantages of each, but without explaining the difference between them.

I ask:

  • What's the difference between them?
  • Examples of frameworks that use each of them.

Note: Let's leave out the advantages / disadvantages as this can be answered in the question linked above

    
asked by anonymous 25.06.2014 / 13:17

1 answer

8

Component Based Frameworks

Component Based Framework maintains synchronization between the component states of the view and its server-side data model.

>

When the user interacts with the screen, the changes made are, at any given moment, reflected in the template that stays on the server.

In JSF, for example, the "screen" is generated by a facelet , which is nothing more than an XML that defines which components are displayed to the user and associate the values of those components to a object ( Java Bean ) that stays on the server. These components are then rendered in HTML and, when the user performs an action, JSF updates the objects on the server.

I did not find an adequate visual representation, but something approximate in Caelum article on the theme :

Incomponent-basedframeworks,viewisresponsibleformappingvaluestobeansandtothemodel.Theaboveimageillustratestheorderofcalls:

  • Theuserperformsanactiononthesystem
  • ThefrontcontrolleroftheframeworkupdatesthecomponentsoftheviewwiththecurrentstateTheManagedBeanmethodiscalled(usingJSFasanexample),andcanexecutesomebusinessrulewiththenewvalues
  • Finally,thesystemmodelisupdated
  • ActionBasedFrameworks

    ActionBasedframeworksdonotnecessarilymaintainthislinkbetweenserverandclientstates.

    Thisisnottosaythatthedevelopercannotstorestateontheserver,forexample,intheusersession,butthatthelinkbetweenthemodelandtheviewisnotascoupledasintheComponentBased.

    AnActionBasedframeworkwilloftendirectlyreceiveHTTPrequests.Thismakestheactionbasedmodelmoreflexible,asthedevelopercanoptforanykindofviewthatgeneratesacompliantHTTPrequest.

    Considerthefollowingillustration(fromthesame previous source ):

    Thesummaryoftheexecutionstepsis:

  • Theuserperformsanactiononthesystem
  • Thefrontcontrolleroftheframeworkdirectstherequestandparameterstoacontroller
  • controllerreadstherequiredparametersandexecutesbusinessrulesthatupdatethemodel
  • Thecontrollerreturnsaviewfortheuser

    Conclusion

    Wecansaythatcomponentbasedframeworksaremorefocusedonviews(withitscomponentsthatmapthemodelanduserdata)basedparametersaremorecenteredoncontrollers.

    Examplesofframeworks are already in the response quoted in the question .

        
    27.06.2014 / 17:49