» JeaseCMS » Блог

How to create a contact form with Jease?

Jease allows to include ZUL-Pages directly into your public website. ZUL (or ZUML) is the markup language defined by ZK which allows to build complex forms with a few lines of XML easily. The additional feature to include simple scripting elements directly into a ZUL page lets you build interactive forms based on the rich set of available ZK components to improve your website.

Here's an example how to create a simple contact form which sends out an email to the adress in charge. Just create a Script with extension .zul and you're done.

<vlayout width="100%"> 
  Name:
  <textbox id="name" hflex="1" constraint="no empty"/> 
  Email:
  <textbox id="email" hflex="1" constraint="/.+@.+\.[a-z]+/: No valid address" />
  Message:
  <textbox id="message" hflex="1" rows="10" constraint="no empty" /> 
  <button label="Send Message"> 
    <attribute name="onClick"><![CDATA[ 
      if(name.isValid() && email.isValid() && message.isValid()) { 
        jease.cms.service.Mails.send(
          email.value,
          "[email protected]",
          "Message from " + name.value + " <" + email.value + ">",
          message.value
        );
        name.rawValue = email.rawValue = message.rawValue = null;
        Messagebox.show("We have received your message.", "Thank you!",
                        Messagebox.OK, Messagebox.INFORMATION);
      } else {
        Messagebox.show("All fields are required!", "Error", 
                        Messagebox.OK, Messagebox.ERROR);
      }
    ]]></attribute>
 </button> 
</vlayout>

Please feel free to try out the form...

Processing...

Last modified on 2012-04-23 by Maik Jablonski