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

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 ...

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