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

  <descriptor>
    <name>com/emarson/lemonade/examples/mobank/moaccount/TransferScreen</name>
    <version>1.0</version>
    <description>
      This is the screen with two text fields.
      User can specify the ammount of money to transer and the 
      target account number. The validation is being processed,
      as both of those fields are required.
    </description>
    <vendor>E-MARSON</vendor>
  </descriptor>

  <path>

    <!-- ASSOCIATIONS --->
    
    <!-- association to MainScreen --->
    <action name="action for 'Cancel'">
      <type>general/bluelemon/code</type>
      <definition resultTo="goToMainScreen">
        <blue:call node="com/emarson/lemonade/examples/mobank/moaccount/MainScreen"
                         location="@com/emarson/lemonade/examples/mobank/moaccount"/>

      </definition>
    </action>
    
    <!-- association to Validate --->
    <subprocess name="action for 'OK'">
      <source>com/emarson/lemonade/examples/mobank/moaccount/Validate</source>
      <resultTo>readFieldsAndProceed</resultTo>
    </subprocess>
    
    
    <!-- INSTRUCTION --->

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

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


        <!-- 
          set the title, content, limit the size to 8 and set
          it as a numeric field
        --->

        <blue:call object="ammountField" method="initialize">
          <blue:argument type="String" value="Ammount [EUR]:"/>
          <blue:argument type="String" value=""/>
          <blue:argument type="byte" value="8"/>
          <blue:argument type="byte" value="TextField.NUMERIC"/>
        </blue:call>

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


        <!-- 
          set the title, content, limit the size to 16 and set
          it as a numeric field
        --->

        <blue:call object="targetAccountField" method="initialize">
          <blue:argument type="String" value="To account:"/>
          <blue:argument type="String" value=""/>
          <blue:argument type="byte" value="16"/>
          <blue:argument type="byte" value="TextField.NUMERIC"/>
        </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="Transfer"/>
        </blue:call>

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

        <!-- add the action to go back to the main screen --->
        <blue:call manager="UtilsManager" method="getActionCommand"
                   toVariable="command">

          <blue:argument type="String" value="Cancel"/>
          <blue:argument type="byte" value="ActionCommand.BACK"/>
          <blue:argument type="byte" value="0"/>
          <blue:argument type="byteArr" contextKey="goToMainScreen"/>
        </blue:call>

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

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

          <blue:argument type="String" value="OK"/>
          <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>