Obecto Training Portal

Icon

sharing our knowledge

MVC Example – Refactored

DOWNLOAD REFACTORED VERSION OF THE MVC EXAMPLE

What’s included in the re-factored version?

  • the MVC approach in now demonstrated not only for the module, but also for the item renderer used in the list component
  • the model adapter pattern is demonstrated too
  • some other minor refinements

Adapting the Model into a Presentation Model

Let’s see the Model Adapter pattern in more detail:

The MXML usage of the model adapter is pretty straight-forward – you can see this in the StatisticsView.mxml:

<programmerListItemModel:ProgrammerListItemModelAdapter id="modelAdapter"
    source="{model.programmers}"/>

And then instead of using the model.programmers you can use modelAdapter.resultCollection:

<list:CustomLayoutList id="list" styleName="programmersList" width="550"
    layout="{model.inAdvancedView ? verticalLayout : fluidLayout}"
    dataProvider="{modelAdapter.resultCollection}"
    itemRenderer="{new ClassFactory(ProgrammerListItem)}"/>

This adaptation is actually in a way demonstration of what means to have a pure abstract model and a presentation model (like in the MVP pattern).