In our forms we indicate required
fields with a red asterisk to the right of the fields. Rather than
trying to achieve this with CSS, we use a <xforms:group> bound to
the same node as the control:
<xforms:input ref="some/field"> <xforms:label>Some field</xforms:label> </xforms:input> <xforms:group ref="some/field"> <xhtml:span class="required-symbol">*</xhtml:span> </xforms:group> Then we hide the required symbol unless the field is required: .required-symbol { display:none; } .xforms-required .required-symbol { display:inline; } This has worked nicely for us, because the required symbol will then also show/hide together with the input. Unfortunately in the latest OPS milestone, the xforms-required class is no longer output for <xforms:group>, but only 'valued' controls: if (xformsControl != null && xformsControl instanceof XFormsValueControl && xformsControl.isRequired()) { if (sb.length() > 0) sb.append(' '); sb.append("xforms-required"); if ("".equals(((XFormsValueControl) xformsControl).getValue())) sb.append(" xforms-required-empty"); else sb.append(" xforms-required-filled"); } I can see the rationale for the change (what does a required group mean?), but it's a pity because it means tricks like our use of a group to display a required symbol are no longer possible. How about still outputting xforms-required for all controls, and then only outputting xforms-required-empty/filled for 'valued' controls? eg if (xformsControl != null && xformsControl.isRequired()) { if (sb.length() > 0) sb.append(' '); sb.append("xforms-required"); if( xformsControl instanceof XFormsValueControl ) { if ("".equals(((XFormsValueControl) xformsControl).getValue())) sb.append(" xforms-required-empty"); else sb.append(" xforms-required-filled"); } } Since the information is readily available on the model, it seems a pity not to express it in the view and offer more flexibility for form authors. In addition, the xforms-required class is only omitted in the intial XHTML document generated by the Java code - if the group's required-ness changes while the form is used, the xforms-required class is happily added/removed from the group span by the OPS's javascript, which is a little inconsistent. Once you can programmatically access MIPs via xpath there'll be a nice alternative to this approach anyway. 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 |
Administrator
|
Adrian,
> I can see the rationale for the change (what does a required group > mean?), but it's a pity because it means tricks like our use of a group > to display a required symbol are no longer possible. How about still > outputting xforms-required for all controls, and then only outputting > xforms-required-empty/filled for 'valued' controls? eg > > if (xformsControl != null && xformsControl.isRequired()) { > if (sb.length() > 0) > sb.append(' '); > sb.append("xforms-required"); > if( xformsControl instanceof XFormsValueControl ) { > if ("".equals(((XFormsValueControl) xformsControl).getValue())) > sb.append(" xforms-required-empty"); > else > sb.append(" xforms-required-filled"); > } > } > Since the information is readily available on the model, it seems a pity > not to express it in the view and offer more flexibility for form > authors. In addition, the xforms-required class is only omitted in the > intial XHTML document generated by the Java code - if the group's > required-ness changes while the form is used, the xforms-required class > is happily added/removed from the group span by the OPS's javascript, > which is a little inconsistent. > > Once you can programmatically access MIPs via xpath there'll be a nice > alternative to this approach anyway. -Erik -- Orbeon - XForms Everywhere: 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 |
Free forum by Nabble | Edit this page |