LoginScreen.lzx
<library>
<class name="LoginScreen" extends="BorderedBox" bgcolor="$once{COLORS.LOGIN_BG}" width="500" height="325" borderColor="$once{COLORS.LOGIN_BORDER}">
<node name="i18n" datapath="i18nDS:/app/login">
<attribute name="loginSuccess" type="string" value="$path{'success/text()'}"/>
<attribute name="loginMessage" type="string" value="$path{'loginMessage/text()'}"/>
<attribute name="missingData" type="string" value="$path{'missingData/text()'}"/>
</node>
<ServiceConnector name="loginConn" form="$once{parent}">
<method name="handleResult" args="message">
form.searchSubnodes("name", "messageBox").setAttribute('text', message);
</method>
</ServiceConnector>
<attribute name="bordersize" type="number" value="4"/>
<method name="collectValues">
var values = new Array();
values['login'] = this.loginName.text;
values['password'] = this.password.text;
return values;
</method>
<method name="disable">
this.commit.setAttribute('enabled', false);
</method>
<method name="enable">
this.commit.setAttribute('enabled', true);
</method>
<method name="showError" args="messageTxt">
this.messageBox.setAttribute('text', messageTxt);
</method>
<method name="showMessage" args="key">
if (key != null) {
this.messageBox.setAttribute('text', this.i18n[key]);
} else {
this.messageBox.setAttribute('text', '');
}
</method>
<method name="reset">
loginName.setAttribute('text', '');
password.setAttribute('text', '');
</method>
<method name="validate" args="conn">
var login = this.searchSubnodes("name", "loginName").text;
var password = this.searchSubnodes("name", "password").text;
if (login.length == 0 || password.length == 0) {
conn.showValidatonError(this.i18n.missingData);
return false;
} else {
return true;
}
</method>
<switch>
<when runtime="dhtml">
<view x="6" resource="http:../resources/ShowFlash.jpg" onclick="canvas.switchRuntime()"/>
</when>
<otherwise>
<view x="6" resource="http:../resources/ShowDHTML.jpg" onclick="canvas.switchRuntime()"/>
</otherwise>
</switch>
<BorderedBox name="messageBox" x="20" y="70" height="32" width="${parent.width-40}" borderColor="#6eaed8" bgcolor="#c6dff0">
<method name="setText" args="t">
this.textField.setAttribute('text', t);
</method>
<text name="textField" align="center" fgcolor="#2c4c62" fontsize="14" datapath="i18nDS:/app/login/loginMessage/text()"/>
</BorderedBox>
<text x="20" y="117" fontsize="14" datapath="i18nDS:/app/login/user/text()"/>
<edittext name="loginName" x="110" y="115" width="200" fontsize="14" height="30" doesenter="true" maxlength="8">laszlo
<method name="doEnterDown">
if (parent.commit.enabled) {
parent.commit.onclick.sendEvent();
}
</method>
</edittext>
<text x="20" y="155" fontsize="14" datapath="i18nDS:/app/login/password/text()"/>
<edittext name="password" x="110" y="158" width="200" fontsize="14" height="30" password="true" doesenter="true" maxlength="10">openlaszlo
<method name="doEnterDown">
if (parent.commit.enabled) {
parent.commit.onclick.sendEvent();
}
</method>
</edittext>
<button name="commit" x="110" y="200" fontsize="14" onclick="classroot.loginConn.callService()" datapath="i18nDS:/app/login/loginButton/text()"/>
<view x="20" y="${parent.height-this.height-20}" resource="../resources/LZProject.jpg"/>
<view x="${classroot.width-this.width-20}" y="25">
<simplelayout axis="x" spacing="15"/>
<I18NFlag imageUrl="resources/flags/us.jpg" language="en"/>
<I18NFlag imageUrl="resources/flags/de.jpg" language="de"/>
<I18NFlag imageUrl="resources/flags/ko.jpg" language="ko"/>
</view>
</class>
</library>