A html:select problem
Hi everyone, I'm still trying ot get my head around the Struts framework, I've got very little experience working with JSPs and Javascript and so the whole learning process can be slightly overwhelming. Please bear with me. I am trying to make a JSP page where there is a simple select box. As soon as the user selects an option I want it to do something, i.e load a page in another frame. html:form action=/getMenuItem method=GET html:select property=url html:option value=http://www.yahoo.com;Yahoo /html:option html:option value=http://www.google.com;Google/html:option /html:select . And in my struts-config.xml, the /getMenuItem refers to a MenuForm bean and a MenuAction class. The MenuForm bean has: getUrl() and setUrl() defined. Now how do I trigger the MenuAction class to work at all? I got this to run and display a select box, but I can't seem to trigger the MenuAction class at all - I put a System.out.println( ) statement in its perform() method to see if it was run at all, and nothing happened. I'm sorry this sounds trivial but its very frustrating for me! Thanks for any help out there. Jin -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Validator design considerations
I'm working ont it, For validation, I suggest an external XML file based on regular expression, in this case we are able to generate and synchronise validator functions on client and server size. ex: ** *Server size: (with project jakarta regexp) public ActionErrors validate (ActionMapping mapping, HttpServletRequest request) { ActionErrors errors=null; // Get the action errors by checking this instance and rules describe in // form-rules.xml try { errors = ReValidator.actionErrors(this); } catch (Exception e) { e.printStackTrace(); } // Check others errors. Errors cannot be explain in form-rules.xml // Return errors. return errors; } *Client side: !-- Javascript validate function for check.do -- script language=javascript function testField(field, regexp) { if ( field != null field.value != field.value != null) { var myRe = regexp.exec(field.value); if ( !myRe ) { return false; } else { return true; } } return true; } function validate() { var text=; if ( document.myForm.email.value == || document.myForm.email.value == null ) text += (email:*.\n); else if ( !testField(document.myForm.email,/[a-z0-9_-]+(\.[a-z0-9_-]+)*@[a-z0-9_-]+(\.[a-z0-9_-]+)+/) ) text += (email:[email invalide].\n) (...) if ( text == ) return true; alert(Erreur de saisie:\n\n + text); return false; } /script *And XML File form-rules regexps regexp type=day value=[1-9]|0[1-9]|[1-2][0-9]|3[0-1] message=error.jour/ regexp type=month value=[1-9]|0[1-9]|1[0-2] message=error.mois/ regexp type=year value=[0-9][0-9][0-9][0-9] message=error.annee/ regexp type=date value=($day)-($month)-($year) message=error.date/ regexp type=email value=[a-z0-9_-]+(\.[a-z0-9_-]+)*@[a-z0-9_-]+(\.[a-z0-9_-]+)+ message=error.email/ regexp type=intvalue=(^-?\d\d*$) message=error.int/ regexp type=minTwoLetter value=...* message=error.minTwoLetter/ /regexps form-beans form-bean type=com.cross.example.MyForm name=myForm property name=id regexp=$int notnull=true/ property name=firstname regexp=$minTwoLetter notnull=true/ property name=lastname regexp=$minTwoLetter notnull=(firstname!=null)/ property name=emailregexp=$email notnull=true/ property name=birthday regexp=$date/ /form-bean /form-beans /form-rules --- Andrej Sobkowski [EMAIL PROTECTED] a écrit : Hello All, I have a set of design considerations/suggestions for the Validation Framework in Struts. Let me know if I'm totally missing the point. I like the whole Validator approach, in particular the XML configuration. I believe that's the way to go, but I'd like to discuss a few points. DISCUSSION: The Validator is quite linked to Servlet's stuff (HttpServletRequest) and to FormBean. If I got it right, currently the Validator needs a set of parameters to be passed to the ValidatorAction, including the bean to validate, the Field and some Servlet parameters. In a similar way, the validation process is linked to the FormBean (validate() in FormBean class). Shouldn't they be separate? - The Action should take care of the HTTP stuff while the Validator should only have knowledge of the bean and the corresponding fields to be validated. - The form bean itself is a special data holder and shouldn't be aware of how its data is validated. Do you agree? I was thinking at something like the following (pseudo-code): * CONFIGURATION file (new DTD for struts-config.xml or separate file) actionpath=/login type=com.mycompany.myActionWithValidation name=myForm !-- add validation on myForm's property 'lastName' that will check via a SizeValidator that the size of the field is between 1 and 15 chars. If not, the message will be returned in the ValidationException (I18N can be added easily) -- validation property=lastName validator=com.mycompany.SizeValidator arg0=1 arg1=15 message=Last Name is mandatory and can't be longer than 15 chars / ... /action * JAVA CODE public interface IValidator(Object bean) { +validate() throws ValidationException; } public class Action { ... +addValidator(IValidator val) +validators(): Iterator // returns an Iterator on all validators for the action } // Validator that checks if text size is min and max (for example). // It can be easily extended to check int min/max and so on. public class SizeValidator { ... // min/max public void validate(Object bean) throws ValidationException { Object value =
help,please
i know friends that this is totally offtrack and this is not the write place to ask this questions but i am really stuck up and have no one to ask to please could u help me out i am working on a file upload example , and am copying the code as it is from a book on servlets by dustin callaway here is the code and the html file to pass on the file to the page here is the html file html body h4 align=centerfont color=#80uFile Upload Servlet/u/font/h4 table border=0 width=84% cellspacing=0 cellpadding=0 tr td width=51% form enctype=multipart/form-data action=UploadServlet method=post pfont color=#80Press the b browse/b button to select the file to upload and then click on the bUpload Button/b /font p font color=#80 nbsp; input type=hidden name=directory value=temp/ input type=hidden name=successPage value=success.html input type=hidden name=OverWrite value=false input type=hidden name=OverWritePage value=overwrite.html /font/td td width=50% p align=centerfont color=#80 br input type=file name=filename value= maxlength=255 size=50 br br input type=submit value=Upload /font/p /td /tr /table /form import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class UploadServlet extends HttpServlet { static final int MAX_SIZE =102400; String rootPath,successMessage; public void init(ServletConfig config) throws ServletException { super.init(config); rootPath = config.getInitParameter(RootPath); if (rootPath == null) { rootPath=/; } successMessage = config.getInitParameter(SuccessMessage); if (successMessage == null) { successMessage = File Upload Complete ; } } // end of init() method public void doPost(HttpServletRequest request,HttpServletResponse response) { ServletOutputStream out = null; DataInputStream in = null; FileOutputStream fileOut = null; try { response.setContentType(text/plain); out=response.getOutputStream(); } catch(IOException e) { System.out.println(Error getting the output stream); System.out.println(Error description:+e); } try { String contentType = request.getContentType(); if (contentType != null contentType.indexOf(multipart/form-data) != -1) { in = new DataInputStream(request.getInputStream()); int formDataLength = request.getContentLength(); if (formDataLength MAX_SIZE) { out.println(Sorry the file is too large to uploaad ); out.flush(); return; } // end of if byte dataBytes[] = new byte[formDataLength]; int bytesRead=0; int totalBytesRead=0; while (totalBytesRead formDataLength) { bytesRead = in.read(dataBytes,totalBytesRead,formDataLength); totalBytesRead += bytesRead; } // end of while String file = new String(dataBytes); dataBytes = null; int lastIndex = contentType.lastIndexOf(=); String boundary =contentType.substring(lastIndex+1,contentType.length()); String directory=; if(file.indexOf(name =\Directory\) 0); { directory = file.substring(file.indexOf(name=\Directory\)); directory=directory.substring(directory.indexOf(\n)+1); directory = directory.substring(0,directory.indexOf(\n)-1); if (directory.indexOf(..)0) { out.println(Security Error: You cannot do this ); return; } }// end of if String successPage=; if(file.indexOf(name=\SuccessPage\)0) { successPage=file.substring(file.indexOf(name=\SuccessPage\)); successPage=successPage.substring(successPage.indexOf(\n)+1); successPage=successPage.substring(successPage.indexOf(\n)+1); successPage = successPage.substring(0,successPage.indexOf(\n)-1); } String overWrite; if(file.indexOf(name=\OverWrite\)0) { overWrite = file.substring(file.indexOf(name=\OverWrite\)); overWrite =
RE: Using Struts with XSLT
Yeah, I did the rendering/presentation end for an entire application using XSLT. The application was a time tracking invoicing type app that we delivered as an ASP (i.e. failed .com). Spent 18 months with that stuff. We were using the Sun xml processor and the Saxon xslt compiler. It wasn't struts, but that shouldn't matter too much. I can imagine numerous ways one would eventually route the output through a XSL processor using struts -- including the method you mentioned. Some things I discovered. #1, the performance definitely was not what I could have wanted for the application. All that xml/xsl handling added a certain performance floor that simply could not be overcome. We calculated that the XSL rendering part of the application added somewhere between .5 and .75 seconds to all requests. Granted, we were doing pretty heavy rendering -- the xml objects were upwards of 30k or so. And we were getting somewhere around ~8000 page requests/hour. #2, we had to staff and train a cadre of XSL stylsheet designers. This was tough, because there were not (this was 1999/2000) alot of people with this kind of knowledge back then. The stuff is not rocket science, but still not the easiest thing in the world -- especially for interface designers. #3, the XSL syntax at the time was not standardized. We moved between the Lotus XSL processor and Saxon and had to do a complete rework of the interface layer. This may sound like a bashing, but it's not. The concept of XSL rendering is absolutely amazing. It gets one much close to that perfect separation of data and presentation. And things have progressed substantially since that time. HOWEVER, if I were to do it again, I would definitely limit the use of the XSL to areas where it was necessary. In the end, JSP is just easier. Todd -Original Message- From: Jan Arendtsz [mailto:[EMAIL PROTECTED]] Sent: Friday, November 02, 2001 9:10 PM To: [EMAIL PROTECTED] Subject: Using Struts with XSLT I would like to use Struts as my MVC framework but use XSLT for rendering the final HTML/WML pages. I thought that this would be somewhat of a common approach but was surprised to find very little information when searching through these archives. Is this something that Struts 1.1 will support? The application that I'm hoping to building should eventually support several UI devices as well as multiple languages and that's the reason we would like to use XSLT. However, we are also somewhat concerned about some of the performance ramifications when using XSLT. It seems that using Struts 1.0, I would have to do the following: - Use the action object to call JavaBeans or EJBs to retrieve data from the database either as XML text, Row sets (JDBC 2.0 extension), or custom data objects (the optimal way would be not to use XML since it's not as efficient), and store this data as a request attribute. Once the action object has forwarded to the corresponding view JSP or Servlet, this data can be retrieved (since it has a request scope), converted to a DOM object and transformed using a XSL stylesheet. I was also hoping to use the stylesheet template caching described in the book Java and XSLT by Eric Burke (http://oreilly.com/catalog/javaxslt/chapter/ch05.html) to improve performance. The JSP page used for the view will not contain any Struts tags and therefore can be a servlet. Variations to this could include the following: - Using the Jakarta XSL tag lib within the JSP page to do the transformation. This could mean that I won't get some of the performance benefits using stylesheet caching. - Use filters (new to servlet 2.3 spec). Don't know much about this, especially on the performance side. For those of you have worked on a similar application, do you have any suggestions or best practices? I'm trying to use both Struts (purely as the Model 2) and XSLT together and this does not seem to be a common practice. I could drop one or the other if the solution is a good one. Does anyone have thoughts or experience with other frameworks such as Coccon, Turbine, and Barracuda? Thanks Jan -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: How to use the radio tag inside logic:iterate tag
Hello dave It sounds better.Thank u. alvin kuttikkat antony Internet und Virtuelle Hochshule Directory Universität München Leopoldstr .3 80802 München Germany Office Tel + 49.89.21025979 Office Fax + 49.89.21025980 [EMAIL PROTECTED] 11/02/01 06:41pm See if this helps... http://www.mail-archive.com/struts-user@jakarta.apache.org/msg16684.html Cheers, Dave Alvin Kutttikkat Antony [EMAIL PROTECTED] on 11/02/2001 12:33:27 PM Please respond to Struts Users Mailing List [EMAIL PROTECTED] To:[EMAIL PROTECTED] cc:(bcc: David Hay/Lex/Lexmark) Subject: How to use the radio tag inside logic:iterate tag -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Iterate, Resin And Tomcat
HI, I have the strangest problem with the Iterate tag, Resin and Tomcat. I populate a news bean from a database and store it in the request scope (request.setAttribute(news,news);) When I iterate over the beans in Tomcat, it's fine. In resin, the iterate part is just skipped, as though the bean was empty. Does anyone have an idea? thanks, Noam
Re: Using Struts with XSLT
The wall most people run into is that, AFAIK, you have to give up the tag extensions to use XSL at runtime, which is an issue for many Struts developers. Another way to use XML in a Struts application is to use the Digester to convert the XML into a JavaBean, and then pass that along in the request. However, that would not help with your requirement to render different markup for different devices. It may be possible to use the Tiles to create different styles of pages for the different devices, but I really haven't looked at that myself. -- Ted Husted, Husted dot Com, Fairport NY USA. -- Custom Software ~ Technical Services. -- Tel +1 716 737-3463 -- http://www.husted.com/struts/ Jan Arendtsz wrote: I would like to use Struts as my MVC framework but use XSLT for rendering the final HTML/WML pages. I thought that this would be somewhat of a common approach but was surprised to find very little information when searching through these archives. Is this something that Struts 1.1 will support? The application that I'm hoping to building should eventually support several UI devices as well as multiple languages and that's the reason we would like to use XSLT. However, we are also somewhat concerned about some of the performance ramifications when using XSLT. It seems that using Struts 1.0, I would have to do the following: - Use the action object to call JavaBeans or EJBs to retrieve data from the database either as XML text, Row sets (JDBC 2.0 extension), or custom data objects (the optimal way would be not to use XML since it's not as efficient), and store this data as a request attribute. Once the action object has forwarded to the corresponding view JSP or Servlet, this data can be retrieved (since it has a request scope), converted to a DOM object and transformed using a XSL stylesheet. I was also hoping to use the stylesheet template caching described in the book Java and XSLT by Eric Burke (http://oreilly.com/catalog/javaxslt/chapter/ch05.html) to improve performance. The JSP page used for the view will not contain any Struts tags and therefore can be a servlet. Variations to this could include the following: - Using the Jakarta XSL tag lib within the JSP page to do the transformation. This could mean that I won't get some of the performance benefits using stylesheet caching. - Use filters (new to servlet 2.3 spec). Don't know much about this, especially on the performance side. For those of you have worked on a similar application, do you have any suggestions or best practices? I'm trying to use both Struts (purely as the Model 2) and XSLT together and this does not seem to be a common practice. I could drop one or the other if the solution is a good one. Does anyone have thoughts or experience with other frameworks such as Coccon, Turbine, and Barracuda? Thanks Jan -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: struts with tiles
It is not known when 1.1 will be released. http://jakarta.apache.org/struts/userGuide/kickstart.html#release It's easy to incorporate Tiles into your current project now, which is what I would recommend. -- Ted Husted, Husted dot Com, Fairport NY USA. -- Custom Software ~ Technical Services. -- Tel +1 716 737-3463 -- http://www.husted.com/struts/ peter wrote: hi Does anybody know when the next version of struts (containing tiles) will be released? Thanks Peter -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: struts / tiles / ApplicationResources problem
Make sure that there is a setting in your web.xml for the Application Resources. init-param param-nameapplication/param-name param-valueApplicationResources/param-value /init-param ... and that the ApplicationResources.properties file is on the application's classpath. Anywhere under classes should do. -- Ted Husted, Husted dot Com, Fairport NY USA. -- Custom Software ~ Technical Services. -- Tel +1 716 737-3463 -- http://www.husted.com/struts/ peter wrote: Hi Just installed tiles, which I'm running with struts1.0, and I get the following error when I try to load my .jsp file: A Servlet Exception Has Occurred Exception Report: javax.servlet.ServletException: Cannot find message resources under key org.apache.struts.action.MESSAGE at org.apache.jasper.runtime.PageContextImpl.handlePageException(Unknown Source) at org.apache.jsp.fHome$jsp._jspService(fHome$jsp.java:188) .. I think the problem might be something to do with not being able to read my ApplicationResources.properties, but I cannot find a way to solve this problem yet. If I remove all tags which reference the ApplicationResources the .jsp file loads ok. I've followed the instructions according to the installation file at: http://www.lifl.fr/~dumoulin/tiles/doc/installation.html and I've place the .tld, and .jar files in the relevant directories, and modified my web.xml file with: servlet servlet-nameaction/servlet-name servlet-classorg.apache.struts.tiles.ActionComponentsServlet/servlet-clas s init-param param-namedefinitions-config/param-name param-value/WEB-INF/tilesInstances.xml/param-value /init-param ... Have I missed something out, or does someone know what the problem might be? Thanks Peter -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: struts / tiles / ApplicationResources problem
Thanks for your quick reply. I already have the the setting in my web.xml file for Application Resources, which is placed directly under the classes directory. The Application Resources worked fine before I sdded the tiles stuff, like defining my action servlet of class ActionServlet in web.xml, as opposed to ActionComponentServlet. Thanks Peter Make sure that there is a setting in your web.xml for the Application Resources. init-param param-nameapplication/param-name param-valueApplicationResources/param-value /init-param ... and that the ApplicationResources.properties file is on the application's classpath. Anywhere under classes should do. -- Ted Husted, Husted dot Com, Fairport NY USA. -- Custom Software ~ Technical Services. -- Tel +1 716 737-3463 -- http://www.husted.com/struts/ peter wrote: Hi Just installed tiles, which I'm running with struts1.0, and I get the following error when I try to load my .jsp file: A Servlet Exception Has Occurred Exception Report: javax.servlet.ServletException: Cannot find message resources under key org.apache.struts.action.MESSAGE at org.apache.jasper.runtime.PageContextImpl.handlePageException(Unknown Source) at org.apache.jsp.fHome$jsp._jspService(fHome$jsp.java:188) .. I think the problem might be something to do with not being able to read my ApplicationResources.properties, but I cannot find a way to solve this problem yet. If I remove all tags which reference the ApplicationResources the .jsp file loads ok. I've followed the instructions according to the installation file at: http://www.lifl.fr/~dumoulin/tiles/doc/installation.html and I've place the .tld, and .jar files in the relevant directories, and modified my web.xml file with: servlet servlet-nameaction/servlet-name servlet-classorg.apache.struts.tiles.ActionComponentsServlet/servlet-clas s init-param param-namedefinitions-config/param-name param-value/WEB-INF/tilesInstances.xml/param-value /init-param ... Have I missed something out, or does someone know what the problem might be? Thanks Peter -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
strust-example error?
Hi, I'm a very newbie. I was trying to get strut-example to work. After the index.jsp, it gives internal server error for Register with the MailReader The error says Parsing error processing resource path /WEB-INF/struts-config.xml Would you be able to point me to the right direction. Thanks Jae = Jae Chi [EMAIL PROTECTED] Without Fear There is not Courage. __ Do You Yahoo!? Find a job, post your resume. http://careers.yahoo.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Fw: redirection
- Original Message - From: Andrew Kirkland [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, October 31, 2001 4:01 AM Subject: RE: redirection Whenever I write a struts application and try to do anything involving an action mapping, my browser is simply redirected to the corresponding *.do file! Can someone tell me whats wrong? Im using tomcat 3.3. This is the example I have been following : http://www.jspinsider.com/tutorials/jsp/struts/lesson1/l1b_struts.view#top however, I have tried several examples including pre-coded downloads and ones ive done myself all with the same problem. Ive rechecked the instructions for installing struts several times and cannot see a problem. Thanks for your help Andy -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] . -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
forward action - basic understanding
I've seen examples where both... return mapping.findForward(success); and return new ActionForward(mapping.getInput()); ...redirect to the same location (and the new ActionForward appears to always be used under user error type situations). What's the difference between these two (in re: to what they do behind the scenes) and what's the rule on when to use one method vs. the other? Thanks, Dave -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]