ivelin 02/05/06 19:11:56 Modified: src/scratchpad/webapp/mount/xmlform README.txt Log: added Daniel's summary Revision Changes Path 1.3 +41 -205 xml-cocoon2/src/scratchpad/webapp/mount/xmlform/README.txt Index: README.txt =================================================================== RCS file: /home/cvs/xml-cocoon2/src/scratchpad/webapp/mount/xmlform/README.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- README.txt 17 Apr 2002 17:59:15 -0000 1.2 +++ README.txt 7 May 2002 02:11:56 -0000 1.3 @@ -1,13 +1,16 @@ -The cocoon-form extension mechanism is inspired by Struts and XForms and is intended to: +The XMLForm framework is inspired by Struts and XForms. +It aims to: -* Ease the development of sophisticated web applications utilizing with complex data types and multi-page transactions +* Ease the development of sophisticated web applications utilizing complex data types and multi-page transactions * Provide an automated 2 way mapping between HTML Forms <-> XML <-> JavaBeans -* Use the standardized and powerful XML Schema language for data validation -* Promote natural reuse of validation, binding and business logic between cocoon actions (which are best utilized -for interactive clients driven web applications ) and web services (which are in turn becoming the standard machine-to-machine web technology) -* In doing so, utilize as much as possible of the existing cocoon 2 technology. More specifically: actions, action sets, cocoon-form format. +* Use standard XML validation languages like XML Schema, Relax-NG, Schematron for data validation +* Promote natural reuse of validation, binding and business logic between cocoon actions (which are best utilized for interactive clients driven web applications ) and web services (which are in turn becoming the standard machine-to-machine web technology) +* In doing so, utilize as much as possible of the existing cocoon 2 technology. More specifically: actions, action sets, cocoon-action parameters and transformers. +* Utilize existing XPath tools like JXPath for read/write access to JavaBeans, DOM nodes and mixed +objects. + -------------------------------------------------------------------------------------------- @@ -29,6 +32,37 @@ Ivelin Ivanov, [EMAIL PROTECTED] + +-------------------------------------------------------------------------------------------- + +Following is a summary provided by Daniel Fagerstrom <[EMAIL PROTECTED]> + + +Background +---------- + +The aim of XMLForm, is to build and edit an xml document (called the +instance), subject to constraints from some schema (XMLSchema, Schematron, +...), through a sequence of form pages. The instance is either a +dom-document or a Java bean-structure or a mix. XMLForm consist, of +three main components: + +* Form - is responsible for the instance and validation of it. Form objects +are stored in request attributes for one page forms and session attributes +for wizards (multi page forms). A Form can be populated from the request +parameters. This is the "model in MVC terms. + +* XMLFormTransformer - takes a form descriptor, (similar to XForms) as input +and fill it with data and error messages from a Form object that is +referred in an attribute. This is the "view" in MVC terms. + +* AbstractXMLFormAction, (WizardAction) - creates the Form object if +necessary and populates it with data based on the request parameters. It can +also take care of flow handling and checkbox state. This is the "controller" in MVC terms. + + + + -------------------------------------------------------------------------------------------- Following are copies of the announcement emails send to the Cocoon development mailing list. @@ -112,86 +146,8 @@ code (~5 lines) and Sophisticated form validation with 0! lines of Java code. -Let me walk you quickly through the sitemap of the example provided in the -distribution: - -######### -#sitemap:# -######## ... - <map:pipelines> - <map:pipeline> - <map:match pattern="*"> -1. <map:act type="FormBinderAction"/> <!-- ### Uses The -FormBeanBinder tool to bind the html form elements to an underlying JavaBean -model through XPath based form element names --> -2. <map:generate src="insertFormBean.xml"/> <!-- ### This is a very -short -files simply inserting the form bean --> -3. <map:transform type="castor"/> <!-- ### -CastorTransformer converts the bean into an XML stream --> -4. <map:transform src="schematron/xmlform-sch-report.xsl"/> <!-- ### A -Schematron schema validates the form and adds the validation results in the -stream, while preserving the original form stream --> -5. <map:transform src="formbean2html.xsl"/> <!-- ### Renders the HTML -file -using the XML form and the validation errors from the input document --> - <map:serialize type="html"/> - </map:match> - </map:pipeline> - </map:pipelines> -... - -###################### -#xmlform-sch-report.xml: # -###################### - -The validation schema is really simple and intuitive. The one in the example -is over simplified. -Schematron however supports i18n and validation in phases (useful for -wizards). - -... -<schema ns="http://xml.apache.cocoon/xmlform" -xmlns="http://www.ascc.net/xml/schematron"> - <title>Schema for the XML Form example</title> - <pattern name="A Simple Form Validation Pattern"> - <rule context="name"> - <assert test="string-length(.) > 3">Animal name should be at least 4 -characters.</assert> - <assert test="string-length(.) < 10">Animal name should be less than -10 characters.</assert> - </rule> - <rule context="scope"> - <assert test="normalize-space(.) = 'session' or normalize-space(.) = -'request'">Scope should be request or session.</assert> - </rule> - </pattern> -</schema> - -===================================== - -That's all folks ! - -All sources and xml documents are provided in the example. - -I will be working with Torsten on a more sophisticated wizard example -and a best practices document. - -Cocoon is really close to becoming a full-blown web-app server, -which enforces a pure separation in BOTH directions ! - -I know everyone on this team is extremely busy, but even one line feedback -is of great help for me, so - -Feedback please ! - -Cheers, - -Ivelin - - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -250,128 +206,8 @@ - Very, very simple to learn if one knows XPath. (I just can stop repeating that.) - -Please play with the new demo and send me your feedback. -I've tried to add more JavaDoc since last time. -Note that since there are 2 demos now, the URLs are different: -xmlform/demo1 for the original demo and -xmlform/demo2 for the new demo -The new demo extends the first one with an additional page which is shown on -successful submit. -This shows a possible sitemap control logic based on validation results. - -Having in addition the efficient HTML Form -> JavaBean binding, I'm -convinced we're not too far from making Cocoon a prime time app server. - -The only area which is not completely fleshed out yet is rendering the HTML -Forms. -The currently proposed simplistic solution apparently works for many people, -but there are still strong opinons for a -XForms style model. I would need more specific suggestions on the latter, so -that we can have a good understanding -and eventually vote on one or the other. - -Download from: -http://prdownloads.sourceforge.net/freebuilder/CocoonForm_0-7.zip - - -======================== -P.S.: For those who are too busy to install the demo, but would like to -participate in the discussion, I attach key snippets of code below: -======================== - ----------------------------------------------------------------- -sitemap.xmap: - -... - <!-- - Demo2: - 1) The Action binds the HTML form to a JavaBean -and inserts it in the session - 2) The Action uses the Java Schematron Validator -to perform fast validation - 3) The Action inserts into request the validation -result (if negative) - 4) Selector branches control depending on the -outcome of 3) - 5) If 3) produced validation errors, then the path -is similar to Demo1 - 6) If 3) did not produce validation errors, then -Success page is displayed - --> - <map:match pattern="demo2"> - <map:act type="ValidationFormAction"/> - <map:select type="request-attribute"> - <map:parameter name="attribute-name" -value="validationPassed"/> - <!-- validation passed, go to next page --> - <map:when test="true"> - <map:call resource="display-success"/> - </map:when> - <!-- validation failed, go to the same -page --> - <map:otherwise> - <map:generate -src="insertFormBean-Demo2.xml"/> - <map:transform type="castor"/> - <map:transform -src="formbean2html-Demo2.xsl"/> - <map:serialize type="html"/> - </map:otherwise> - </map:select> - </map:match> - </map:pipeline> ... ----------------------------------------------------------------- - -class ValidatingFormAction - -... - public Map act(...) - { - ... - String formName = "xmlForm"; - TestBean jBean = (TestBean) session.getAttribute( formName ); - if (jBean == null) - { - // first time here, populate the bean with initial values - jBean = new TestBean(); - session.setAttribute( formName, jBean); - } - else - { - // been here before, update the bean with client's values - FormBeanBinder.bind(request, jBean); - } - // validate state of the bean against a Schematron schema. - // Schema Phase is "Full" - Properties props = new Properties(); - props.put("phase", "Full"); - ValidationResult vres = validator_.validate(jBean, props); - // if the validation result is not empty, then - // make the validation result available to the pipeline - // it can be later checked by a <map:selector/> - // or inserted in the SAX stream by a CastorTransformer - // or maybe even both - if (!vres.isEmpty()) - { - request.setAttribute ( formName + "ValidationResult", vres ); - } - request.setAttribute ( "validationPassed", new Boolean( -vres.isEmpty() ) ); - // apply additional buziness logic to the bean - jBean.incrementCount(); - - return objectModel; - } - -... -} - - -Ivelin - ~~~~~~~~~~~~~~~~~~~~~ - +<end-of-file/>
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]