Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=3308850
By: sandra81
I tried to debug what's going on.
I looked at the code of dbforms and I realized that when I validate the form
I do not pass into the org.dbforms.event.ValidationEvent.doValidation() method.
I don't understand why.
So, I found another solution. I use the interceptors.
But I have problems.
I have to create a ProductValidation class to validate my products. Here is
the code:
package com.altervisions.annuaire;
import org.dbforms.config.*;
import org.dbforms.event.*;
import java.sql.*;
import java.util.Vector;
import javax.servlet.http.*;
public class Product extends DbEventInterceptorSupport {
private int checkProduct(FieldValues fieldValues)
throws ValidationException
{
Vector errors = new Vector();
String designation = (String)
fieldValues.get("designation").getFieldValue();
String category = (String)
fieldValues.get("category_id").getFieldValue();
if (designation == null || designation.trim().length()==0 ||
designation.compareTo("") == 0) {
errors.add("Designation is required.<br>");
}
if (category.compareTo("0") == 0 ||
category.trim().length()==0) {
errors.add("Category is required<br>");
}
if(!errors.isEmpty()) {
throw new MultipleValidationException(errors);
}
else return GRANT_OPERATION;
}
public int preInsert(HttpServletRequest request, Table table,
FieldValues
fieldValues, DbFormsConfig config, Connection con)
throws ValidationException {
return checkProduct(fieldValues);
}
public int preUpdate(HttpServletRequest request, Table table,
FieldValues
fieldValues, DbFormsConfig config, Connection con)
throws ValidationException {
return checkProduct(fieldValues);
}
}
In the dbform tag I put the following attributes:
<db:dbform tableName="alter_achat_product"
maxRows="1"
multipart="true"
followUp="alter_annuaire_product_search.jsp"
redisplayFieldsOnError="true"
followUpOnError="alter_annuaire_product_creation.jsp"
autoUpdate="false"
captionResource="true">
For creation everything works well, but for the update the error message is
posted twice.
Could you explain me why?
Thanks in advance !
Regards
Sandra
______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=55830
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
DbForms Mailing List
http://www.wap-force.net/dbforms