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™

17.7. Implementation and Testing

The first thing you need to take care of is restricting access to the write view. If you go to the write view without being logged in there will be no user id for the currentUser and the submitPost function will give you a null reference in error when trying to retrieve the userId to set it as the authorId for the PostVO. To restrict access to the write view, edit the writeButton in the ApplicationControlBar in the MainView component to match the following:

<mx:LinkButton label="Write" id="writeButton"
visible="{(this.model.currentUser == null)
? false:(this.model.currentUser.accessLevel == 100)}" click="new
ChangeMainViewEvent(ChangeMainViewEvent.WRITE_VIEW).dispatch();"/>

Here the visible property is tied to the value of a ternary expression that checks to see if there is a current user. Simply checking to see if accessLevel equals 100 will not work and will cause the button to be shown until a user logs in and there is a value for the accessLevel property, so you first have to determine whether the currentUser property is null. If there is no user, the button is hidden. If there is a user, the access level is checked and the button is displayed if the access level is 100 (indicating that the user is an author).

Now edit the writeView HBox, adding the PostEditor view below the label:

<mx:HBox id="writeView"> <mx:Label styleName="viewHeader" text="Write"/> <views:PostEditor width="100%" postSubmitted="{this.model.postSubmissionStatus}"/> </mx:HBox> ...
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