You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Jesse Kuhnert (JIRA)" <ta...@jakarta.apache.org> on 2006/07/23 17:14:15 UTC

[jira] Assigned: (TAPESTRY-772) Valiadator needs to support "depend on" like Struts (i.e. field D is mandaatory ONLY depending on the setting of field B)

     [ http://issues.apache.org/jira/browse/TAPESTRY-772?page=all ]

Jesse Kuhnert reassigned TAPESTRY-772:
--------------------------------------

    Assignee: Jesse Kuhnert

> Valiadator needs to support "depend on" like Struts (i.e. field D is mandaatory ONLY depending on the setting of field B)
> -------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-772
>                 URL: http://issues.apache.org/jira/browse/TAPESTRY-772
>             Project: Tapestry
>          Issue Type: Wish
>          Components: Framework
>    Affects Versions: 3.0.3
>         Environment: Any
>            Reporter: Tony Herstell
>         Assigned To: Jesse Kuhnert
>
> The Validation Framework lets you set a field as Mandatory.
> Setting clientScriptEnabled to true in the .page turns on javascript support.
> Both GREAT features.
> I wish to have the ability, before Tapestry 4 is released to have this field be mandatory, but ONLY when another field is selected. (The Struts Validator plugin is a good example of this and uses a "valid-when" property - refer to Struts Validator (not actually part of Struts however) documentation for a complete overview and some useful "design" concepts you could leverage).
> Worked Explanation:
> ================
> I have a form, that has a check box.
> I have fields on the form that are hidden (or disabled!) depending on this check box. I use Javascript to manipulate the DOM to hide these fields
>       document.getElementById("SomeIDIHaveToManauallyAddToTheHTMLElement").style['display']="none")
> Since the fields are declared mandatory in the .page, then when the user presses "Submit" on the form the current implementation of the javascript notices that the mandatory field is not empty and attempts to move the cursor to it... this fails as the field is either hidden or disabled, and the form gets submitted anyhow (a useful side effect - turn on javascript errors to see it happen)!!!
> At Server side, the validation is checked again and the field is again found to be in error so you have to catch the errors and ignore them:
>    if (delegate.getHasErrors()) {
>       // return;   <------- Ignore them!!! or catch the ones you want
>    }
> Soultion
> =======
> The javascript (and back end validation) should check the pre-conditions (i.e. ValidWhen Rules), set up in the component declaration in the .page before treating it as mandatory!!!
> Poor Workaround
> ===============
> 1. This allows you to get round the problem, but you must have the hidden field at the end of the form as it "auto-submits" the form when the javascript encounters the first field it cannot write to... (Well on IE anyhow).
> 2. Dont hide/disable any mandatory fields in a Form using tapestry... (makes the screens full of fields that the user should not see let alone be able to type into).

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org