O'Reilly logo

Professional Cairngorm™ by Jeremy Wischusen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

18.1. Loading Posts Overview

The load posts feature has the following requirements:

  • When users arrive at the application, they should be presented with a list of the most recent posts sorted by date. The post retrieval service will provide them in this order.

  • The most recent post should be displayed automatically.

  • When users click on one of the titles in the recent posts list, the full post should be displayed in place of the currently displayed post.

You can load posts by triggering the appropriate event when the application loads. You are already doing this for the loading of the categories. Since there are now a number of things that need to occur when the applications loads, you are going to centralize these things by creating an event and command class that will execute when the application loads. The command class that gets triggered when the application loads will then be responsible for triggering any events that need to occur. This will also make creating new main views simpler, since all these views have to do is dispatch a single event, rather than remember a list of events that need to be dispatched.

You can display a full post by binding a view to a property on the model that holds a PostVO representing the currently selected post.

Since the recent posts service returns the posts in the order of their creation dates, displaying the most recent post is simply a matter of taking the first item in the list of posts returned by the service and assigning it to the property ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required