Presentation is loading. Please wait.

Presentation is loading. Please wait.

Apache Cocoon Part II 3/6/06 Kevin Davis. Learning Objectives Understand how CForms work Understand how XSPs work Make a basic CForm that can pass information.

Similar presentations


Presentation on theme: "Apache Cocoon Part II 3/6/06 Kevin Davis. Learning Objectives Understand how CForms work Understand how XSPs work Make a basic CForm that can pass information."— Presentation transcript:

1 Apache Cocoon Part II 3/6/06 Kevin Davis

2 Learning Objectives Understand how CForms work Understand how XSPs work Make a basic CForm that can pass information to an XSP

3 Cocoon Forms vs HTML Forms Cocoon forms – use XML to make reusable form objects with easy validation HTML forms – must write all forms individually and use Javascript or other languages for some validation See working samples at http://blaze.terry.uga.edu:8080/cocoon/sa mples/blocks/forms/ http://blaze.terry.uga.edu:8080/cocoon/sa mples/blocks/forms/

4 Widgets XML entities in the definition file that give a form field its name and validation information Email address: Called in the template file along with HTML code for formatting Have built-in responses to validation issues, including help tooltips and redisplaying the form if something wasn’t correct

5 Flow A Javascript file and the sitemap control the order in which pages are called function registration() { var form = new Form("registration_definition.xml"); form.showForm("registration-display-pipeline"); var viewData = { "username" : form.getChild("name").getValue() } cocoon.sendPage("registration-success-pipeline", viewData); }

6 Flow Continued </map:flow>…<map:pipeline> </map:match>… </map:transform> <map:serialize/></map:match>… <map:serialize/></map:match>

7 XSPs Much like servlets, XSPs can request data from a submitted form and insert it into a database, or call and display data from a database XML tags and Java code can be used Connection to a database occurs in one Cocoon configuration file, XSPs just need to call the name of the database

8 XSPs Continued otc INSERT into otc_users (name,email,password,age,spam) values (' esc_name ',' ',' ',' ',' ') … [java code]

9 Exercise Follow the guide located at http://cocoon.apache.org/2.1/userdocs/basics/sa mple.html - create your own template and definition files with at least one unique widget http://cocoon.apache.org/2.1/userdocs/basics/sa mple.html Compare this to the working example located at http://blaze.terry.uga.edu:8080/cocoon/cforms/reg istration http://blaze.terry.uga.edu:8080/cocoon/cforms/reg istration Look at the files sitemap-modified.xmap and test.xsp in the opt/tomcat5/webapps/cocoon/cforms directory to see how a CForm could use an XSP to insert data into a database


Download ppt "Apache Cocoon Part II 3/6/06 Kevin Davis. Learning Objectives Understand how CForms work Understand how XSPs work Make a basic CForm that can pass information."

Similar presentations


Ads by Google