You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Antonio Gallardo <ag...@agssa.net> on 2005/06/02 20:14:28 UTC
Re: CFORMS validation unexplained behavior
Hi:
print() is not part of the flow API. Use:
cocoon.log.debug("My comment");
Best Regards,
Antonio Gallardo
On Jue, 2 de Junio de 2005, 10:54, Messing, Elad dijo:
> Hello again !
> I have posted this text 24 hours ago, but it seems like it was
> too related to its previous thread, so I decided to repost it as a new
> thread with a new title. Forgive me if you consider this as spam.
>
>
> With the help of Sylvain and Thorsten I have managed to come up
> with a form.
> Now - when all data is valid, all works fine.
> The problem starts when the data is not valid.
>
> I have 3 widgets in my form - text field and a select list. (See
> definition below)
> On the text field there is a validation of length, and on the
> select list there is no validation, but the first "item" of it is a null
> record - to show an empty slot.
> On the "form" there is a validation so that either of the 2
> fields must contain value. (See definition below)
>
> When I first show the form all is fine.
>
> When I enter a too-short string in the text field, I get a
> strange behavior: I can see the error message stating it is too short,
> but I can also see the error message stating that either of the fields
> should be entered (coming from the "form level" validation function) -
> like nothing was entered in the text field. I added a "print" line into
> the form validation, to see that even though I have entered a value in
> the text field (it was too short - but it was there) the widget value is
> actually null. (see the "print" in the flow below).
>
> Also - I would expect the validation to stop after it was
> failing on the "too-short" text field widget validation. Why has it
> continued to the "Form level" validation at all ?
>
> Another strange behavior was, that after I submitted the form
> with valid data, I could see the results. When I pressed "Back" button
> of the browser - I got back to the form page, with all the error
> messages still showing. The fields are showing the valid data which I
> put in, but the errors from the first trail are still there. Why is that
> ?
>
> And the third issue - When I am not using the "Back" button, but
> instead using the original "link" to the form page, I get other results
> - I can see the form in the state it was after I entered a "too-short"
> string in the text field !! This is after I have already changed the
> data to valid, submitted, got my results, and return to the form page
> using its link 1 minute after.. I even get the results opening a new
> browser window, in a different process. Only "restart" to the web server
> removes it.
> Is this the normal behavior ? Should I reset the form in some
> manner ?
>
> I am attaching down the needed text from the flow and form
> description - maybe it can help you understand my problems.
>
> Thank you very much for reading my long post :)
>
> Elad
>
> **************
> <fd:form
> xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
>
> <fd:validation>
> <fd:javascript>
> validateRestaurantForm(widget);
> </fd:javascript>
> </fd:validation>
>
> <fd:widgets>
> <fd:messages id="errors">
> <fd:datatype base="string"/>
> </fd:messages>
> <fd:field id="name">
> <fd:label>Name</fd:label>
> <fd:hint>Hint Hint</fd:hint>
> <fd:datatype base="string"/>
> <fd:validation>
> <fd:length min="2">
> <fd:failmessage>You should add name</fd:failmessage>
> </fd:length>
> </fd:validation>
> </fd:field>
>
> <fd:field id="type">
> <fd:label>Type</fd:label>
> <fd:datatype base="integer"/>
> <fd:selection-list type="flow-jxpath" list-path="restTypeList"
> value-path="id" label-path="name"/>
> </fd:field>
> </fd:widgets>
>
> </fd:form>
> **************
>
> function validateRestaurantForm (form){
> print ("Start validateRestaurantForm");
> var success = true;
> var nameWidget = form.lookupWidget("name");
> var typeWidget = form.lookupWidget("type");
> var errorsWidget = form.lookupWidget("errors");
>
> print ("Name: " + nameWidget.value + " Type: " +
> typeWidget.value);
> if (typeWidget.value == null && nameWidget.value == null ) {
> errorsWidget.addMessage("You must either select a name
> or type");
> print ("set the errors and return false");
> success = false;
> }
> return success;
> }
>
> **************
>
> Elad Messing
> Software Developer
> European Media Laboratory GmbH
> Schloss-Wolfsbrunnenweg 33
> D-69118 Heidelberg
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org