17.6. Views

The view for editing a post is a simple form. The information that the user needs to provide is the post title, body, and category. All the additional information for creating the post can be retrieved from the currentUser property of the ModelLocator or known values. The authorId will always be the id of the current user and the createdOn date is always the current date, which is handled by the database.

In the com.FlexBlog.views package create a new component named PostEditor, based on form. Remember to clear the height and width from the creation dialog. Edit the component to match the following:

<?xml version="1.0" encoding="utf-8"?> <mx:Form xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ import com.FlexBlog.events.AddPostEvent; import com.FlexBlog.valueobjects.CategoryVO; import com.FlexBlog.valueobjects.PostVO; import mx.controls.Alert; import mx.events.ValidationResultEvent; import com.FlexBlog.models.FlexBlogModel; [Bindable] private var model:FlexBlogModel = FlexBlogModel.getInstance(); private function submitPost(event:MouseEvent):void{ var errorMesssage:Boolean =false; if (this.titleValidator.validate().type == ValidationResultEvent.INVALID){ errorMesssage= true; } if (this.bodyValidator.validate().type == ValidationResultEvent.INVALID){ errorMesssage= true; } if(errorMesssage){ Alert.show('Please correct the highlighted fields. Mouseover each field for an error description.'); }else{ this.submitPostButton.enabled = false; var post:PostVO ...

Get Professional Cairngorm™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.