com.triomotor.views

WorkOrderView

extends: AbstractView

This class calls the server to get orders and shows them in a List component. When the user clicks one order, this class sends an order selected Event to all the Objects that are registered as listeners of that event.
This class is similar to the ServiceOrders.as (viewed in detail in the first tutorial) We chose not to extend from ServiceOrders and extend from AbstractView insted.

Property Summary

private ListserviceOrders
private ComboBoxstatusComboBox
private TextInputlicense
private RecordSetworkOrders
private ConnectororderSelectedConnector
private ServiceworkOrdersService

Constructor Summary

WorkOrderView()

Method Summary

public fillComboBox(r:ResultEvent)
public reportError(fault:FaultEvent)
public static FILTER_FUNCTION(record:Object, obj:Object)
public filterWorkOrders(r:ResultEvent)
public change()
public selectionChange()
public updateOrderEvent(event:Number)
public updateStatus(r:ResultEvent)
private onLoad()
private init()
private createConnection()

Property Details

serviceOrders

private serviceOrders:List

An instance of List that has been initialized on the stage with instance name serviceOrders.

statusComboBox

private statusComboBox:ComboBox

An instance of ComboBox that has been initialized on the stage with instance name statusComboBox.

license

private license:TextInput

An instance of TextInput that has been initialized on the stage with instance name license.

workOrders

private workOrders:RecordSet

A local reference of the recordset received from the server with the list of orders

orderSelectedConnector

private orderSelectedConnector:Connector

A connector used to notify when an order is selected

See Also
TrioMotor.orderSelected

workOrdersService

private workOrdersService:Service

A Service object that connects to the CFC mx.services.workOrder

Constructor Details

WorkOrderView

WorkOrderView()

Method Details

fillComboBox

public fillComboBox(r:ResultEvent):Void

Description: fills the statusComboBox with the query received
Assumptions: - We expect a query as a parameter with the columns STATUS_NAME and STATUS_ID
Data structures:RecordSet
Globals: uses statusComboBox
Calls: bindFormatStrings() in the DataGlue
Is Called by: the server via RelayResponder in response to the getStatusCodes() call

Parameters
r (ResultEvent) - A RecorSet object
Returns
void

reportError

public reportError(fault:FaultEvent):Void

Description: traces errors in the case problems ocurr
Assumptions: none
Globals: none
Calls: none
Is Called by: This function is called byRelayResponder when an Error ocurrs

Parameters
fault (FaultEvent) -
Returns
Void

FILTER_FUNCTION

static public FILTER_FUNCTION(record:Object,
                              obj:Object):Boolean

Description: A custom function for filtering recordsets
Assumptions: record has the properties: STATUS_ID and LICENSE. And obj has the properties txt and id
Globals: none
Calls: none
Is Called by: filter() in the workOrders recordSet inside the filterWorkOrders method

Parameters
record (Object) - An item from the RecordSet
obj (Object) -
Returns
Boolean

filterWorkOrders

public filterWorkOrders(r:ResultEvent):Void

Description: filters the List serviceOrders when the user writes in the txt field and/or selects the comboBox
Assumptions: - A RecordSet as a parameter with the columns LICENSE, WORK_ORDER_ID, and STATUS_NAME
- serviceOrders has been already instantiated on the stage
- orderSelectedConnector is instantiated
Data structures:RecordSet
Globals: uses workOrders, serviceOrders, statusComboBox
_root.workOrder( this is a global variable that it's set in the html and passed through flash vars)
Calls: serviceOrders: addItem(), removeAll(), and getItemAt()
filter() in workOrders
fireEvent() in orderSelectedConnector
Is Called by: the server via RelayResponder in response to the getWorkOrders() call and by the method change()

Parameters
r (ResultEvent) - A query Object
Returns
void

change

public change():Void

Description: Calls filterWorkOrders when dropDown is selected or text is typed in the TextInput
Assumptions: none
Globals: none
Calls: filterWorkOrders()
Is Called by: statusComboBox and license because this class is registered as a listener of the change event in both components

Returns
Void

selectionChange

public selectionChange():Void

Description: Sends an event to all the registered listeners in the connector orderSelectedConnector
Assumptions: orderSelectedConnector is intantiated
Globals: uses serviceOrders
Calls: fireEvent() in the orderSelectedConnector
Is Called by: The List serviceOrders because this class is registered as a listener of the change event via a proxy Object see #onLoad

Returns
Void

updateOrderEvent

public updateOrderEvent(event:Number):Void

Description: requests the information of the order that needs an update to the server. This usually happens when the user clicks notify in the DetaiView and the order changes the status, therefore it needs to be updated
Assumptions: workOrdersService is intantiated
Globals: uses workOrdersService
Calls: getWorkOrderDetail() in the workOrdersService, a method on the CFC mx.services.workOrder
Is Called by: application.updateOrder Connector because this is registered as a listener of it.

Parameters
event (Number) - Work order
Returns
Void
See Also
TrioMotor.updateOrder

updateStatus

public updateStatus(r:ResultEvent):Void

Description: updates the status of the item received in the list
Assumptions: - We expect a RecordSet as a parameter with the columns STATUS_NAME, LICENSE, and WORK_ORDER_ID with only one item
Data structures:RecordSet
Globals: uses serviceOrders and orderSelectedConnector
Calls: fireEvent() in the orderSelectedConnector
Is Called by: the server via RelayResponder in response to the getWorkOrderDetail() call

Parameters
r (ResultEvent) - A RecorSet Object
Returns
Void

onLoad

private onLoad():Void

Description: Registers this class as a listener of the event change in the following components:
license, serviceOrders, and statusComboBox
Assumptions: license, serviceOrders, and statusComboBox have already been instantiated on the stage
Globals: Uses the following globals:
license, statusComboBox, serviceOrders
Calls: addEventListener() in serviceOrders, statusComboBox, and license
Is Called by: This function is called automatically by the player when this object is completely loaded. This is possible because this class extends from the MovieClip Class

Returns
void

init

private init():Void

Description: Registers this object as listener of update order event in the Connector updateOrder. Calls the create connection method to connect with the server
Assumptions: application is already instantiated
Globals: uses application, orderSelectedConnector
Calls: addListener() in the application.updateOrder. And createConnection()
Is Called by: setApplication() in its super class AbstractView

Returns
Void

createConnection

private createConnection():Void

Description: Creates a connection with the server to the CFC mx.services.workOrder and the CFC mx.services.statusCode and gets the work orders and the status codes from those Services
Assumptions: application is already instantiated
Globals: uses application and workOrdersService
Calls: getWorkOrders() in workOrdersService ( this is a call to the CFC mx.services.workOrder)
getStatusCodes() in status_Code ( this is a call to the CFC mx.services.statusCode)
Is Called by: init()

Returns
Void