From: Anthony E. <me...@an...> - 2003-04-11 17:43:29
|
Matthew Patrick Hardy wrote: > Hello, > > I'm trying to get a reletively simple form working with the formproc API > for demonstration purposes however i'm running into some problems with the > script validators. I've been trying to use the FieldsMatch.py in my own > form and I get some odd results. The following is a snippet from my form > include: > > <element name="session_1" optional="true"> > <validator type="shared" name="forbidden_chars"/> > <message classname="org.formproc.message.ResourceBundleMessageProvider"> > <bundle>org.formproc.example.ExampleResourceBundle</bundle> > <key>session_1.message</key> > </message> > </element> > > <element name="session_1_class" optional="true"> > <validator type="shared" name="forbidden_chars"/> > <message></message> > </element> > > <element-group name="session_1"> > <element name="session_1"/> > <element name="sessoin_1_class"/> > <validator type="script"> > <script>FieldsMatch.py</script> > <error>Passwords must must match.</error> > </validator> > </element-group> > > Now session_1_class and session_1 are both select boxes with different > values so they will never validate correctly but I should still get the > "Passwords must must match." error in my form when I do > > <%= results.getErrorOrMessage("session_1") %> Currently getErrorOrMessage() does not look into group results to find errors or messages. If you want to get error messages for a group you would need to use getGroupErrorMessage(). > in the jsp. But instead I get the following error when the above code is > included in the xml include: > > org.formproc.FormConfigurationException: Form configuration not found for > 'campcaen-page1' > at > org.formproc.FormManager.getFormConfiguration(FormManager.java:209) > at org.formproc.FormManager.configure(FormManager.java:196) > at > org.apache.jsp.campcaen_0002dpage1$jsp._jspService(campcaen_0002dpage1$jsp.java:183) > at > org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > > etc... That's a strange error to receive. It would appear that the form configuration is never loaded which would indicate that an exception is being thrown during the loading of that form configuration. Which version of FormProc are you using? Do you see anywhere in your server logs an exception during the loading of the form configuration? > 'campcaen-page1' is the name of my form. I don't get this exception > without the <element-group><element-group/>. Also is there anyway to > return an error message from the script? I'm checking for schedule > conflicts between selections and it would be helpful if the script could > generate the error message based on what the problem was. Currently there is not, but perhaps something can be added to the ScriptResult object. The only problem I see is that I am not sure how to get this into the FormResult. Currently the FormResult can only store an error if it extends from Throwable. I suppose any script errors could be wrapped in an exception even if it will never be thrown. Thoughts? > One more thing. It would be very helpful to have a more extensive example > that spans multiple pages and has more than just input boxes. I agree, but I am rather stretched for time. If you would like to contribute more extensive examples I would be glad to include them with the distribution. Sincerely, Anthony Eden |