Hi list !
I have two small contributions/patches for the cforms, which maybe could
be included in the next release... Sorry for posting this to the dev
list, but I am not sure wether the patches are useful/correct, and
looking at bugzilla I get the feeling that patches are rather not
integrated without some attention from the dev list :-)
a) Two issues regarding FormInstance.java (diff follows below) (I use
javaflow with cforms)
a1) additional constructor that allows FormInstance to accept a locale
(without this constructor there's no chance to pass the user agents
locale to a javaflow FormInstance). This works for me, although I am not
sure wether it is the right solution (see
http://www.mail-archive.com/dev@cocoon.apache.org/msg33411.html)
a2) an improvement of validation handling when a submit widget should
submit without validation
b) Added id to output of validation-message and validation-error in
forms-field-styling.xsl, so that the javascript alerts can be tested
with unit tests (new template-match snip follows below). The id of the
link is val_error_ + widget id. Not sure if the naming is ok for you,
just tell if you want something different.
Tell me what's welcome, then I'll submit to bugzilla...
regards,
tom
CodeSnips:
FormInstance.java
86,104d85
< * Create a form, given the URI of its definition file, the
< * binding file and set the forms locale
< */
< public FormInstance(String definitionFile, String bindingFile,
Locale locale) {
< this(definitionFile);
< this.locale = locale;
< createBinding(bindingFile);
< }
<
< /**
< * Create a form, given the URI of its definition file, and
< * set the locale.
< */
< public FormInstance(String definitionFile, Locale locale) {
< this(definitionFile);
< this.locale = locale;
< }
<
< /**
216d196
< finished = this.isValid;
217a198
> finished = this.isValid;
forms-field-styling.xsl:
<xsl:template match="fi:validation-message | fi:validation-error">
<xsl:element name="a">
<xsl:attribute name="id">val_error_<xsl:value-of
select="../@id" /></xsl:attribute>
<xsl:attribute name="href">#</xsl:attribute>
<xsl:attribute
name="class">forms-validation-message</xsl:attribute>
<xsl:attribute name="onclick">alert('<xsl:value-of
select="normalize-space(.)" />');return false;</xsl:attribute>
 ! 
</xsl:element>
<!-- instead of: -->
<!--a id="val_error_" href="#" class="forms-validation-message"
onclick='alert("{normalize-space(.)}");return false;'> ! </a-->
</xsl:template>