Montag, 23. Januar 2012

webOS: Login dialog with Enyo

The Enyo framework is very modular and thus allows components to be reused very easy. Here we have a simple modal dialog that can be used to let the user enter a login name and a password.

The dialog will look like this:


Just create a file LoginDialog.js and add it to your enyo.depends() call.

enyo.kind({
  kind : "ModalDialog",
  name : "FFComputing.LoginDialog",
  caption : "Login",
  events: {
    onOK: "",
    onCancel: ""
  },
  components : [ {
    kind : "Group",
    name : "LoginCaption",
    caption : "Login",
    components : [ {
      kind : "Input",
      name : "loginInput",
      hint : "Login...",
      autoWordComplete : false,
      spellCheck : false,
      autocorrect : false
    } ]
  }, {
    kind : "Group",
    name : "PasswordCaption",
    caption : "Password",
    components : [ {
      kind : "PasswordInput",
      name : "passwordInput",
      hint : "Password...",
      spellCheck : false,
      autocorrect : false
    } ]
  }, {
    layoutKind : "HFlexLayout",
    components : [ {
      kind : "Button",
      flex : 1,
      caption : "OK",
      onclick : "okClicked",
      className : "enyo-button-blue"
    }, {
      kind : "Button",
      flex : 1,
      caption : "Cancel",
      onclick : "cancelClicked"
    }]
  }, ],
 
  okClicked: function(sender) {
    this.close();
    this.doOK(this.$.loginInput.getValue(), this.$.passwordInput.getValue());
  },
 
  cancelClicked: function(sender) {
    this.close();
    this.doCancel();
  }
});

Kommentare:

  1. Hello,

    Would be kind enough to post webos tutorial - connection to MYSQL database?

    Very much appreciated!

    Liz

    AntwortenLöschen
    Antworten
    1. I doon't know if that is possible. In my option a direct connection would require using a service and node.js to open a raw socket. Then you would have to implement whatever protocol mysql uses to communicate between server and client. That seems like a lot of work to me.

      On the other hand you could use something along the line of this: http://www.webos-internals.org/wiki/Tutorials_webOS_Getting_JSON_From_An_External_MySQL_Database
      But that requires access to a webserver that can connect to the database.

      Löschen
  2. I have an xampp server running which I could use to host my database.
    Thanks for the link!

    Lix

    AntwortenLöschen