Re: switch and validation

Mark Birbeck wrote:
> Joern,
> 
> 
>>the problem:
>>
>>if i have a switch statement with several cases and each case 
>>itself constituted a view/page for the user (meaning the 
>>content of a case uses the whole viewport of the client) 
>>there might occur a validation problem or more precisely a 
>>problem with signaling validation errors through alerts.
>>
>>e.g. the user fills out 'page 1' and moves on to another 
>>case. Fills out other data which by some calculation or 
>>action lead to validation failures on 'page 1'. - The user 
>>won't receive any alert messages and will be left without a 
>>clue what may have gone wrong.
>>
>>Is there a solution which i oversee?
> 
> 
> There is no general solution. The obvious one is to reposition all alerts,
> but the probably wouldn't show when on controls that are in hidden cases.
First of all, thanks for the answer.

> 
> But a technique we began to use recently is to use groups that are bound to
> the node you are interested in, but place them in a completely different
> part of the form:
> 
>   <xf:switch>
>     <xf:case id="page1">
>       <xf:input ref="age">
>         ...
>       </xf:input>
>     </xf:case>
>     <xf:case id="page2">
>       <xf:group ref="age" class="error-message">
>         Age has been entered wrongly. Click here to go edit it...
>       </xf:group>
>       .
>       .
>       .
>     </xf:case>
>   </xf:case>
> 
> All you need to do for this to work is use CSS to *hide* valid xf:groups
> with a class of "error-message". The nice thing about this technique is that
> the contents of the group can be anything, so you can put in other controls
> that might help the user, or perhaps a trigger that toggles the sub-form in
> question.
This is really a creative solution and i agree that it may even have 
advantages in some situations.

Though, i must confess i do not fully understand it: ok, the group is 
switched invisible/visible with the help of some additional CSS style.

But how can i form such a style rule? The group containing the 
errormessage will get a XForms pseudo style of 'invalid' or 'valid' and 
at the same time will still have 'error-message' as class. So these 
attributes will exist on the same element. Is it possible to write an 
CSS rule that tests two conditions on one element and is understood by 
current browsers? Sorry, if i oversee something obvious here.

And furthermore i think there maybe should be a more obvious solution 
for this problem in XForms one day. Two options quickly pop up when 
thinking about this:
1. why not consider allowing alerts to occur in arbitary locations of a 
form (even multiple times) and associating them with an 'for' Attribute 
as in HTML <label for="id"/>

2. alternatively allow an 'alertfor' Attribute on 'group' Elements which 
would capture the advantages you mentioned for handling more complex 
error situations and one likes to guard the user out of the mess. Sure, 
here a group wearing the attribute shouldn't be shown in case the linked 
Node is valid.


Joern
> 
> Another version of this technique is to group all of your error messages
> into a scrollable footer so that they are always 'visible' wherever you are
> in the form.
> 
> Regards,
> 
> Mark
> 
> 
> Mark Birbeck
> CEO
> x-port.net Ltd.
> 
> e: Mark.Birbeck@x-port.net
> t: +44 (0) 20 7689 9232
> w: http://www.formsPlayer.com/
> b: http://internet-apps.blogspot.com/
> 
> Download our XForms processor from
> http://www.formsPlayer.com/
> 
> 
> 

Received on Tuesday, 13 September 2005 23:12:03 UTC