<?xml version="1.0" encoding="UTF-8"?>
<process xmlns:blue="http://www.e-marson.com/bluelemon">
<descriptor>
<name>com/emarson/lemonade/examples/mobank/Validate</name>
<version>1.0</version>
<description>
This is the action invoked when user is trying to continue
after filling the AuthenticationScreen text fields:
userId and password.
This action:
- reads the values of the text fields,
- if any of them is empty, shows the warning alert and returns,
- forwards the processing to the Authenticate node in the
"network" location.
</description>
<vendor>E-MARSON</vendor>
</descriptor>
<path>
<action name="go to the authentication screen screen">
<type>general/bluelemon/code</type>
<definition resultTo="actionForCancel">
<blue:call node="com/emarson/lemonade/examples/mobank/AuthenticationScreen"
location="@com/emarson/lemonade/examples/mobank"/>
</definition>
</action>
<action name="read data, verify and continue">
<type>general/bluelemon/code</type>
<definition resultTo="result">
<blue:call manager="GeneralManager" method="getCurrent"
toVariable="form"
castTo="com/emarson/lemonade/bluelemon/midp1/Form"/>
<blue:call object="form" method="getItem"
toVariable="userIdField"
castTo="com/emarson/lemonade/bluelemon/midp1/TextField">
<blue:argument type="byte" value="0"/>
</blue:call>
<blue:call object="userIdField" method="getString"
toVariable="userId"/>
<blue:call object="form" method="getItem"
toVariable="passwordField"
castTo="com/emarson/lemonade/bluelemon/midp1/TextField">
<blue:argument type="byte" value="1"/>
</blue:call>
<blue:call object="passwordField" method="getString"
toVariable="password"/>
<blue:call manager="UtilsManager" method="length"
toVariable="userIdLength">
<blue:argument type="variable" name="userId"/>
</blue:call>
<blue:call manager="UtilsManager" method="length"
toVariable="passwordLength">
<blue:argument type="variable" name="password"/>
</blue:call>
<blue:call manager="UtilsManager" method="=="
toVariable="userIdIsEmpty">
<blue:argument type="variable" name="userIdLength"/>
<blue:argument type="byte" value="0"/>
</blue:call>
<blue:call manager="UtilsManager" method="=="
toVariable="passwordIsEmpty">
<blue:argument type="variable" name="passwordLength"/>
<blue:argument type="byte" value="0"/>
</blue:call>
<blue:call manager="UtilsManager" method="OR"
toVariable="anyStringIsEmpty">
<blue:argument type="variable" name="userIdIsEmpty"/>
<blue:argument type="variable" name="passwordIsEmpty"/>
</blue:call>
<blue:if isTrue="anyStringIsEmpty">
<blue:newInstance module="com/emarson/lemonade/bluelemon/midp1/Alert"
toVariable="alert"/>
<blue:call object="alert" method="initialize">
<blue:argument type="String" value="Incorrect data"/>
<blue:argument type="String" value="The user id and password cannot be empty."/>
<blue:argument type="byte" value="AlertType.WARNING"/>
<blue:argument type="short" value="1500"/>
</blue:call>
<blue:call manager="GeneralManager" method="setCurrent">
<blue:argument type="variable" name="alert"/>
</blue:call>
<blue:return/>
</blue:if>
<blue:call node="com/emarson/lemonade/examples/mobank/InitializeDownloading"
location="@com/emarson/lemonade/examples/mobank">
<blue:argument type="String" value="Logging in"/>
<blue:argument type="String" value="You are being authenticated..."/>
<blue:argument type="String" value="Cancel"/>
<blue:argument type="byteArr" contextKey="actionForCancel"/>
</blue:call>
<blue:try>
<blue:call node="com/emarson/lemonade/examples/mobank/Authenticate"
location="network">
<blue:argument type="variable" name="userId"/>
<blue:argument type="variable" name="password"/>
</blue:call>
</blue:try>
<blue:catch exception="com/emarson/midp/IOException">
<blue:call node="com/emarson/lemonade/examples/mobank/AuthenticationScreen"
location="@com/emarson/lemonade/examples/mobank"/>
<blue:call node="com/emarson/lemonade/examples/mobank/authentication/Screen"
location="@com/emarson/lemonade/examples/mobank"/>
<blue:newInstance module="com/emarson/lemonade/bluelemon/midp1/Alert"
toVariable="alert"/>
<blue:call object="alert" method="initialize">
<blue:argument type="String" value="Connection problem"/>
<blue:argument type="String" value="Can't connect to the Internet."/>
<blue:argument type="byte" value="AlertType.ERROR"/>
<blue:argument type="short" value="Alert.FOREVER"/>
</blue:call>
<blue:call manager="GeneralManager" method="setCurrent">
<blue:argument type="variable" name="alert"/>
</blue:call>
</blue:catch>
<blue:call node="com/emarson/lemonade/examples/mobank/FinalizeDownloading"
location="@com/emarson/lemonade/examples/mobank"/>
</definition>
</action>
<finish name="done">
<return>result</return>
</finish>
</path>
</process>