Skip to Main Content
Professional Cairngorm™
book

Professional Cairngorm™

by Jeremy Wischusen
November 2009
Intermediate to advanced content levelIntermediate to advanced
357 pages
8h 20m
English
Wrox
Content preview from Professional Cairngorm™

19.6. Views

You need views that will allow the user to enter comments and display the comments for the currently selected posts. You will continue the practice, started in Chapter 18 on loading posts, of breaking views down into distinct components.

Start by creating the view that will allow users to enter comments. In the com.FlexBlog.views package create a new component based on Form. Name it CommentForm. 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" visible="{this.model.currentUser != null}"> <mx:Script> <![CDATA[ import com.FlexBlog.events.AddCommentEvent; import com.FlexBlog.models.FlexBlogModel; import com.FlexBlog.valueobjects.CommentVO; import mx.controls.Alert; import mx.events.ValidationResultEvent; private var model:FlexBlogModel =FlexBlogModel.getInstance() private function submitComment(event:MouseEvent):void{ if (this.bodyValidator.validate().type == ValidationResultEvent.INVALID) { Alert.show('Please correct the highlighted fields. Mouse over each field for an error description.'); }else{ this.submitCommentButton.enabled = false; var comment:CommentVO =new CommentVO(); comment.userId = this.model.currentUser.userId; comment.body = this.comment.text; comment.postId =this.model.currentPost.postId; new AddCommentEvent(comment).dispatch(); } } public function set commentSubmitted(status:String):void{ if (status == 'success'){ ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Professional Java® JDK®, 6th Edition

Professional Java® JDK®, 6th Edition

W. Clay Richardson, Jeff Scanlon, Donald Avondolio, Mark W. Mitchell, Scot Schrager

Publisher Resources

ISBN: 9780470497265Purchase book