struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jim Barrows" <jbarr...@sssc.com>
Subject RE: Validator upgrade?
Date Mon, 13 Dec 2004 19:08:02 GMT


> -----Original Message-----
> From: Mick.Knutson@wellsfargo.com [mailto:Mick.Knutson@wellsfargo.com]
> Sent: Monday, December 13, 2004 11:53 AM
> To: user@struts.apache.org
> Subject: RE: Validator upgrade?
> 
> 
> Bingo....
> I sent an email last week about my custom rules, and was told 
> that I should/could put my custom rules into a file called 
> validator-rules-wfb.xml and just add an entry into my 
> struts-config validator setting with that file. So now I 
> would have 4 different validator config files. But the 
> validator-rules-wfb.xml does not get loaded.
> So, I moved my custom rules back into the validator-rules.xml 
> file, and it works.

Okay..that's interesting becuase what they told you is supposed to be correct.  However, this
will still force you to monkey with the file on the next upgrade.  At this point though...
I'm guessing you don't care :)

> 
> 
> 
> --------------------
> Mick Knutson
> Wells Fargo Business Direct
> (415) 222-1020
> 
> "This message may contain confidential and/or privileged 
> information. If you are not the addressee or authorized to 
> receive this for the addressee, you must not use, copy, 
> disclose, or take any action based on this message or any 
> information herein. If you have received this message in 
> error, please advise the sender immediately by reply e-mail 
> and delete this message. Thank you for your cooperation."
> --------------------
> 
> 
> 
> -----Original Message-----
> From: Jim Barrows [mailto:jbarrows@sssc.com]
> Sent: Monday, December 13, 2004 10:26 AM
> To: Struts Users Mailing List
> Subject: RE: Validator upgrade?
> 
> 
> > -----Original Message-----
> > From: Mick.Knutson@wellsfargo.com 
> [mailto:Mick.Knutson@wellsfargo.com]
> > Sent: Monday, December 13, 2004 11:22 AM
> > To: user@struts.apache.org
> > Subject: RE: Validator upgrade?
> > 
> > 
> > here is the error I get each time (the original code is below 
> > in this thread):
> > =======================================
> > 
> > 2004-12-10 15:12:08,998 ERROR [ExecuteThread: '8' for queue:
> > 'weblogic.kernel.Default'] validator.ValidatorForm
> > (ValidatorForm.java:114) - No ValidatorActio n named 
> > isequalif found for
> > field businessLineSelected
> > org.apache.commons.validator.ValidatorException: No 
> > ValidatorAction named
> > isequalif found for field businessLineSelected
> 
> It doesn't look like it's reading your xml file with the 
> plugins in it.  I might put a break point in 
> RequestProcess.processValidate and see what it's doing at 
> this point to verify that Struts is reading your plugin 
> configuration correctly.
> 
> 
> >         at 
> > 
> org.apache.commons.validator.Field.handleMissingAction(Field.java:911)
> >         at 
> org.apache.commons.validator.Field.validate(Field.java:886)
> >         at org.apache.commons.validator.Form.validate(Form.java:174)
> >         at 
> > org.apache.commons.validator.Validator.validate(Validator.java:367)
> >         at 
> > org.apache.struts.validator.ValidatorForm.validate(ValidatorFo
> > rm.java:112)
> >         at 
> > org.apache.struts.action.RequestProcessor.processValidate(Requ
> > estProcessor.java:921)
> >         at 
> > org.apache.struts.action.RequestProcessor.process(RequestProce
> > ssor.java:206)
> >         at 
> > org.apache.struts.action.ActionServlet.process(ActionServlet.j
> > ava:1164)
> >         at 
> > 
> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
> >         at 
> > servletunit.struts.CactusStrutsTestCase.actionPerform(CactusSt
> > rutsTestCase.java:537)
> >         at 
> > com.wf.bd.ice.creditapplication.CreditApplicationActionsTest.t
> > estProductSelection(CreditApplicationActionsTest.java:135)
> >         at 
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >         at 
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccess
> > orImpl.java:39)
> >         at 
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMeth
> > odAccessorImpl.java:25)
> >         at java.lang.reflect.Method.invoke(Method.java:324)
> >         at junit.framework.TestCase.runTest(TestCase.java:154)
> >         at junit.framework.TestCase.runBare(TestCase.java:127)
> >         at 
> > org.apache.cactus.internal.AbstractCactusTestCase.runBareServe
> > r(AbstractCactusTestCase.java:153)
> >         at 
> > org.apache.cactus.internal.server.AbstractWebTestCaller.doTest
> > (AbstractWebTestCaller.java:119)
> >         at 
> > org.apache.cactus.internal.server.AbstractWebTestController.ha
> > ndleRequest_aroundBody0(AbstractWebTestController.java:93)
> >         at 
> > org.apache.cactus.internal.server.AbstractWebTestController.ha
> > ndleRequest_aroundBody1$advice(AbstractWebTestController.java:124)
> >         at 
> > org.apache.cactus.internal.server.AbstractWebTestController.ha
> > ndleRequest(AbstractWebTestController.java)
> >         at 
> > org.apache.cactus.server.ServletTestRedirector.doPost_aroundBo
> > dy2(ServletTestRedirector.java:101)
> >         at 
> > org.apache.cactus.server.ServletTestRedirector.doPost_aroundBo
> > dy3$advice(ServletTestRedirector.java:124)
> >         at 
> > org.apache.cactus.server.ServletTestRedirector.doPost(ServletT
> > estRedirector.java)
> >         at 
> > org.apache.cactus.server.ServletTestRedirector.doGet_aroundBod
> > y0(ServletTestRedirector.java:72)
> >         at  
> > org.apache.cactus.server.ServletTestRedirector.doGet_aroundBod
> > y1$advice(ServletTestRedirector.java:124)
> >         at 
> > org.apache.cactus.server.ServletTestRedirector.doGet(ServletTe
> > stRedirector.java)
> >         at 
> > javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> >         at 
> > javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >         at 
> > weblogic.servlet.internal.ServletStubImpl$ServletInvocationAct
> > ion.run(ServletStubImpl.java:971)
> >         at 
> > weblogic.servlet.internal.ServletStubImpl.invokeServlet(Servle
> > tStubImpl.java:402)
> >         at 
> > weblogic.servlet.internal.ServletStubImpl.invokeServlet(Servle
> > tStubImpl.java:305)
> >         at 
> > weblogic.servlet.internal.WebAppServletContext$ServletInvocati
> > onAction.run(WebAppServletContext.java:6350)
> >         at 
> > weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authe
> > nticatedSubject.java:317)
> >         at 
> > weblogic.security.service.SecurityManager.runAs(SecurityManage
> > r.java:118)
> >         at 
> > weblogic.servlet.internal.WebAppServletContext.invokeServlet(W
> > ebAppServletContext.java:3635)
> >         at 
> > weblogic.servlet.internal.ServletRequestImpl.execute(ServletRe
> > questImpl.java:2585)
> >         at  
> > weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
> >         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
> > 
> > 
> > 
> > --------------------
> > Mick Knutson
> > Wells Fargo Business Direct
> > (415) 222-1020
> > 
> > "This message may contain confidential and/or privileged 
> > information. If you are not the addressee or authorized to 
> > receive this for the addressee, you must not use, copy, 
> > disclose, or take any action based on this message or any 
> > information herein. If you have received this message in 
> > error, please advise the sender immediately by reply e-mail 
> > and delete this message. Thank you for your cooperation."
> > --------------------
> > 
> > 
> > 
> > -----Original Message-----
> > From: Jim Barrows [mailto:jbarrows@sssc.com]
> > Sent: Monday, December 13, 2004 10:19 AM
> > To: Struts Users Mailing List
> > Subject: RE: Validator upgrade?
> > 
> > 
> > > -----Original Message-----
> > > From: Mick.Knutson@wellsfargo.com 
> > [mailto:Mick.Knutson@wellsfargo.com]
> > > Sent: Friday, December 10, 2004 3:42 PM
> > > To: user@struts.apache.org
> > > Subject: Validator upgrade?
> > > 
> > > 
> > > with the new struts 1.2.4 upgrade, I started to change all 
> > > the <arg0 ...> to <arg position="0"...> but find that my 
> > > custom validators are not being found.
> > > 1. Is there a doc on upgrading the validator?
> > > 2. Anyone ever heard of this happening?
> > 
> > I believe requiredif is being deprecated in favor of 
> > validwhen.  However, the only reference I see is the key you 
> > are using, so that may not be valid.
> > 
> > http://struts.apache.org/userGuide/dev_validator.html
> > 
> > Other then that, everything else looks okay.  Do you have a 
> > specific error you're getting?
> > 
> > 
> > 
> > > 
> > > Here is  my <form> validator:
> > > ==========================
> > > 			<field property="businessLineSelected" 
> > > depends="isequalif">
> > > 				<msg name="isequalif" 
> > > key="requiredif.productSelectionRequired"/>
> > > 				<arg position="0" 
> > > key="form.businessLineSelected"/>
> > > 				<var>
> > > 					
> > > <var-name>thisValue[0]</var-name>
> > > 					<var-value>true</var-value>
> > > 				</var>
> > > 				<var>
> > > 					<var-name>field[0]</var-name>
> > > 					
> > > <var-value>businessCardSelected</var-value>
> > > 				</var>
> > > 				<var>
> > > 					
> > > <var-name>fieldTest[0]</var-name>
> > > 					<var-value>EQUAL</var-value>
> > > 				</var>
> > > 				<var>
> > > 					
> > > <var-name>fieldValue[0]</var-name>
> > > 					<var-value>false</var-value>
> > > 				</var>
> > > 				<var>
> > > 					<var-name>field[1]</var-name>
> > > 					
> > > <var-value>businessSecuredCardSelected</var-value>
> > > 				</var>
> > > 				<var>
> > > 					
> > > <var-name>fieldTest[1]</var-name>
> > > 					<var-value>EQUAL</var-value>
> > > 				</var>
> > > 				<var>
> > > 					
> > > <var-name>fieldValue[1]</var-name>
> > > 					<var-value>false</var-value>
> > > 				</var>
> > > 				<var>
> > > 					<var-name>field[2]</var-name>
> > > 					
> > > <var-value>equipmentExpressSelected</var-value>
> > > 				</var>
> > > 				<var>
> > > 					
> > > <var-name>fieldTest[2]</var-name>
> > > 					<var-value>EQUAL</var-value>
> > > 				</var>
> > > 				<var>
> > > 					
> > > <var-name>fieldValue[2]</var-name>
> > > 					<var-value>false</var-value>
> > > 				</var>
> > > 				<var>
> > > 					<var-name>fieldJoin</var-name>
> > > 					<var-value>AND</var-value>
> > > 				</var>
> > > 			</field>
> > > 
> > > And here is my custom validator:
> > > ===========================      <validator name="isequalif"
> > >                  
> > > classname="com.wf.bd.ice.rules.validation.ICEFieldChecks"
> > >                  method="validateIsEqualIf"
> > >                  methodParams="java.lang.Object,
> > >                                
> > > org.apache.commons.validator.ValidatorAction,
> > >                                org.apache.commons.validator.Field,
> > >                                
> > > org.apache.struts.action.ActionMessages,
> > >                                
> > org.apache.commons.validator.Validator,
> > >                                
> > javax.servlet.http.HttpServletRequest"
> > >                  msg="isequalif.default">
> > >       </validator>
> > > 
> > > 
> > > and here is the method in our ICEFieldChecks:
> > > ===================================
> > > 
> > >     public static boolean validateIsEqualIf(
> > >         Object bean, ValidatorAction va, Field field, 
> > > ActionMessages errors,
> > >         org.apache.commons.validator.Validator validator,
> > >         HttpServletRequest request
> > >     ) {
> > >         Object form =
> > >             validator.getResource(
> > >                 org.apache.commons.validator.Validator.BEAN_KEY
> > >             );
> > >         String value = null;
> > > 
> > >         if(isString(bean)) {
> > >             value = (String) bean;
> > >         } else {
> > >             value = ValidatorUtil.getValueAsString(bean, 
> > > field.getProperty());
> > >         }
> > > 
> > >         if(value == null) {
> > >             value = "";
> > >         }
> > > 
> > >         boolean required = false;
> > >         java.util.Collection theseValues = new ArrayList();
> > > 
> > >         int j = 0;
> > > 
> > >         while(
> > >             !GenericValidator.isBlankOrNull(
> > >                     field.getVarValue("thisValue[" + j + "]")
> > >                 )
> > >         ) {
> > >             theseValues.add(field.getVarValue("thisValue[" + 
> > > j++ + "]"));
> > >         }
> > > 
> > >         if(theseValues.isEmpty()) {
> > >             return true;
> > >         }
> > > 
> > >         int i = 0;
> > >         String fieldJoin = "AND";
> > > 
> > >         
> > > 
> > 
> if(!GenericValidator.isBlankOrNull(field.getVarValue("fieldJoin"))) {
> > >             fieldJoin = field.getVarValue("fieldJoin");
> > >         }
> > > 
> > >         if(fieldJoin.equalsIgnoreCase("AND")) {
> > >             required = true;
> > >         }
> > > 
> > >         while(
> > >             !GenericValidator.isBlankOrNull(
> > >                     field.getVarValue("field[" + i + "]")
> > >                 )
> > >         ) {
> > >             String dependProp = field.getVarValue("field[" 
> > + i + "]");
> > >             String dependTest = 
> > > field.getVarValue("fieldTest[" + i + "]");
> > >             String dependTestValue = 
> > > field.getVarValue("fieldValue[" + i + "]");
> > >             String dependIndexed = 
> > > field.getVarValue("fieldIndexed[" + i + "]");
> > > 
> > >             if(dependIndexed == null) {
> > >                 dependIndexed = "false";
> > >             }
> > > 
> > >             String dependVal = null;
> > >             boolean thisRequired = false;
> > > 
> > >             if(field.isIndexed() && 
> > > dependIndexed.equalsIgnoreCase("true")) {
> > >                 String key = field.getKey();
> > > 
> > >                 if((key.indexOf("[") > -1) && 
> > > (key.indexOf("]") > -1)) {
> > >                     String ind = key.substring(0, 
> > > key.indexOf(".") + 1);
> > >                     dependProp = ind + dependProp;
> > >                 }
> > >             }
> > > 
> > >             dependVal = ValidatorUtil.getValueAsString(form, 
> > > dependProp);
> > > 
> > >             if(dependTest.equals(FIELD_TEST_NULL)) {
> > >                 if((dependVal != null) && 
> > (dependVal.length() > 0)) {
> > >                     thisRequired = false;
> > >                 } else {
> > >                     thisRequired = true;
> > >                 }
> > >             }
> > > 
> > >             if(dependTest.equals(FIELD_TEST_NOTNULL)) {
> > >                 if((dependVal != null) && 
> > (dependVal.length() > 0)) {
> > >                     thisRequired = true;
> > >                 } else {
> > >                     thisRequired = false;
> > >                 }
> > >             }
> > > 
> > >             if(dependTest.equals(FIELD_TEST_EQUAL)) {
> > >                 thisRequired = 
> > > dependTestValue.equalsIgnoreCase(dependVal);
> > >             }
> > > 
> > >             if(fieldJoin.equalsIgnoreCase("AND")) {
> > >                 required = required && thisRequired;
> > >             } else {
> > >                 required = required || thisRequired;
> > >             }
> > > 
> > >             i++;
> > >         }
> > > 
> > >         if(required) {
> > >             if(!theseValues.contains(value)) {
> > >                 errors.add(
> > >                     field.getKey(), Resources.getActionMessage(
> > >                         request, va, field
> > >                     )
> > >                 );
> > > 
> > >                 return false;
> > >             } else {
> > >                 return true;
> > >             }
> > >         }
> > > 
> > >         return true;
> > >     }
> > > 
> > > 
> > > 
> > > 
> > > --------------------
> > > Mick Knutson
> > > Wells Fargo Business Direct Information Systems
> > > (415) 222-1020
> > > 
> > > "This message may contain confidential and/or privileged 
> > > information. If you are not the addressee or authorized to 
> > > receive this for the addressee, you must not use, copy, 
> > > disclose, or take any action based on this message or any 
> > > information herein. If you have received this message in 
> > > error, please advise the sender immediately by reply e-mail 
> > > and delete this message. Thank you for your cooperation."
> > > --------------------
> > > 
> > > 
> > > 
> > > 
> > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > > 
> > > 
> > > 
> > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > > 
> > > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message