<?xml version="1.0" encoding="UTF-8"?>
<process xmlns:blue="http://www.e-marson.com/bluelemon">

  <descriptor>
    <name>com/emarson/lemonade/examples/mobank/AuthenticationScreen</name>
    <version>1.0</version>
    <description>
      This is the screen with two text fields to specify userId and password.
      Both the fields are required.
    </description>
    <vendor>E-MARSON</vendor>
  </descriptor>

  <path>

    <!-- ASSOCIATIONS --->

    <!-- association to exit from MIDlet --->
    <subprocess name="action for 'Exit'">
      <source>com/emarson/lemonade/templates/ExitFromApplication</source>
      <resultTo>actionForExit</resultTo>
    </subprocess>
    
    <!-- association to Validate --->
    <subprocess name="action for 'Continue'">
      <source>com/emarson/lemonade/examples/mobank/Validate</source>
      <resultTo>readFieldsAndProceed</resultTo>
    </subprocess>
    
    
    <!-- INSTRUCTION --->

    <action name="a form to specify user data">
      <type>general/bluelemon/code</type>
      <definition resultTo="screen">

        <!-- create the first text field --->
        <blue:newInstance module="com/emarson/lemonade/bluelemon/midp1/TextField"
                          toVariable="userIdField"/>


        <!-- set the title, content, limit the size to 8 --->
        <blue:call object="userIdField" method="initialize">
          <blue:argument type="String" value="User ID:"/>
          <blue:argument type="String" value=""/>
          <blue:argument type="byte" value="8"/>
          <blue:argument type="byte" value="TextField.ANY"/>
        </blue:call>

        <!-- create the second text field --->
        <blue:newInstance module="com/emarson/lemonade/bluelemon/midp1/TextField"
                          toVariable="passwordField"/>


        <!-- 
          set the title, content, limit the size to 8 and set it's 
          type as password (ANY | PASSWORD)
        --->

        <blue:call object="passwordField" method="initialize">
          <blue:argument type="String" value="Password:"/>
          <blue:argument type="String" value=""/>
          <blue:argument type="byte" value="16"/>
          <blue:argument type="int" value="TextField.ANYORPASSWORD"/>
        </blue:call>

        <!-- create the form... --->
        <blue:newInstance module="com/emarson/lemonade/bluelemon/midp1/Form"
                          toVariable="form"/>


        <!-- ...set its title...  --->
        <blue:call object="form" method="initialize">
          <blue:argument type="String" value="moBank - log in"/>
        </blue:call>

        <!-- ... and put both of the text fields there. --->
        <blue:call object="form" method="appendItem">
          <blue:argument type="variable" name="userIdField"/>
        </blue:call>
        <blue:call object="form" method="appendItem">
          <blue:argument type="variable" name="passwordField"/>
        </blue:call>

        <!-- add the action to exit from the application --->
        <blue:call manager="UtilsManager" method="getActionCommand"
                   toVariable="command">

          <blue:argument type="String" value="Exit"/>
          <blue:argument type="byte" value="ActionCommand.EXIT"/>
          <blue:argument type="byte" value="0"/>
          <blue:argument type="byteArr" contextKey="actionForExit"/>
        </blue:call>

        <blue:call object="form" method="addCommand">
          <blue:argument type="variable" name="command"/>
        </blue:call>

        <!-- add the action to continue --->
        <blue:call manager="UtilsManager" method="getActionCommand"
                   toVariable="command">

          <blue:argument type="String" value="Continue"/>
          <blue:argument type="byte" value="ActionCommand.OK"/>
          <blue:argument type="byte" value="0"/>
          <blue:argument type="byteArr" contextKey="readFieldsAndProceed"/>
        </blue:call>

        <blue:call object="form" method="addCommand">
          <blue:argument type="variable" name="command"/>
        </blue:call>

        <!-- show the form on the device's screen --->
        <blue:call manager="GeneralManager" method="setCurrent">
          <blue:argument type="variable" name="form"/>
        </blue:call>

      </definition>
    </action>

    <finish name="done">
      <return>screen</return>
    </finish>

  </path>

</process>