I am a beginner, i'm tring to setup validation and I can't get it work, i'm in big troubles ....
Can someone help me yo discover where is my mistake?
In validation.xml, generated by DEVGUI I have this piece of validation definition
<form name="Annuncio">
.....
<field depends="maxlength" property="Titolo">
<msg key="Titolo has a maximum length of ${var:maxchars}" resource="false" name="maxlength"/>
<arg0 key="${var:maxchars}" resource="false" name="maxlength"/>
<var>
<var-name>maxchars</var-name>
<var-value>50</var-value>
</var>
</field>
....
</form>
In Eclipse console, running the form i get this message:
142716 [http8080-Processor4] ERROR org.dbforms.validation.DbFormsValidatorUtil - Not in proper format - do not try to convert!
With some debug I found that in File DbFormsValidatorUtil, this piece of code ....
try
{
result = errors.getXMLErrorMessage(result);
}
catch (Exception e)
{
logCat.error("Not in proper format - do not try to convert!");
}
has result set with value "Titolo has a maximum length of ${var:maxchars}:50" and errors is null so exception is fired!
I want only make simple test don't use i18n without resource bundle resource="false"
My version is DBFORMS 2.4 on Tomcat 4.18 JVM 1.4.1
Tank you
Luigi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If I understand well you tell that arg0 MUST be the name of the field.
With "name of the field" do you think about a key you declared in dbforms-errors.xml?
I don't want to user external file for error message configuration and code generated by DEVGUI seem consistent.
Perhaps I have some basic configuration error because I get this ...
0 [main] WARN org.dbforms.servlets.ConfigServlet - XML Errors file not found, XML error handler disabled!
171 [main] WARN org.dbforms.servlets.ConfigServlet - Application Resources file not setted in Web.xml, ApplicationResources handler disabled!
171 [main] WARN org.dbforms.servlets.ConfigServlet - Locale Key not setted, use "org_dbforms_LOCALE" as key to access the Locale in session scope.
on Tomcat start and this ...
156112 [http8080-Processor4] ERROR org.dbforms.util.MessageResource - getMessage
java.util.MissingResourceException: Can't find bundle for base name org.dbforms.resources.messages, locale it
at java.util.ResourceBundle.throwMissingResourceException(Unknown Source)
at java.util.ResourceBundle.getBundleImpl(Unknown Source)
at java.util.ResourceBundle.getBundle(Unknown Source)
at org.dbforms.util.MessageResource.getMessage(MessageResource.java:91)
at org.dbforms.util.MessageResourcesInternal.getMessage(MessageResourcesInternal.java:71)
at org.dbforms.config.Field.getFormat(Field.java:349)
at org.dbforms.taglib.DbBaseHandlerTag.getFormat(DbBaseHandlerTag.java:185)
at org.dbforms.taglib.DbBaseHandlerTag.getFormattedFieldValue(DbBaseHandlerTag.java:302)
at org.dbforms.taglib.DbDataContainerLabelTag.doEndTag(DbDataContainerLabelTag.java:87)
at org.apache.jsp.FAQ_gestione_jsp._jspx_meth_db_dataLabel_0(FAQ_gestione_jsp.java:487)
at org.apache.jsp.FAQ_gestione_jsp._jspService(FAQ_gestione_jsp.java:200)
.....
on first page request (but the form works).
Seems that DbForms is tryng to get info on IdFAQ that is declared as ...
That's are only warnings - no faults. Is a hint that you have no resources defined.
arg0 is the text wich should be shown for the fieldname in the error message. If you do not use resources then just write the text you want do be shown.....
If you define resource="false" for arg0 the text is not gotten from any resources.
There is a manual how to define the valiudation - have a look into the articles/usefull/validating_user_input.pdf file.
By the way - i use dbforms for a real project - and it works fine.
Henner
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
After a lot of attempts I obtained some useful result moving ${var:maxchars} from "<msg TAG" to "<arg0 TAG".
I think that DEVGUI problem is in generate_validation.xsl where ${var:maxchars} is used inside "<msg TAG" but I suppose this is not supported.
If you thin that I'm not wrong I can suggest a little correction on xslt.
Now I have another problem .... :-(
if I use depends="required,minlength" only minlenght validation is client side, the first is on server.
Some suggestion?
Tank you
Luigi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That depends of of your validator-rules.xml. Is there a javascript method defined?
And what's your dbforms attributtes? Do you use an included script for validation or let you put the javascript code into the page directly?
I never tested the first solution - and i never corrected the include file...
See above - help is welcome!
Henner
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Seems that you are right. In this case the error will occur on the server side.
Feel free to rework the javascript code.
There is a parameter somewhere with wich you can distinguish between insert and update mode.
Please send me your changes - so that i can put them into the release!
Thanks
Henner
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am a beginner, i'm tring to setup validation and I can't get it work, i'm in big troubles ....
Can someone help me yo discover where is my mistake?
In validation.xml, generated by DEVGUI I have this piece of validation definition
<form name="Annuncio">
.....
<field depends="maxlength" property="Titolo">
<msg key="Titolo has a maximum length of ${var:maxchars}" resource="false" name="maxlength"/>
<arg0 key="${var:maxchars}" resource="false" name="maxlength"/>
<var>
<var-name>maxchars</var-name>
<var-value>50</var-value>
</var>
</field>
....
</form>
In Eclipse console, running the form i get this message:
142716 [http8080-Processor4] ERROR org.dbforms.validation.DbFormsValidatorUtil - Not in proper format - do not try to convert!
With some debug I found that in File DbFormsValidatorUtil, this piece of code ....
try
{
result = errors.getXMLErrorMessage(result);
}
catch (Exception e)
{
logCat.error("Not in proper format - do not try to convert!");
}
has result set with value "Titolo has a maximum length of ${var:maxchars}:50" and errors is null so exception is fired!
I want only make simple test don't use i18n without resource bundle resource="false"
My version is DBFORMS 2.4 on Tomcat 4.18 JVM 1.4.1
Tank you
Luigi
Seems that devgui has an bug...
Here is an working example
<field property="user_name" depends="required,maxlength">
<arg0 key="aucos.user.name" />
<arg1 name="maxlength" key="${var:maxlength}" resource="false" />
<var>
<var-name>maxlength</var-name>
<var-value>15</var-value>
</var>
</field>
First arg must be the name of the field. Second is the maxlength attribute.
Cheers,
Henner
Tank you for your time.
If I understand well you tell that arg0 MUST be the name of the field.
With "name of the field" do you think about a key you declared in dbforms-errors.xml?
I don't want to user external file for error message configuration and code generated by DEVGUI seem consistent.
Perhaps I have some basic configuration error because I get this ...
0 [main] WARN org.dbforms.servlets.ConfigServlet - XML Errors file not found, XML error handler disabled!
171 [main] WARN org.dbforms.servlets.ConfigServlet - Application Resources file not setted in Web.xml, ApplicationResources handler disabled!
171 [main] WARN org.dbforms.servlets.ConfigServlet - Locale Key not setted, use "org_dbforms_LOCALE" as key to access the Locale in session scope.
on Tomcat start and this ...
156112 [http8080-Processor4] ERROR org.dbforms.util.MessageResource - getMessage
java.util.MissingResourceException: Can't find bundle for base name org.dbforms.resources.messages, locale it
at java.util.ResourceBundle.throwMissingResourceException(Unknown Source)
at java.util.ResourceBundle.getBundleImpl(Unknown Source)
at java.util.ResourceBundle.getBundle(Unknown Source)
at org.dbforms.util.MessageResource.getMessage(MessageResource.java:91)
at org.dbforms.util.MessageResourcesInternal.getMessage(MessageResourcesInternal.java:71)
at org.dbforms.config.Field.getFormat(Field.java:349)
at org.dbforms.taglib.DbBaseHandlerTag.getFormat(DbBaseHandlerTag.java:185)
at org.dbforms.taglib.DbBaseHandlerTag.getFormattedFieldValue(DbBaseHandlerTag.java:302)
at org.dbforms.taglib.DbDataContainerLabelTag.doEndTag(DbDataContainerLabelTag.java:87)
at org.apache.jsp.FAQ_gestione_jsp._jspx_meth_db_dataLabel_0(FAQ_gestione_jsp.java:487)
at org.apache.jsp.FAQ_gestione_jsp._jspService(FAQ_gestione_jsp.java:200)
.....
on first page request (but the form works).
Seems that DbForms is tryng to get info on IdFAQ that is declared as ...
<table name="FAQ" defaultVisibleFields="IdFaq" >
<field name="IdFaq" fieldType="int" size="10" isKey="true"/>
....
I appreciate every help because I'm evaluating dbforms on a real project but i can't get advanced results, only basic form data entry.
Luigi
That's are only warnings - no faults. Is a hint that you have no resources defined.
arg0 is the text wich should be shown for the fieldname in the error message. If you do not use resources then just write the text you want do be shown.....
If you define resource="false" for arg0 the text is not gotten from any resources.
There is a manual how to define the valiudation - have a look into the articles/usefull/validating_user_input.pdf file.
By the way - i use dbforms for a real project - and it works fine.
Henner
After a lot of attempts I obtained some useful result moving ${var:maxchars} from "<msg TAG" to "<arg0 TAG".
I think that DEVGUI problem is in generate_validation.xsl where ${var:maxchars} is used inside "<msg TAG" but I suppose this is not supported.
If you thin that I'm not wrong I can suggest a little correction on xslt.
Now I have another problem .... :-(
if I use depends="required,minlength" only minlenght validation is client side, the first is on server.
Some suggestion?
Tank you
Luigi
Feel free to do so!
Help is welcomed!
That depends of of your validator-rules.xml. Is there a javascript method defined?
And what's your dbforms attributtes? Do you use an included script for validation or let you put the javascript code into the page directly?
I never tested the first solution - and i never corrected the include file...
See above - help is welcome!
Henner
Yes, in my validator-rules.xml (found on distro) is present a default method for required field validation.
After a little client side debugging of generated javascript I found that required validation never returns errors.
I think that this is caused by
&& (value != oldValue) ) {
present in the method mentioned above.
If I delete this condition all goes well.
Is this a little bug I found or i'm wrong?
Tank you
Luigi
You are wrong - value needs only be tested if it's changed.
A not changed value is not tested.
This statement just compares old and new value...
Cheers
Henner
yes, but if i'm testing required fields on a form made for add a new record.
In this situation, if user don'compile a required field new_value = old_value = ''.
Required field error can not be catched, I think.
Bye
Luigi
Seems that you are right. In this case the error will occur on the server side.
Feel free to rework the javascript code.
There is a parameter somewhere with wich you can distinguish between insert and update mode.
Please send me your changes - so that i can put them into the release!
Thanks
Henner