[RFE] Output CSS classes for custom types

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

[RFE] Output CSS classes for custom types

jpereza
Hello!

I used to have some CSS styles attached to 'type-classes' (eg. "xforms-type-integer") in order to put a different style to controls depending of their types:

For example, align an input bound to an integer node:
.xforms-input input[type="text"].xforms-type-integer { text-align: right; }

But now I have to change all binding definitions to use a custom type for integer types, so I'm going to lost that CSS classes and I will not be able to put a different style to that controls.

So, it would be great if Orbeon output CSS classes for custom types, like this example:


XForms:
<xforms:model>
  ...
  <xforms:bind nodeset="a" <b>type="my:MyNumber" />
  ...
  <xs:schema targetNamespace="http://localhost/my" xmlns:my="http://localhost/my">
    ...
  </xs:schema>
</xforms:model>


XHTML Output:
...
<‍span id="a" class="xforms-control xforms-input xforms-type-custom-MyNumber">
  <‍label class="xforms-label" for="a$xforms-input-1">A value: <‍/label>
  <‍input id="a$xforms-input-1" type="text" name="a$xforms-input-1" value="20" class="xforms-input-input xforms-type-custom-MyNumber">
<‍/span>
...



I hope you understand what I meant to say :)

jpereza
Reply | Threaded
Open this post in threaded view
|

Re: [RFE] Output CSS classes for custom types

Alessandro  Vernet
Administrator
Yes, this makes sense. I added an RFE for this, but, unless sponsored,
we can't guarantee this will be done anytime soon:

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

Alex

On Fri, Mar 12, 2010 at 4:26 AM, jpereza <[hidden email]> wrote:

>
> Hello!
>
> I used to have some CSS styles attached to 'type-classes' (eg.
> "xforms-type-integer") in order to put a different style to controls
> depending of their types:
>
> For example, align an input bound to an integer node:
> .xforms-input input[type="text"].xforms-type-integer { text-align: right; }
>
> But now I have to change all binding definitions to use a custom type for
> integer types, so I'm going to lost that CSS classes and I will not be able
> to put a different style to that controls.
>
> So, it would be great if Orbeon output CSS classes for custom types, like
> this example:
>
>
> XForms:
> <xforms:model>
>  ...
>  <xforms:bind nodeset="a" type="my:MyNumber" />
>  ...
>  <xs:schema targetNamespace="http://localhost/my"
> xmlns:my="http://localhost/my">
>    ...
>  </xs:schema>
> </xforms:model>
>
>
> XHTML Output:
> ...
> <&zwj;span id="a" class="xforms-control xforms-input
> xforms-type-custom-MyNumber">
>  <&zwj;label class="xforms-label" for="a$xforms-input-1">A value:
> <&zwj;/label>
>  <&zwj;input id="a$xforms-input-1" type="text" name="a$xforms-input-1"
> value="20" class="xforms-input-input xforms-type-custom-MyNumber">
> <&zwj;/span>
> ...
>
>
>
> I hope you understand what I meant to say :)
>
> jpereza
>
> --
> View this message in context: http://n4.nabble.com/RFE-Output-CSS-classes-for-custom-types-tp1590429p1590429.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> 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
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
Orbeon Forms - Web forms, open-source, for the Enterprise -
http://www.orbeon.com/
My Twitter: http://twitter.com/avernet


--
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
OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: [RFE] Output CSS classes for custom types

jpereza
Alessandro Vernet wrote
Yes, this makes sense. I added an RFE for this, but, unless sponsored,
we can't guarantee this will be done anytime soon:

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

Alex
Thanks for your interest, Alex.

I've been looking through the source code, and I think I find a way to implement this functionality.

In the class org.orbeon.oxf.xforms.processor.handlers.XFormsBaseHandler, add this code to the method handleMIPClasses()

