spans in generated html

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

spans in generated html

Adrian Baker-2
For an xforms:input, OPS generates HTML like

<label class="label xforms-label" for="input-N1009E1611">Diagnosis</label>
<span id="input-N1009E1611" class="xforms-control xforms-input xforms-required xforms-required-empty xforms-invalid">
    <span class="xforms-date-display"></span>
    <input type="text" name="input-N1009E1611" value="" class="xforms-input-input xforms-type-string">
    <span class="xforms-showcalendar xforms-type-string"></span>
</span>
<label class="xforms-alert xforms-alert-active" for="input-N1009E1611">Please enter a primary diagnosis</label>
<label class="xforms-hint" for="input-N1009E1611">This is a hint for diagnosis</label>

I'm wondering if it might be neater if the three related <label> elements (label, alert, hint) were placed *inside* the span, along with the input etc, eg

<span id="input-N1009E1611" class="xforms-control xforms-input xforms-required xforms-required-empty xforms-invalid">
    <label class="label xforms-label" for="input-N1009E1611">Diagnosis</label>
    <span class="xforms-date-display"></span>
    <input type="text" name="input-N1009E1611" value="" class="xforms-input-input xforms-type-string">
    <span class="xforms-showcalendar xforms-type-string"></span>
    <label class="xforms-alert xforms-alert-active" for="input-N1009E1611">Please enter a primary diagnosis</label>
    <label class="xforms-hint" for="input-N1009E1611">This is a hint for diagnosis</label>
</span>


This would mean you could do away with the .xforms-alert-active class (and related javascript) and just use
.xforms-alert {
    display:none;
}
.xforms-invalid .xforms-alert {
    display:inline;
}

Also, you then don't need to use javascript to hide the other <label> (label, alert, hint) elements when the input control becomes irrelevant, because the .xforms-disabled class on the wrapping span neatly takes care of this. (This also gets rid of the slight inconsistency that (AFAIK) the .xforms-disabled class in CSS is used to hide the control, whereas the javascript command documentElement.xformsMessageLabel.style.display = "none" is used to hide these labels). And arguably this matches the structure of the source <xforms:xxx> element a little better (perhaps).

Another reason I was considering this structure is that it allows me to hide the alert text for xforms-required-empty fields with:
.xforms-required-empty .xforms-alert {
    display:none;
}

Which gets rid of distracting & inappropriate alerts when the user hasn't even yet filled in a value for the field - we already have the .xforms-required-empty class to use to communicate this.

For example, I have a numerical field which is required. When the form loads, currently the user is told two things
- the field is required and not filled in (OPS default style is red background)
- an alert saying "XYZ must be a number"

Obviously the alert is misleading in this case - it should be displayed only when the user has actually entered a non-numerical value. I know that the registration form details another approach for tackling this problem using event listeners and @ui:xx attributes to track what fields have been changed, but frankly it's simply too complex and too much work for what should be default behaviour.

Anyway, perhaps a single wrapping <span> approach was considered and not used for some reason?

Adrian





--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: spans in generated html

Alessandro  Vernet
Administrator
Adrian,

Since we have a <span> that contains all the <xforms:input> elements,
I agree with you, it would make sense to put the <label> for the
XForms label, hint, and help in that same <span>. Now however, if we
do this for the <xforms:input>, we should do it for all the XForms
controls, which would mean adding a <span> around all the controls.

I like the idea, and I am trying to weigh in possible drawbacks of
this approach. Those include possibly breaking existing code in
PresentationServer applications where people make assumptions about
the generated HTML. It would also slightly increase the amount of
generated HTML. Do you see any other drawback?

In the meantime, I have added this suggestion to the tracker:

http://forge.objectweb.org/tracker/index.php?func=detail&aid=304727&group_id=168&atid=350207

Alex

On 2/28/06, Adrian Baker <[hidden email]> wrote:

>  For an xforms:input, OPS generates HTML like
>
>  <label class="label xforms-label"
> for="input-N1009E1611">Diagnosis</label>
>  <span id="input-N1009E1611" class="xforms-control xforms-input
> xforms-required xforms-required-empty xforms-invalid">
>      <span class="xforms-date-display"></span>
>      <input type="text" name="input-N1009E1611" value=""
> class="xforms-input-input xforms-type-string">
>      <span class="xforms-showcalendar xforms-type-string"></span>
>  </span>
>  <label class="xforms-alert xforms-alert-active"
> for="input-N1009E1611">Please enter a primary diagnosis</label>
>  <label class="xforms-hint" for="input-N1009E1611">This is a hint for
> diagnosis</label>
>
>  I'm wondering if it might be neater if the three related <label> elements
> (label, alert, hint) were placed *inside* the span, along with the input
> etc, eg
>
>  <span id="input-N1009E1611" class="xforms-control xforms-input
> xforms-required xforms-required-empty xforms-invalid">
>      <label class="label xforms-label"
> for="input-N1009E1611">Diagnosis</label>
>      <span class="xforms-date-display"></span>
>      <input type="text" name="input-N1009E1611" value=""
> class="xforms-input-input xforms-type-string">
>      <span class="xforms-showcalendar xforms-type-string"></span>
>      <label class="xforms-alert xforms-alert-active"
> for="input-N1009E1611">Please enter a primary diagnosis</label>
>      <label class="xforms-hint" for="input-N1009E1611">This is a hint for
> diagnosis</label>
>  </span>
>
>
>  This would mean you could do away with the .xforms-alert-active class (and
> related javascript) and just use
>  .xforms-alert {
>      display:none;
>  }
>  .xforms-invalid .xforms-alert {
>      display:inline;
>  }
>
>  Also, you then don't need to use javascript to hide the other <label>
> (label, alert, hint) elements when the input control becomes irrelevant,
> because the .xforms-disabled class on the wrapping span neatly takes care of
> this. (This also gets rid of the slight inconsistency that (AFAIK) the
> .xforms-disabled class in CSS is used to hide the control, whereas the
> javascript command
> documentElement.xformsMessageLabel.style.display = "none"
> is used to hide these labels). And arguably this matches the structure of
> the source <xforms:xxx> element a little better (perhaps).
>
>  Another reason I was considering this structure is that it allows me to
> hide the alert text for xforms-required-empty fields with:
>  .xforms-required-empty .xforms-alert {
>      display:none;
>  }
>
>  Which gets rid of distracting & inappropriate alerts when the user hasn't
> even yet filled in a value for the field - we already have the
> .xforms-required-empty class to use to communicate this.
>
>  For example, I have a numerical field which is required. When the form
> loads, currently the user is told two things
>  - the field is required and not filled in (OPS default style is red
> background)
>  - an alert saying "XYZ must be a number"
>
>  Obviously the alert is misleading in this case - it should be displayed
> only when the user has actually entered a non-numerical value. I know that
> the registration form details another approach for tackling this problem
> using event listeners and @ui:xx attributes to track what fields have been
> changed, but frankly it's simply too complex and too much work for what
> should be default behaviour.
>
>  Anyway, perhaps a single wrapping <span> approach was considered and not
> used for some reason?
>
>  Adrian
>
>
>
>
>
> --
> You receive this message as a subscriber of the [hidden email]
> mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>
>

--
Blog (XML, Web apps, Open Source):
http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet