» JeaseCMS » Блог » Как создать форму контактов?

Java with Ease


Java is a very productive development environment if you choose and combine the right tools and patterns.

Jease is the result of my personal quest bringing tools and patterns together which make the life of a web-developer as simple as it can be.

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%"> 
  <textbox id="name" hflex="1" constraint="no empty"/> 
  <textbox id="email" hflex="1" constraint="/.+@.+\.[a-z]+/: No valid address" />
  <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()) { 
          "Message from " + name.value + " <" + email.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);

Please feel free to try out the form...

Last modified on 2011-02-14 by Maik Jablonski