cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leszek Gawron" <lgaw...@mobilebox.pl>
Subject Deprecating FormValidatorAction
Date Mon, 08 Mar 2004 12:42:39 GMT
As the FormValidatorAction is not cool fancy and new it still intruduces some
interesting functionality that does not exist in flow. Suppose you do not use
CForms in all your application views. So you have plain html with links that
will trigger some flow function:

http://www.myhost.com/myapp/document/edit.do?documentId=123&storeName=first

Although all cocoon examples silently omit the request parameter validation it
is needed here (as in all places that we use request parameters). So instead
of validating the request parameters manually in flow (which makes the code
look really ugly) we could use the existing functionality of
FormValidatorAction. The only thing that should be done is to convert it to
cocoon component so it could be easily obtained from flow and rename it to
something like RequestParameterValidator.

This way you could still use the format of validator descriptors and use flow
this way: 

function edit() {
	var validator = cocoon.getComponent(
"o.a.c.RequestParameterValidator");
	if ( validator.validateRequestParams(
"descriptors/edit-document-descriptor.xml" ) {
		// validate params vs. database and proceed to some view

	} else { 
		// extract errors from validator (as in xsp-formval) and 
		// show some view with error message that the reuqest was 
		// malformed
	}
}

AbstractValidatorAction implements a lot of validating condition types along
with constraint-sets which is maybe not so useful now for forms (as CForms is
much more powerful) but very useful just to validate request parameters.

My regards
	LG



Mime
View raw message