cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Man <Martin....@seznam.cz>
Subject [C2] FormValidator action
Date Thu, 12 Apr 2001 17:35:59 GMT
Hi all,
	This is my first coding contribution into c2, if you find it usefull
pls. include it.
	
	It for now does only check parameter type (string, long, double) and
whether it is null or not, if successfull the act method returns something
that you can explicitely configure via {result}, otherwise it returns null

example sitemap fragment follows
---------------------------------------------------------------------------
<map:match pattern="do-post">
    <map:act type="form validator">
   	<parameter name="descriptor"
   		value="context://descriptors/form-params.xml"/>
   	<parameter name="validate"
   		value="author,email,message"/>
   	<map:act type="add-employee">
   		<parameter name="form-descriptor"
   			value="context://db/guestbook-table-mapping.xml"/>
   		<map:redirect-to uri="view"/>
   	</map:act>
   </map:act>
   <map:redirect-to uri="post"/>
</map:match>

form-params.xml
-----------------------------------------------------------
<form-params>
	<param name="author" type="string" nullable="no"/>
	<param name="email" type="string" nullable="yes"/>
	<param name="message" type="string" nullable="no"/>
	<param name="xml-message" type="string" nullable="no"/>

	<param name="count" type="long" nullable="no"/>
	<param name="sallary" type="double" nullable="no"/>
</form-params>


in this simple guestbook example, when both actions (form validator, and
add-employee - which adds record to the database) are successfull, the
redirect to main 'view' page is sent, otherwise the user is just directed back
to page with form fields to fill, ...

hope you find it usefull... :-))

martin man


P.S. I'm working now the simiar way on SessionValidator and DBAuthenticator
-- 
-------------------------------------------------------------------------------
"Only dead fish swims with a stream"
gpg_key_available: http://globales.cz/~mman/martin.man.gpg
gpg_key_fingerprint: 2CC0 4AF6 92DA 5CBF 5F09  7BCB 6202 7024 6E06 0223

Mime
View raw message