Hi,
SmartGWTEE 2.4, Firefox 3.6
I'm trying to develop a server side validator according to an example http://www.smartclient.com/smartgwtee/showcase/#validation_dmi
I defined my validator in .ds.xml
The ServerValidatorM implementation:
when the call from DynamicForm arrives to the server's controller I call
and receive the following exception. What I did wrong?
My intention here is to achieve a customized validator for both server-side and client-side.
I've read the this is impossible to do in one class. Therefore I chose to implement two validators, one for client - extending CustomValidator and Server - using POJO with the condition method.
Then put them both into .ds.xml with clientOnly and serverOnly flags.
Is this approach recommended? Or is there is way to implement CustomValidator for both sides at once?
best regards,
Zdary
SmartGWTEE 2.4, Firefox 3.6
I'm trying to develop a server side validator according to an example http://www.smartclient.com/smartgwtee/showcase/#validation_dmi
I defined my validator in .ds.xml
Code:
<field name="surname" type="text" required="true"> <validators> <validator type="lengthRange" min="1" max="50"/> <validator type="serverCustom"> <serverObject lookupStyle="new" className="cz.bcom.server.validators.ServerValidatorM"/> <errorMessage>Only available in stock</errorMessage> </validator> </validators> </field>
Code:
package cz.bcom.server.validators; import java.util.Map; import com.isomorphic.datasource.DataSource; import com.isomorphic.datasource.Validator; public class ServerValidatorM { public boolean condition(Object value, Validator validator, String fieldName, Map record, DataSource ds) throws Exception { System.out.println("HELLO"); return false; } }
Code:
Map<?, ?> newValues = dsRequest.getValues(); ErrorReport errorReport = baseBeanDS.validate(newValues, false);
Code:
[WARN] /helloworld/commonDS.rpc java.lang.NullPointerException at com.isomorphic.util.DefaultValidators$serverCustom.callServerObject(DefaultValidators.java:1131) at com.isomorphic.util.DefaultValidators$serverCustom.validate(DefaultValidators.java:1073) at com.isomorphic.util.DefaultValidators.processValidator(DefaultValidators.java:264) at com.isomorphic.util.DefaultValidators.validateField(DefaultValidators.java:230) at com.isomorphic.datasource.SimpleType.validateValue(SimpleType.java:89) at com.isomorphic.datasource.SimpleType.create(SimpleType.java:65) at com.isomorphic.datasource.BasicDataSource.validateFieldValue(BasicDataSource.java:1046) at com.isomorphic.datasource.BasicDataSource.validateFieldValue(BasicDataSource.java:993) at com.isomorphic.datasource.BasicDataSource.toRecord(BasicDataSource.java:671) at com.isomorphic.datasource.BasicDataSource.toRecords(BasicDataSource.java:586) at com.isomorphic.datasource.DataSource.validate(DataSource.java:1725) at cz.bcom.server.persistence.controllers.DSControllerImpl.process(DSControllerImpl.java:126) at cz.bcom.server.persistence.controllers.CommonDSController.handleRequest(CommonDSController.java:79) at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:859) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:793) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097) at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:324) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
I've read the this is impossible to do in one class. Therefore I chose to implement two validators, one for client - extending CustomValidator and Server - using POJO with the condition method.
Then put them both into .ds.xml with clientOnly and serverOnly flags.
Is this approach recommended? Or is there is way to implement CustomValidator for both sides at once?
best regards,
Zdary
Comment