159                    // Output type class
160                    final String typeName = singleNodeControl.getBuiltinTypeName();
161                    if (typeName != null) {
162                        // Control is bound to built-in schema type
163                        if (sb.length() > 0)
164                            sb.append(' ');
165
166                        sb.append("xforms-type-");
167                        sb.append(typeName);
168                    }
+                       else {
+                           // Output custom type class
+                           final String customTypeName = singleNodeControl.getTypeLocalName();
+                           if (customType != null) {
+                               // Control is bound to a custom schema type
+                               if (sb.length() > 0)
+                                   sb.append(' ');
+
+                               sb.append("xforms-type-custom-");
+                               sb.append(customTypeName);
+                           }
+                       }
169                }
170            } else if (!handlerContext.isTemplate()) {
171                // Case of a non-concrete control - simply mark the control as disabled
172                if (sb.length() > 0)
173                    sb.append(' ');
174                sb.append("xforms-disabled");
175            }


You also need to implement the method getTypeLocalName() for the class org.orbeon.oxf.xforms.control.XFormsSingleNodeControl, like this:

    /**
     * Convenience method to return the local name of the XML Schema type.
     *
     * @return the local name of the type, or null if not found
     */
    public String getTypeLocalName() {
        final String type = getType();
 
        if (type != null) {
            return type.substring(type.indexOf('}') + 1);
        } else {
            return null;
        }
    }


I hope this suggestions will help this issue going ahead.

Thanks,
jpereza.
Reply | Threaded
Open this post in threaded view
|

Re: Re: [RFE] Output CSS classes for custom types

Erik Bruchez-3
Hi,

Thanks, I put these changes in. I noticed an issue, which is that MSV
doesn't always provide the type name. But if you use xf:bind/@type,
things should work!

-Erik

On Tue, Mar 16, 2010 at 1:40 AM, jpereza <[hidden email]> wrote:

>
>
> Alessandro  Vernet wrote:
>>
>> Yes, this makes sense. I added an RFE for this, but, unless sponsored,
>> we can't guarantee this will be done anytime soon:
>>
>> http://forge.ow2.org/tracker/index.php?func=detail&aid=314832&group_id=168&atid=350207
>>
>> Alex
>>
>
> Thanks for your interest, Alex.
>
> I've been looking through the source code, and I think I find a way to
> implement this functionality.
>
> In the class
> http://github.com/orbeon/orbeon-forms/blob/master/src/java/org/orbeon/oxf/xforms/processor/handlers/XFormsBaseHandler.java#L159
> org.orbeon.oxf.xforms.processor.handlers.XFormsBaseHandler , add this code
> to the method handleMIPClasses()
>
> 159                    // Output type class
> 160                    final String typeName =
> singleNodeControl.getBuiltinTypeName();
> 161                    if (typeName != null) {
> 162                        // Control is bound to built-in schema type
> 163                        if (sb.length() > 0)
> 164                            sb.append(' ');
> 165
> 166                        sb.append("xforms-type-");
> 167                        sb.append(typeName);
> 168                    }
> +                       else {
> +                           // Output custom type class
> +                           final String customTypeName =
> singleNodeControl.getTypeLocalName();
> +                           if (customType != null) {
> +                               // Control is bound to a custom schema type
> +                               if (sb.length() > 0)
> +                                   sb.append(' ');
> +
> +                               sb.append("xforms-type-custom-");
> +                               sb.append(customTypeName);
> +                           }
> +                       }
> 169                }
> 170            } else if (!handlerContext.isTemplate()) {
> 171                // Case of a non-concrete control - simply mark the
> control as disabled
> 172                if (sb.length() > 0)
> 173                    sb.append(' ');
> 174                sb.append("xforms-disabled");
> 175            }
>
>
> You also need to implement the method getTypeLocalName() for the class
> http://github.com/orbeon/orbeon-forms/blob/master/src/java/org/orbeon/oxf/xforms/control/XFormsSingleNodeControl.java
> org.orbeon.oxf.xforms.control.XFormsSingleNodeControl , like this:
>
>    /**
>     * Convenience method to return the local name of the XML Schema type.
>     *
>     * @return the local name of the type, or null if not found
>     */
>    public String getTypeLocalName() {
>        final String type = getType();
>
>        if (type != null) {
>            return type.substring(type.indexOf('}') + 1);
>        } else {
>            return null;
>        }
>    }
>
>
> I hope this suggestions will help this issue going ahead.
>
> Thanks,
> jpereza.
>
> --
> View this message in context: http://n4.nabble.com/RFE-Output-CSS-classes-for-custom-types-tp1590429p1594568.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> 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
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
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
OW2 mailing lists service home page: http://www.ow2.org/wws