Struts 2 and Velocity
Hi all I've recently switched from Struts 1.x to Struts 2.1.6 and would like to continue using velocity to render the view. I also wish to take advantage of the Struts 2 tag library by using velocity directly. From the documentation at http://struts.apache.org/2.1.6/docs/velocity-tags.html, I see the format is: #s**tag **(...) ... #end However, I'm having difficult using the tags. The following is ok and works as expected #stextfield ("label=Employee Name" "name=empname" "size=15" "maxlength=10") However, I would like to display fieldErrors as I need by name. I'm trying the following which doesn't seem to work. #sfielderror #sparam ("value=username") #end The 'end' tag is not expected on this one Can anybody point me in the right direction? Thanks Robin - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2 and Velocity
Robin Mannering wrote: From the documentation at http://struts.apache.org/2.1.6/docs/velocity-tags.html, I see the format is: #s**tag **(...) ... #end However, I'm having difficult using the tags. The following is ok and works as expected #stextfield ("label=Employee Name" "name=empname" "size=15" "maxlength=10") However, I would like to display fieldErrors as I need by name. I'm trying the following which doesn't seem to work. #sfielderror #sparam ("value=username") #end The 'end' tag is not expected on this one Can anybody point me in the right direction? Does #sfielderror ("fieldname=username") not work, or do you need multiple fields? Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2 and Velocity
Thanks for your response. Unfortunately, #sfielderror ("fieldname=username") does not work. All the current field errors are rendered in an unordered list. Using struts2 tags, it would be: field1 field2 OR These are two tags nested which I'm having trouble translating into Velocity. Any other ideas? Dave Newton wrote: Robin Mannering wrote: From the documentation at http://struts.apache.org/2.1.6/docs/velocity-tags.html, I see the format is: #s**tag **(...) ... #end However, I'm having difficult using the tags. The following is ok and works as expected #stextfield ("label=Employee Name" "name=empname" "size=15" "maxlength=10") However, I would like to display fieldErrors as I need by name. I'm trying the following which doesn't seem to work. #sfielderror #sparam ("value=username") #end The 'end' tag is not expected on this one Can anybody point me in the right direction? Does #sfielderror ("fieldname=username") not work, or do you need multiple fields? Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.375 / Virus Database: 270.12.93/2205 - Release Date: 06/27/09 05:53:00
Re: Struts 2 and Velocity
It might be fieldName; case-sensitive. I'm not very familiar with the Velocity tag support, but it may be similar to Freemarker in that some tags are in-line tags, some are block tags, and decisions were made at some point to try and cover the most common use-case. If that's the case then you'll probably have to loop over the field names of interest. Dave Robin Mannering wrote: Thanks for your response. Unfortunately, #sfielderror ("fieldname=username") does not work. All the current field errors are rendered in an unordered list. Using struts2 tags, it would be: field1 field2 OR These are two tags nested which I'm having trouble translating into Velocity. Any other ideas? Dave Newton wrote: Robin Mannering wrote: From the documentation at http://struts.apache.org/2.1.6/docs/velocity-tags.html, I see the format is: #s**tag **(...) ... #end However, I'm having difficult using the tags. The following is ok and works as expected #stextfield ("label=Employee Name" "name=empname" "size=15" "maxlength=10") However, I would like to display fieldErrors as I need by name. I'm trying the following which doesn't seem to work. #sfielderror #sparam ("value=username") #end The 'end' tag is not expected on this one Can anybody point me in the right direction? Does #sfielderror ("fieldname=username") not work, or do you need multiple fields? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2 and Velocity
Hi Dave, It worked ! It seems to be case sensitive. Thanks for your help. Can you please tell me how you knew to specify 'fieldName' ? I cannot find it documented anywhere Dave Newton wrote: It might be fieldName; case-sensitive. I'm not very familiar with the Velocity tag support, but it may be similar to Freemarker in that some tags are in-line tags, some are block tags, and decisions were made at some point to try and cover the most common use-case. If that's the case then you'll probably have to loop over the field names of interest. Dave Robin Mannering wrote: Thanks for your response. Unfortunately, #sfielderror ("fieldname=username") does not work. All the current field errors are rendered in an unordered list. Using struts2 tags, it would be: field1 field2 OR These are two tags nested which I'm having trouble translating into Velocity. Any other ideas? Dave Newton wrote: Robin Mannering wrote: From the documentation at http://struts.apache.org/2.1.6/docs/velocity-tags.html, I see the format is: #s**tag **(...) ... #end However, I'm having difficult using the tags. The following is ok and works as expected #stextfield ("label=Employee Name" "name=empname" "size=15" "maxlength=10") However, I would like to display fieldErrors as I need by name. I'm trying the following which doesn't seem to work. #sfielderror #sparam ("value=username") #end The 'end' tag is not expected on this one Can anybody point me in the right direction? Does #sfielderror ("fieldname=username") not work, or do you need multiple fields? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.375 / Virus Database: 270.12.93/2205 - Release Date: 06/27/09 05:53:00
Re: Struts 2 and Velocity
Robin Mannering wrote: Hi Dave, It worked ! It seems to be case sensitive. Thanks for your help. Can you please tell me how you knew to specify 'fieldName' ? I cannot find it documented anywhere In the S2 tag reference [1] on the fielderror tag page [2]. Dave [1] http://struts.apache.org/2.x/docs/tag-reference.html [2] http://struts.apache.org/2.x/docs/fielderror.html - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: How to set a file name using a header in the response?
Dave Newton wrote: > Jim Collings wrote: >> <%response.setHeader("Content-Disposition", "attachment; >> filename=\"filename_${fromDate}-${toDate}.doc\""); %> >> >> The above is what I currently have but I think there is a new way to >> do it that doesn't involve using a scriptlet. Also, the "fromDate" and >> "toDate" items don't work. I've tried quoting them but I'm not sure I >> got it right. They are used later on in the document, so I know I am >> getting them. > > AFAIK you can't use EL inside a scriptlet. Well I thought as much but, so far, a scriptlet is the only way I know of to make the setting above. I know that scriptlets are the old way of doing things. I'm hoping that there is a new way to do this. JSTL perhaps? How would one set a response header in JSTL, assuming that it is possible? Jim C. signature.asc Description: OpenPGP digital signature
Re: How to set a file name using a header in the response?
Jim Collings wrote: Dave Newton wrote: Jim Collings wrote: <%response.setHeader("Content-Disposition", "attachment; filename=\"filename_${fromDate}-${toDate}.doc\""); %> The above is what I currently have but I think there is a new way to do it that doesn't involve using a scriptlet. Also, the "fromDate" and "toDate" items don't work. I've tried quoting them but I'm not sure I got it right. They are used later on in the document, so I know I am getting them. AFAIK you can't use EL inside a scriptlet. Well I thought as much but, so far, a scriptlet is the only way I know of to make the setting above. You've missed my point: the code inside scriptlets is written verbatim to the generated Java source: EL is meaningless in Java source. You'd need to get the properties you're using in EL from a scoped attribute, just like servlets/JSP, or from the value stack. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: How to set a file name using a header in the response?
Putthese code in servlet or action class. don't put in the jsp file. On Sat, Jun 27, 2009 at 9:25 AM, Jim Collings wrote: > Dave Newton wrote: >> Jim Collings wrote: >>> <%response.setHeader("Content-Disposition", "attachment; >>> filename=\"filename_${fromDate}-${toDate}.doc\""); %> >>> >>> The above is what I currently have but I think there is a new way to >>> do it that doesn't involve using a scriptlet. Also, the "fromDate" and >>> "toDate" items don't work. I've tried quoting them but I'm not sure I >>> got it right. They are used later on in the document, so I know I am >>> getting them. >> >> AFAIK you can't use EL inside a scriptlet. > > Well I thought as much but, so far, a scriptlet is the only way I know > of to make the setting above. I know that scriptlets are the old way of > doing things. I'm hoping that there is a new way to do this. JSTL > perhaps? How would one set a response header in JSTL, assuming that it > is possible? > > > Jim C. > > > > > > - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
prepare{MethodName} not working
Hi, While referring the below link I came to know that we can have prepare{MethodName}() that will run before the invocation of the particular method. http://struts.apache.org/2.1.6/docs/prepare-interceptor.html I was trying the same. In my action class, I have a save() method and the action class is implemented with Preparable Interface. But when I add prepareSave() I get a error "The method prepareSave() of type ManageGeneralSetupAction must override or implement a supertype method". Do I need to override any other method or do I need to implement any other Interface? Please advice me on this. Thanks Praveen
Re: How to set a file name using a header in the response?
john feng wrote: > Putthese code in servlet or action class. don't put in the jsp file. ... >> is possible? This idea seems promising. So I have an action that results in the jsp in question and I'm using the Convention plug-in. Presumably, I would have to apply one of the *Aware interfaces to the action to get access to the response header. Am I on the right track here? Jim C. signature.asc Description: OpenPGP digital signature
Re: prepare{MethodName} not working
You probably have the @Override annotation on prepareSave(), and you don't need it. On Sat, Jun 27, 2009 at 11:40 AM, Praveen.V.Kumar < praveenkuma...@spanservices.com> wrote: > Hi, > > While referring the below link I came to know that we can have > prepare{MethodName}() that will run before the invocation of the particular > method. > > http://struts.apache.org/2.1.6/docs/prepare-interceptor.html > > I was trying the same. In my action class, I have a save() method and the > action class is implemented with Preparable Interface. But when I add > prepareSave() I get a error > "The method prepareSave() of type ManageGeneralSetupAction must override or > implement a supertype method". > > Do I need to override any other method or do I need to implement any other > Interface? > > Please advice me on this. > > Thanks > Praveen > > -- Jim Kiley Senior Technical Consultant | Summa [p] 412.258.3346 http://www.summa-tech.com
Re: prepare{MethodName} not working
> Hi, > While referring the below link I came to know that we can have > prepare{MethodName}() that will run before the invocation of the particular > method. > > http://struts.apache.org/2.1.6/docs/prepare-interceptor.html > > I was trying the same. In my action class, I have a save() method and the > action class is implemented with Preparable Interface. But when I add > prepareSave() I get a error > "The method prepareSave() of type ManageGeneralSetupAction must override or > implement a supertype method". > > Do I need to override any other method or do I need to implement any other > Interface? > Please advice me on this. You might be using the wrong stack in your xml. Check out this one: paramsPrepareParamsStack Jim C. signature.asc Description: OpenPGP digital signature
RE: prepare{MethodName} not working
I have the @Override annotations on prepareSave() but still it is saying The method prepareSave() of type ManageGeneralSetupAction must override or implement a supertype method -Original Message- From: Jim Kiley [mailto:jhki...@summa-tech.com] Sent: Saturday, June 27, 2009 9:20 PM To: Struts Users Mailing List Subject: Re: prepare{MethodName} not working You probably have the @Override annotation on prepareSave(), and you don't need it. On Sat, Jun 27, 2009 at 11:40 AM, Praveen.V.Kumar < praveenkuma...@spanservices.com> wrote: > Hi, > > While referring the below link I came to know that we can have > prepare{MethodName}() that will run before the invocation of the particular > method. > > http://struts.apache.org/2.1.6/docs/prepare-interceptor.html > > I was trying the same. In my action class, I have a save() method and the > action class is implemented with Preparable Interface. But when I add > prepareSave() I get a error > "The method prepareSave() of type ManageGeneralSetupAction must override or > implement a supertype method". > > Do I need to override any other method or do I need to implement any other > Interface? > > Please advice me on this. > > Thanks > Praveen > > -- Jim Kiley Senior Technical Consultant | Summa [p] 412.258.3346 http://www.summa-tech.com - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: prepare{MethodName} not working
Reread what I wrote: "You probably have the @Override annotation on prepareSave(), and *you don't need it*." Delete the annotation. jk On Sat, Jun 27, 2009 at 11:52 AM, Praveen.V.Kumar < praveenkuma...@spanservices.com> wrote: > I have the @Override annotations on prepareSave() but still it is saying > The method prepareSave() of type ManageGeneralSetupAction must override or > implement a supertype method > > -Original Message- > From: Jim Kiley [mailto:jhki...@summa-tech.com] > Sent: Saturday, June 27, 2009 9:20 PM > To: Struts Users Mailing List > Subject: Re: prepare{MethodName} not working > > You probably have the @Override annotation on prepareSave(), and you don't > need it. > > On Sat, Jun 27, 2009 at 11:40 AM, Praveen.V.Kumar < > praveenkuma...@spanservices.com> wrote: > > > Hi, > > > > While referring the below link I came to know that we can have > > prepare{MethodName}() that will run before the invocation of the > particular > > method. > > > > http://struts.apache.org/2.1.6/docs/prepare-interceptor.html > > > > I was trying the same. In my action class, I have a save() method and the > > action class is implemented with Preparable Interface. But when I add > > prepareSave() I get a error > > "The method prepareSave() of type ManageGeneralSetupAction must override > or > > implement a supertype method". > > > > Do I need to override any other method or do I need to implement any > other > > Interface? > > > > Please advice me on this. > > > > Thanks > > Praveen > > > > > > > -- > Jim Kiley > Senior Technical Consultant | Summa > [p] 412.258.3346 > http://www.summa-tech.com > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > -- Jim Kiley Senior Technical Consultant | Summa [p] 412.258.3346 http://www.summa-tech.com
Interceptor Use
Hello, Struts 2.1.6 I wish to ensure a user is logged into an application before allowing him/her to execute certain tasks. Would using an Interceptor be a good way to go? My idea is to retrieve session data in the intercept() method of the interceptor and verify a certain attribute is held in the session. If it is not, I would then like to redirect the user to a login page with an appropriate error message. Is this an approriate use of interceptors? Previously, I simply had a verifyLoginStatus() method in a base action class which I extended in actions I wanted to protect. I'd appreciate any thoughts... Thanks Robin - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
How to correct this syntax for multiple submit buttons?
Hi, here are the offending lines in my jsp file: Errors on console: org.apache.jasper.JasperException: /html/portlet/onlinepayment_portlet/sign_in.jsp(110,18) equal symbol expected org.apache.jasper.JasperException: /html/portlet/onlinepayment_portlet/sign_in.jsp(110,18) equal symbol expected at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40) Thanks - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor Use
Robin Mannering wrote: I wish to ensure a user is logged into an application before allowing him/her to execute certain tasks. Would using an Interceptor be a good way to go? Yep. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor Use
This is a very appropriate use for interceptors. You might also want to look at Spring Security, which does this and a lot more without too much configuration pain. jk On Sat, Jun 27, 2009 at 12:25 PM, Robin Mannering wrote: > Hello, > > Struts 2.1.6 > > I wish to ensure a user is logged into an application before allowing > him/her to execute certain tasks. > > Would using an Interceptor be a good way to go? > > My idea is to retrieve session data in the intercept() method of the > interceptor and verify a certain attribute is held in the session. > > If it is not, I would then like to redirect the user to a login page with > an appropriate error message. > > Is this an approriate use of interceptors? Previously, I simply had a > verifyLoginStatus() method in a base action class which I extended in > actions I wanted to protect. > > I'd appreciate any thoughts... > Thanks > Robin > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > -- Jim Kiley Senior Technical Consultant | Summa [p] 412.258.3346 http://www.summa-tech.com
Re: Performance issues in showcase sample struts 2.1.6 application
In particular, look for the section on creating a production profile. The tag library searches various locations for the freemarker templates, the last place it looks is inside the core jar file. Copying the template you use out of the jar will help quite a bit. Also, if performance is a huge concern, check out the javatemplates plugin. On 6/26/09, Musachy Barroso wrote: > You might want to start here: > http://struts.apache.org/2.x/docs/performance-tuning.html > > musachy > > On Fri, Jun 26, 2009 at 12:57 PM, Daniel Guryca wrote: >> Anybody ? >> >> Daniel >> >> On Fri, Jun 26, 2009 at 5:54 PM, Daniel Guryca wrote: >>> I have found that devMode was set to true .. so I changed it to false. >>> >>> Now I'm getting something around 140 req/s which is much better but >>> still somewhat slow. >>> >>> What more can I set to make it run faster ? >>> >>> My current settings are listed below: >>> >>> >>> struts.mapper.alwaysSelectFullNamespace true >>> struts.url.includeParams none >>> struts.freemarker.templatesCache false >>> struts.dispatcher.parametersWorkaround false >>> struts.multipart.maxSize 2097152 >>> struts.freemarker.mru.max.strong.size 100 >>> struts.ognl.allowStaticMethodAccess false >>> struts.codebehind.defaultPackage person >>> struts.serve.static true >>> struts.enable.DynamicMethodInvocation true >>> struts.serve.static.browserCache false >>> struts.tag.altSyntax true >>> struts.freemarker.wrapper.altMap true >>> struts.multipart.parser jakarta >>> struts.i18n.reload false >>> actionPackages org.apache.struts2.showcase.person >>> struts.objectFactory.spring.autoWire name >>> struts.xslt.nocache false >>> struts.action.extension action,, >>> struts.velocity.configfile velocity.properties >>> struts.custom.i18n.resources globalMessages >>> allowStaticMethodAccess false >>> struts.url.http.port 80 >>> struts.velocity.contexts >>> struts.configuration.xml.reload false >>> struts.objectFactory.spring.useClassCache true >>> struts.url.https.port 443 >>> devMode false >>> struts.devMode false >>> struts.ui.templateDir template >>> struts.enable.SlashesInActionNames false >>> struts.velocity.toolboxlocation >>> struts.objectFactory spring >>> struts.freemarker.manager.classname customFreemarkerManager >>> struts.ui.templateSuffix ftl >>> struts.objectFactory.spring.autoWire.alwaysRespect false >>> struts.codebehind.pathPrefix / >>> struts.multipart.saveDir >>> struts.ui.theme xhtml >>> struts.i18n.encoding UTF-8 >>> struts.freemarker.beanwrapperCache false >>> >>> >>> regards >>> Daniel >>> >>> On Fri, Jun 26, 2009 at 5:35 PM, Daniel Guryca wrote: Hi, I have just deployed included showcase sample application on to my tomcat 6. I'm very amazed how SLOWLY it runs. I'm looking for a framework for my company and Struts 2 seems very good to me (I have a previous experience with grails which is good for smaller applications but too unstable and bugy for bigger apps) but how about the Struts 2 performance ? I would expect much much better results (similar simple pages with stripes or even grails almost fly - 700 and more req/s) !! I was running these on my dual core a...@2.1 Ghz using apache bench. ab -c 10 -n 1000 'http://localhost:8080/struts2-showcase-2.1.6/skill/edit.action' 13 req/s ab -c 10 -n 1000 'http://localhost:8080/struts2-showcase-2.1.6/showcase.action' 19/ req/s Performance for other pages is also very very poor. What am I doing wrong ? Is Struts 2 really so horribly slow ? Thank you. regards Daniel >>> >> >> - >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> > > > > -- > "Hey you! Would you help me to carry the stone?" Pink Floyd > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > -- Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org