
STEP 7: CREATE THE ACCOUNT MANAGER LOGIN SCREEN
Create the logic for the Account Manager login screen in the Main.mxml file. The login screen launches the main Account Manager
user interface if a user logs in with valid credentials, and displays an error message if the credentials are invalid.
The Main.mxml default code contains several components that you'll either use as-is or modify:
•
Declarations—Defines user interface elements within a Flex application.
•
F3DesktopApplication—Connects the Force.com Flex desktop application to Force.com, provides the Force.com login and
authentication functionality, and handles the initial synchronization of data between Force.com and the Force.com Flex application.
Every Force.com Flex desktop application is contained within an F3DesktopApplication component. The requiredTypes
attribute on this component determine which Salesforce objects the desktop application can access.
•
Script—Contains the embedded ActionScript that defines the actions on the user interface elements defined in the
Declarations component. You will change the default ActionScript in this component.
•
States—Enables the application to determine which user interface to present.
•
The main UI for your application, which is in a Spark Group component. The component contains a layout component used
to arrange your UI elements, a VGroup component that creates a vertical grouping of the UI elements, and a Force.com Flex
component that renders a status bar at the bottom of the application.
Modify the rest of the Main.mxml default code as follows:
1. Remove the VGroup and Group components from the default code, and replace them with the following Spark Panel
component. The Panel component provides a screen entitled “Salesforce.com Login.” The screen has two input fields, Username
and Password, and a Login button. The component also provides a progress bar that appears while the application is processing
the login attempt.
<s:Panel
title="Salesforce.com Login"
includeIn="login"
horizontalCenter="0"
verticalCenter="0">
<s:layout>
<s:VerticalLayout paddingLeft="10"/>
</s:layout>
<mx:Form>
<mx:FormItem label="Username">
<s:TextInput id="username" text=""/>
</mx:FormItem>
<mx:FormItem label="Password" direction="horizontal">
<s:TextInput
id="password"
text=""
displayAsPassword="true"/>
<s:Button
label="Login"
enabled="{!app.loginPending}"
click="loginClickHandler(event)"/>
</mx:FormItem>
11
Commentaires sur ces manuels