cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Ochs <dan.o...@gmail.com>
Subject Re: [CFORM] How can I remove a previous validation error from a widget?
Date Thu, 04 Aug 2005 13:50:59 GMT
Here is the actual form definition where hte validation is defined and
the flowscript for this form.

Thanks!
dan

form definition:
<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
<fd:validation>
				<fd:javascript>
					var form = widget.getForm();
					
			// This checks if there is at least one of database, table, or
column name are selected.
			  var success = false;
			  if (form.lookupWidget("databaseName").value != null ||
form.lookupWidget("tableName").value != null ||
form.lookupWidget("columnName").value != null){
				  success = true;
			  }
			  
			  
			  // Output error message if validation fails
			  if (success == false){
				form.lookupWidget("test1").setValidationError(new
Packages.org.apache.cocoon.forms.validation.ValidationError("select_one_database_name",
true));
			  }else{
				  form.lookupWidget("test1").setValidationError(null);
			  }
			  
			  // Must return true/false
			  return success;
			</fd:javascript>
</fd:validation>
	<fd:widgets>
...





Here is the flowscript that is being used:

// prompt for database, table, column
// each should have match type enum (exact, starts-with, contains
// in location, type and modification filters
function do_databaseAnalysis(form) {

    debugLog("do_databaseAnalysis") ;

    // Initialize the model with current set of values available.
Factory method requires access to the
    // UserSession to make calls to CRN and produce the beans for
binding to the Form's Model
    var userSession = outerSession.getAttribute(userSessionKey) ;
    var bean = Packages.com.company.product.form.BeanFactory.getDatabaseAnalysisForm();

    form.load(bean);

    if (debugging) {
        debugLog("Performed form.load(bean); dispatching to
form/display-databaseAnalysis");
    }

    // Display the form with the targets produced dynamically by the
factory. It should not allow the form
    // to process until the user has selected at least one target
    form.showForm("form/display-databaseAnalysis") ;

    form.save(bean) ;

    if (debugging) debugLog("form shown and bean saved, now containing
" + bean.dump());

    var model = form.getModel();
    var databaseAnalysis = new
Packages.com.company.product.tools.DatabaseAnalysis(bean);
	var filterExpression = databaseAnalysis.filterExpression;
	var xQuery = "declare default element namespace
'http://developer.company.com/xmlns/envisn/netvisn/'; " +
"<analysisResults
xmlns='http://developer.company.com/xmlns/company/product/'> " +
"{let $allInfo :=
collection('db/product/content')/content/lineage/dbRef/DbRefImpl[" +
filterExpression + "]/../../../lookupInfo " +
"return if (count($allInfo) eq 0) then " + 
" <noResultsFound/> " + 
"else <packages>{ " + 
"for $packageSearchPath in distinct-values($allInfo/packageSearchPath) " +
"order by $packageSearchPath " +
"return <package> " +
"<packageSearchPath>{$packageSearchPath}</packageSearchPath> " +
"<packageSearchPathEnc>{distinct-values($allInfo[packageSearchPath=$packageSearchPath]/packageSearchPathEnc)}</packageSearchPathEnc>{
" +
    "for $objectClass in
distinct-values($allInfo[packageSearchPath=$packageSearchPath]/objectClass)
" +
      "order by $objectClass " +
      "return <objectClass> " +
        "<objectClassValue>{$objectClass}</objectClassValue> {" +
        "for $filteredResults in $allInfo[objectClass=$objectClass and
packageSearchPath=$packageSearchPath] " +
          "order by $filteredResults/searchPath " +
          "return $filteredResults } " +
      "</objectClass>} " +
  "</package>} " +
"</packages>} " + 
"</analysisResults>";

    // Invoke the pipeline with the filter expression from the
databaseAnalysis. This results in a new display,
    // and we don't wait.
    cocoon.sendPage("databaseAnalysis/", {"xqueryStr": xQuery});
}









On 8/4/05, Mark Lundquist <ml@wrinkledog.com> wrote:
> Hi Dan,
> 
> Would you mind posting your whole flowscript method for this form?
> Before you showed a little 'if...else' statement containing the
> setValidationError() call, but it might help to be able to see that in
> context...
> 
> cheers,
> —ml—
> 
> On Aug 4, 2005, at 6:32 AM, Dan Ochs wrote:
> 
> > This this seems to have the same effect as setting the validation
> > error to null.  The error is cleared in the form, but the form returns
> > back to me with no errors, when it should post and give me back my
> > results.  So it looks like my issues has become, how can I tell the
> > form to try to submit after I clear an error by setting it to null?
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
>
Mime
View raw message