Amazon deals

Saturday, September 27, 2008

Writing your First Xform

Xforms isn't as complicated as people claim it to be. It is a simple, and with tons of benefits than traditional forms. Here's a step by step procedure involved inwriting an Xform that takes a persons name as an input and sends it to an jsp page process.jsp for processing.

1)

Open notepad and put in the following xhtml header

<html
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


this header tell the browser the type of XHTML page and the different standards used as per W3C. the first line is the xforms standards, the second of schema for display and the third for the instance model. Without these your browser will not be able to intepret the page properly.

2)

Write the head section as you do in HTML, i'll elaborate the otter fields in comments delimited by //

<head>
<title>Xforms Example</title>


//The model specifies the Xforms data model. Instance contains all the fields you'll have in the model. Here we have only one field in the instance namely name.

<xf:model>
<xf:instance>
<name/>
</xf:instance>

//in submission action link to your serverside code
<xf:submission action="process.jsp"
method="get" id="sub"/>
</xf:model>
</head>


3) Now to the body part of the page.

<body>
<xf:input ref="name">


// the ref field is used to referance particular elements from the instance model. The label is what the label you want to show on the page

<xf:label>Name:</xf:label>
</xf:input>
<br />


//br is normal HTML break. The submission="sub" specifies the id as given in the instance model in head.

<xf:submit submission="sub"><xf:label>Submit</xf:label></xf:submit>
</body>
</html>


4) There you have your first Xforms ready. Save the file with a .xhtml extension and view in any Xforms compitable browser(click here to know more about xforms viewers) and there you go.

4 comments:

  1. Thank you, this is a great help!

    ReplyDelete
  2. Hello webmaster
    I would like to share with you a link to your site
    write me here preonrelt@mail.ru

    ReplyDelete
  3. do netbeans have a module plugin for xforms?

    ReplyDelete
  4. This is really attention-grabbing, You're a very skilled blogger. I have joined your feed and look forward to in search of extra of your magnificent post. Also, I've shared your website in my social networks

    ReplyDelete