Re: struts 1.1 validation problem / question
Hi Victor, thanks for you reply. the lookupdispatchaction does not really solve my problem, since handling the different actions is not the problem. the problems is the validation of the input fields for the different action. i need different validations depending on the value of the userAction html form value. thanks, Andreas On Sunday 16 November 2003 10:51, Victor wrote: Oi Andre, Tries to verify the LookupDispatchAction class, this class allows to manage diverse actions in simple Action and in this way you can better manage its validations with the Validator. Good code. Victor Amano Izawa __ Yahoo! Mail: 6MB, anti-spam e antivĂrus gratuito! Crie sua conta agora: http://mail.yahoo.com.br - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: struts 1.1 validation problem / question
Hi Andreas, i think the best way is to write your own validate() method in your action form. There you can easily check the value of the userAction attribute and depending on that the other attributes. example: public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (getName().length() 1) { errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(form.error.name.required)); } return errors; } HTH Phil - Original Message - From: Andreas Wuest [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, November 15, 2003 2:36 PM Subject: struts 1.1 validation problem / question Hi, i have a small problem / question concerning the struts 1.1 validation. i have a jsp form that has the following input fields : id name password userAction Depending on the userAction value (can be 'show' or 'save') i need to validate only the id (when userAction is 'show') or the name, password and id (when the userAction is 'save'). i have one form that contains the 4 properties (with getters and setters) and an action class that handles the show and the save action. the problem that i have is the validation. as far as i understand the docuemtneation it is not possible to validate a property only when another property has a certain value. in other words it is not possible to tell the validator to skip validation of a property when another property has a certain value. or am i mistaken ? how can i solve this problem ? do i need 2 forms and action to handle the different userActions or is there another way ?? Thanks in advance, Andreas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: file upload
i've not used dynaforms with fileupload so if that is the problem I couldn't say. you could try it with a normal formBean. However as the problem is trying to set a formfile using a string it looks like the problem could be in your jsp. have you set the enctype like below, html:form action=/blah enctype=multipart/form-data and the form property using html:file rather than html:text html:file property=pb_file/ goodluck, c On Friday 14 November 2003 13:38, sairam manda wrote: Hello Sir, I am new to sturts . I want to upload a file . I am using dynaform . these are snippets in the dynaform I used form-property name=pb_file type=org.apache.struts.upload.FormFile/ and in my action class I used the following code FormFile file = (FormFile) form.get(pb_file); I get the following error org.apache.commons.beanutils.ConversionException: Cannot assign value of type 'java.lang.String' to property 'pb_file' of type 'org.apache.struts.upload.FormFile' org.apache.struts.action.DynaActionForm.set(DynaActionFo rm.java:423) org.apache.commons.beanutils.PropertyUtils.setSimplePrope rty(PropertyUtils.java:1769) org.apache.commons.beanutils.PropertyUtils.setNestedPrope rty(PropertyUtils.java:1684) org.apache.commons.beanutils.PropertyUtils.setProperty(Pr opertyUtils.java:1713) org.apache.commons.beanutils.BeanUtils.setProperty(BeanUt ils.java:1019) org.apache.commons.beanutils.BeanUtils.populate(BeanUtils .java:808) org.apache.struts.util.RequestUtils.populate(RequestUtils .java:1252) org.apache.struts.action.RequestProcessor.processPopulate (RequestProcessor.java:821) org.apache.struts.action.RequestProcessor.process(Request Processor.java:254) org.apache.struts.action.ActionServlet.process(ActionServ let.java:1482) org.apache.struts.action.ActionServlet.doPost(ActionServl et.java:525) javax.servlet.http.HttpServlet.service(HttpServlet.java:7 63) javax.servlet.http.HttpServlet.service(HttpServlet.java:8 56) can somebody make me waware of the problem. regards sairam _ Enjoy shopping online? Get this e credit card. http://server1.msn.co.in/features/amex/ It cuts cost adds value! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: NoClassDefFoundError in custom validator
Ok I figured out a way to make it all work ... The solution ended up being to put all the commons jar files in the root of the ear, and add them to application.xml as java modules. Looks like it was indeed a classloader issue then ... which would lead me to think that this is a bug. No reason why Struts shouldn't be able to do all of the reflection, especially since this is hardly pushing the envelope. Any thoughts? cheers Rob -Original Message- From: Rob van Oostrum [mailto:[EMAIL PROTECTED] Sent: November 14, 2003 6:11 PM To: [EMAIL PROTECTED] Subject: NoClassDefFoundError in custom validator I added the commons validator to my Struts implementation. The out-of-the-box stuff is working just fine. However, I added the following custom validator: public class BarnmanValidator implements Serializable { public static boolean validateEmailAddress(Object bean, Field field) { [etc, etc, etc] When this one is about to be invoked, I get this exception (as root cause of a servlet exception): java.lang.NoClassDefFoundError: org/apache/commons/validator/Field at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:1647) at java.lang.Class.getMethod0(Class.java:1893) at java.lang.Class.getMethod(Class.java:976) at org.apache.commons.validator.Validator.validateFieldForRule(Valida tor.java:4 01) the validator def: validator name=email.unique classname=com.springwell.barnman.validator.BarnmanValidator method=validateEmailAddress methodParams=java.lang.Object,org.apache.commons.validator.Field msg=errors.email.duplicate / the form def: form name=register field property=emailAddress depends=required,email,email.unique / field property=password1 depends=required / field property=password2 depends=required / field property=firstName depends=required / field property=lastName depends=required / /form If I omit my custom validator everything works fine. the commons-validator.jar is in my war file's WEB-INF/lib, and there seems to be no problem locating org.apache.commons.validator.Validator (as you can tell from the stacktrace). Only thing I can think of is that it's a different classloader trying to load the Field class through reflection? Any known solutions to known problems? thanks in advance, Rob - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Iterate problem
Hi, I hava a userForm that has a ArrayList of User objects, each User object has several properties: fistname, lastname, age. How can I get all User's firstname, lastname, age in an iterate? Thanks. bruce
Re: Problem of nested logic:iterate
I have a similiar problem. I hava a userForm that has a ArrayList of User objects, each User object has several properties: fistname, lastname, age. How can I get all User's firstname, lastname, age in an iterate? - Original Message - From: Sumit S. [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Thursday, November 13, 2003 6:35 PM Subject: RE: Problem of nested logic:iterate Here u go...I have a userForm that has a list of users. Each User further has a list of orders...here's the logic:iterate code to do what u want to do ... logic:iterate name=userForm property=users id=user bean:write name=user property=firstname/ logic:iterate name=user property=orders id=order bean:write name=order property=orderdesc/ /logic:iterate /logic:iterate Sumit -Original Message- From: Raman Garg [mailto:[EMAIL PROTECTED] Sent: Thursday, November 13, 2003 2:46 PM To: Struts Users Mailing List Subject: Problem of nested logic:iterate Hi, I have a problem regarding struts logic:iterate I need to show category wise listing of products. so can anybody advice me how to create nested logic iterate loops to accomplish this. what i need is there will be two nested logic iterates logic:iterate !--this is for listing of catergory-- logic:iterate !--this is for products under a catergory-- /logic:iterate /logic:iterate How can populate the inner loop variable??? Thanks in advance, Raman Garg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Where to get the latest Scaffold jar and documentation?
Thanks Caoilte. - Original Message - From: Caoilte O'Connor [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, November 16, 2003 10:04 PM Subject: Re: Where to get the latest Scaffold jar and documentation? The Scaffold in Struts in Action book is very different from the version included with the Artimus example app in Struts 1.1 contrib. I wouldn't advise using those chapters as anything more than a general introduction to the framework. and AFAIK ted considers the framework finished. c On Saturday 15 November 2003 09:20, ZYD wrote: I downloaded a file called scaffold-lib_1_1_b1.zip, there are two jar files inside: commons-scaffold.jar and struts-scaffold.jar In Struts in Action, page 434, org.apache.scaffold.text.MessageUtils is metioned. Does anybody knows where is it? It's not in the two jar files above. I cannot find it anywhere. Even jakarta.apache.org . I also searched the net using google, still no answer. If you are using Scaffold, please give me some help, thanks in advance. bruce BTW: Is Scaffold still being actively maintained and updated? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Redirecting after logon...
Some of my pages need the user to be logged on before they can be viewed, so I have cobbled together some simple behaviour in my Action superclass that forwards them to a logon page. Now, I need to send them back to where they were originally trying to go before I redirected them to logon. I have a couple of questions banging around in my head: 1. Should this redirection be performed by my RequestProcessor class or by my Action superclass? 2. After they have logged on (in LogonAction), I need to return an ActionForward object that takes them back to where they were trying to go originally before I forced them to logon. However, I don't know how to construct an ActionForward that contains everything it needs (for example, what if their original request was a POST containing FORM data, or was a URL like /action/blah?id=123a=bc=d... I want to preserve and forward this info.) 3. I would have thought that nearly every web app would need this behaviour, but both my struts textbooks give mickey-mouse examples, and I can't find anything on the web that looks remotely like a real-world example. Does anyone know of any real examples or advice that they would care to share? Many thanks... -- Craig Edwards Sydney, Australia - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to forward without redirect from action?
I have an action that does the following: public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { request.setAttribute( testing, This is a test ); return new ActionForward( mapping.getInput(), false ); } And I have a jsp page that has the following: %= pageContext.findAttribute( testing ) % The problem is the jsp page always prints null and the url is never that of the action, always that of the page. This means the action is always redirecting to the input page no matter what I set the redirect variable in the ActionForward to be. How do I forward to the input page without redirecting? Here's my action mapping: action-mappings action path=/home/feedback/Email type=org.app.struts.action.EmailAction name=feedback validate=true input=/home/feedback /action /action-mappings If you have any ideas or need more info to help out, please let me know. Thanks, Eric - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ExceptionHandler
Hi, I am trying to use the exception handling from default struts ExceptionHandler. I declared this inside a action tag in struts config.xml : exception type=br.com.tatil.tatilj.exception.FaseJaExisteException key=tatilJ.exception.faseJaExisteException path=tiles.erro / 1- I was always getting the white screen. So I put the input property in the action tag. It started going to the input I declared, but what I wanted was to go to the path declared above (tiles one). 2- Beside, I get: [ServletException in:/componentes/mensagens.jsp] Cannot find bean error in any scope' . Any clue??? Tks a lot, Felipe. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Redirecting after logon...
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... You could do that... or you could do it the J2EE way, decleratively without any coding, letting container do it that way: Thanks for the reply Vic. I can see how that would be the way to go if I were starting from scratch. Unfortunately, I am using a framework that has its own repository for users/roles and I don't think I will be able to coerce it into operating within the J2EE Realm/LoginConfig model. Assuming that I have to build my own infrastructure to handle this, do you have any more thoughts? I already have code that recognizes the user isn't logged on and redirects them to logon... I am just missing the step that sends back to where they were originally going. Thanks again for the feedback. -- Craig Edwards Sydney, Australia - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ExceptionHandler
Yes it is. I am from Brazil. It is in portuguese. Tks. - Original Message - From: Rick Reumann [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Monday, November 17, 2003 2:39 AM Subject: Re: ExceptionHandler Felipe Nascimento wrote: key=tatilJ.exception.faseJaExisteException path=tiles.erro / Is the tiles definition really called tiles.erro and not tiles.error ? -- Rick - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ProcessBeanBase subclass
Hi, I have a ProcessBeanBase subclass that is my business object. I implemented a JUnit test to see why I was getting the final Response Cannot create iterator for this collection' in my browser screen, and I always fall in that ClassCastException. Need help to understand why. Tks! Here is my business object, that extends Empresa that extends ProcessBeanBase : public class BuscaEmpresasComProjeto extends Empresa{ public final String LEGENDA = Empresas com Projetos.; public Object execute(Object parametros) throws Exception{ super.execute(parametros); ResultList list = new ResultListBase( TatilFacade.getInstance().getEmpresasComProjeto(this) ); list.setLegend(LEGENDA); return new ProcessResultBase(list); } } Here is the test: /* * Test for Object execute(Object) */ final public void testExecuteObject() { /** * Subclass of ProcessBeanBase. * Implements execute(Object) method; */ BuscaEmpresasComProjeto busca = new BuscaEmpresasComProjeto(); ArrayList c = null; try { c = (ArrayList) busca.execute(null); } catch (ClassCastException ex){ Assert.fail(Nao conseguiu fazer o cast de Object para ArrayList, vinda de BuscaEmpresasComProjeto.execute() ); ex.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } Assert.assertTrue( c.size() 0); Iterator i = c.iterator(); Assert.assertNotNull(i); } Felipe