RE: Need documentation or code example for custom tag in Struts 2.3.24
Struts 2.3.24 has many changes in URL tag related classes and a new class ComponentUrlProvider. I refactored my code. But it is fully working. Does anyone have documentation or code example for custom tag in Struts 2.3.24? Thanks, Lynn -Original Message- From: Lukasz Lenart [mailto:lukaszlen...@apache.org] Sent: Tuesday, June 30, 2015 1:32 AM To: Struts Users Mailing List Subject: Re: Need documentation or code example for custom tag in Struts 2.3.24 2015-06-30 3:50 GMT+02:00 Lynn Li lynn...@gm.com: I am upgrading Struts from 2.1.6 to 2.3.24. My application has a custom URL tag. I need help on refactoring custom URL tag code. Does anyone have documentation or code example for custom tag in Struts 2.3.24? Thank you in advance! but it should work as is, do you have a problem with that? Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org Nothing in this message is intended to constitute an electronic signature unless a specific statement to the contrary is included in this message. Confidentiality Note: This message is intended only for the person or entity to which it is addressed. It may contain confidential and/or privileged material. Any review, transmission, dissemination or other use, or taking of any action in reliance upon this message by persons or entities other than the intended recipient is prohibited and may be unlawful. If you received this message in error, please contact the sender and delete it from your computer.
Need documentation or code example for custom tag in Struts 2.3.24
I am upgrading Struts from 2.1.6 to 2.3.24. My application has a custom URL tag. I need help on refactoring custom URL tag code. Does anyone have documentation or code example for custom tag in Struts 2.3.24? Thank you in advance! Nothing in this message is intended to constitute an electronic signature unless a specific statement to the contrary is included in this message. Confidentiality Note: This message is intended only for the person or entity to which it is addressed. It may contain confidential and/or privileged material. Any review, transmission, dissemination or other use, or taking of any action in reliance upon this message by persons or entities other than the intended recipient is prohibited and may be unlawful. If you received this message in error, please contact the sender and delete it from your computer.
Re: How to compare string reference variables using ognl?
In OGNL, the == test will call the equals method, so, I believe the expression #selectedOffer==#queryString should work. Read the following document: http://commons.apache.org/ognl/language-guide.html In the sector [Operators], there is a table describe all the operators. If you think the test result is not correct, you need print out the variables, to check what value they really are. 2011/12/12 mohan rao mohanara...@gmail.com: s:set var=selectedOffer value=%{ecOffers.dicountKey}/ s:iterator var =entry value = #session.discountOffers s:set var=queryString value=%{#entry.key}/ s:property value=selectedOffer.equals(queryString)/ It supposed to print true or false. But not printing any value s:property value='#selectedOffer==#queryString'/ Printing false even they are same. (I think it's checking reference.) -- View this message in context: http://struts.1045723.n5.nabble.com/How-to-compare-string-reference-variables-using-ognl-tp5060783p5067525.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Dynamically setting the template directory in an Action
My suggestion: You can create a file(or folder) link on your file system. From the view of your web app, it works like a file(or folder) inside the [document root directory], but the real file(or folder) is actually somewhere outside the [document root directory]. 2011/12/8 Gurcharan Singh gurcharan.sa...@gmail.com: In the same line, I've a question - How to setup Struts2 to use templates which are located outside document root directory. Why we want to do it - We want to keep UI and Dev work separate and in-case any change is made in the template, we shouldn't be re-building the whole app. Thanks Gurcharan - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: struts2 string to map conversion
What is your client side code (JSP)? In OGNL expression, a value assignment is something like: aMap[aKey] = aValue So, you need create HTML code like: input name=aMap[aKey] value=aValue / On the server side, the OGNL expression will be converted into Java method invoking like: yourAction.getAMap().put(aKey, aValue) Unfortunately, the Java generic system don't know the element data type of your Map, so, the data type for [aKey] and [aValue] may be a problem. I suggest you just declare the map as MapString, String, and do the conversion by yourself. All I talked above are not tested, just suggestion. You need do the test and check if it is correct. 2011/12/6 cwalet cwal110...@gmail.com: any body knows how to use Struts2 TypeConversion(in xwork libs) to convert a parameter string to a hashmap object? I tried this: @TypeConversion(key = phone, rule = ConversionRule.MAP, converter = java.lang.String) public void setHmss(HashMapString, Object hmso) { this.hmso = hmso; } but no convert had it done.how?any suggestion? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Dynamically setting the template directory in an Action
I mean: If the OS is unix/linux, you can create file link (or folder link) on the file system. This doc describes more details: http://www.cyberciti.biz/faq/creating-hard-links-with-ln-command/ 2011/12/13 Gurcharan Singh gurcha...@rachna.co.in: Hi Li Sorry, not able to understand your point. Can you kindly elaborate. Thanks! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: struts2 annotation
I did some search, found it here: com.opensymphony.xwork2.conversion.impl.XWorkConverter.addConverterMapping(MapString, Object, Class) And this converter is configured in [struts-default.xml]: http://struts.apache.org/2.x/docs/struts-defaultxml.html The following doc describe more details: http://struts.apache.org/2.x/docs/type-conversion.html 2011/12/1 cwalet cwal110...@gmail.com: hi,all do struts2.2.3 supports com.opensymphony.xwork2.conversion.annotations.TypeConversion annotation? i've search the source in both xwork and struts,but not anything did i found how struts2 resolve the @TypeConversion and @Conversion annotation. any help would be great! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Customizing validation
Looks like you want some pre-condition check before the validation. If and only if the pre-condition is true, the validation will be executed. I did the same thing several years ago. There are 2 solution I tried: (A)Inherit all the struts2 bundled validators, add some pre-condition check code, if and only if the pre-condition is true, invoke the method of the base class. The base class (struts2 bundled validators) will do the left work. BTW, the pre-condition should be passed into the validators via param, so the validators will not include any business logic and they can be reused. And since your pre-condition is a session attribute, I think you can check it's value by OGNL expression. I am not very sure for this. If you can not access session attribute via OGNL, maybe you need a [getCountry] method in your action class, so the OGNL can retrieve the value. You don't need reinvent the whole wheels, but extend the existed wheels. Source code like: public class XXXValidatorEx extends XXXValidator { private String condition; // here is the pre-condition in OGNL public getCondition(); // omitted public setCondition(); // omitted private boolean evaluateCondition(){ // omitted // you can read the code of [ExpressionValidator] and [FieldValidatorSupport], to learn how to evaluate an OGNL expression. } public void validate(Object object) { boolean result = this.evaluateCondition(); if (result ) { super.validate(object); } } } There are about one dozen bundled validators, and the source code of the inherited validators will be almost 100% same (only except the class name and the base class name). This will be a little ugly, but we have no choice, because Java don't support multi-inherit or interface-delegation. My choice was, generating all these source codes via FreeMarker, so I need maintenance only one template file, but not one dozen of class source codes. (B)The other solution is much lighter. No need the enhance the validator class, but express your pre-condition and your validation rule all by expression. like: validator type=expression param name=expression(!pre-condition) or (check-rule)/param /validator This will be easy to do, but hard to use, because you must translate all the validation rules into some OGNL expression Anyway, I think the final and most beautiful solution should be, adding some [pre-condition checking] into the Struts2 bundled validators themselves. But this is out of our control, hope the developers of Struts2 can here this. 2011/11/28 Jyothrilinga Rao jyoth...@gmail.com: Thanks Li Ying, I got some information from http://today.java.net/pub/a/today/2006/01/19/webwork-validation.html?page=3#custom-validators but I do not want to reinvent the wheel (basically avoid coding my validation logic in java code). If I could have my actionClass-validation.xml structured as validators *country name=USA * !-- Field Validators for email field -- field name=email field-validator type=required short-circuit=true messageYou must enter a value for email./message /field-validator field-validator type=email short-circuit=true messageNot a valid e-mail./message /field-validator /field !-- Plain Validator 1 -- validator type=expression param name=expressionemail.equals(email2)/param messageEmail not the same as email2/message /validator */country* *country name=AUSTRIA * !-- Field Validators for email2 field -- field name=email2 field-validator type=email messageNot a valid e-mail2./message /field-validator /field !-- Plain Validator 2 -- validator type=expression short-circuit=true param name=expressionemail.startsWith('mark')/param messageEmail does not start with mark/message /validator */country* /validators I am looking for something like a wrapper on existing bundled validators. Is it possible. Regards, JK. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Customizing validation
Changing the [validation interceptor] will switch on/off the all validations by one pre-condition. But what he need is: if and only if pre-condition-A is true, run validation-A; if and only if pre-condition-B is true, run validation-B; etc... So, I think the right way is, change the validators. 2011/11/29 Dave Newton davelnew...@gmail.com: If the goal is to execute validations based on arbitrary preconditions (I missed the original req) the *easiest* thing to do might be to just extend/usurp the existing validation interceptor to do that precondition check. d. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Please explain
This doc explains it. http://struts.apache.org/2.x/docs/interceptors.html#Interceptors-MethodFiltering 2011/11/29 Srineel Mazumdar smaz19...@gmail.com: Hi, Please explain the meaning of the following : param name=excludeMethodsinput,back,cancel,browse/param - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Customizing validation
Yes, of course you are right. But what you talking about sounds like to change S2 mechanism itself, which we can not do. As a S2 user but not a S2 developer, the simplest way is to write a new validator.. Of course, If the [pre-condition based validation] is a common request, I think it will be great if we post it to the S2 feature request list. 2011/11/29 Dave Newton davelnew...@gmail.com: If the need is across the application, then modifying the app-wide interceptor makes sense. App-wide rule-based validations require something higher-level than reworking existing validators, or writing new ones, to express something that is likely declarative in nature. Seems more like run this bunch of validations based on this condition--rather than simply look up validations based on the action name, lookup should be based on the condition(s). That's mechanism-level, not validate-level. d. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: getText returns NULL when formating number using l10n
If you want a definitive solution, i suggest you create a new method like: getTextEx(.) in your action, in this method, you can check the parameters, if they are null, change them to empty string, and then invoke the original getText method. you can put this method in the base class of your actions, so you can use it in all the actions. 2011/11/23 Felipe Issa felipe.i...@simova.com.br: It's not a definitive solution, but it works. Thanks Li Ying! Em 21/11/2011 23:07, Li Ying escreveu: or you can do the null check in the jsp code, before you create the param list for the format string. Code like: s:textfield key=orderItem.price value=%{getText('format.number',{orderItem.price == null ? : orderItem.price})} / 2011/11/22 Felipe Issafelipe.i...@simova.com.br: Hi. I'm trying to internationalize my application, and for that i need to use the struts l10n. I have managed to parse the number according to the user locale, but I'm having some troubles to display the number using the user locale. On Struts 2 documentation it says: to input a number, one might have noticed that the number is always shown in the Java default number format. Not only that this is not nice, if you are in a non-en locale, it will also cause trouble when submitting the form since type conversion is locale aware. The solution is to again use the message formats as defined above, by using the getText Method of ActionSupport: s:textfield key=orderItem.price value=%{getText('format.number',{orderItem.price})} / This maps to the method signature getText( String key, Object[] params ) in ActionSupport. (http://struts.apache.org/2.x/docs/formatting-dates-and-numbers.html) It display the number in the correct format when i use the value like this, but when the value is null it shows null instead of a empty textfield. Does anyone know how to fix it? Thanks in advice! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: multiple header in struts2 select tag
The error message is optGroupInternalListUiBean.parameters is undefined I had a quick look at the source of Struts2 and tag template, In [template/simple/optgroup.ftl]: line 23: #if parameters.optGroupInternalListUiBeanList??line 24: #assign optGroupInternalListUiBeans=parameters.optGroupInternalListUiBeanList /line 25: #list optGroupInternalListUiBeans as optGroupInternalListUiBeanline 26: optgroup line 27: #if optGroupInternalListUiBean.parameters.label?? error occurred in line 27, and the [optGroupInternalListUiBean] should be an instance of org.apache.struts2.components.ListUIBean,which inherit from org.apache.struts2.components.Component,and the method [getParameters] of [Component] should return a map, which should be never null.So, I think this error should not occur. The source version I have read is [struts2-core-2.2.3.jar],maybe you need upgrade to the latest version,and see if the error happen. 2011/11/8 Jyothrilinga Rao jyoth...@gmail.com: Thank you Dave. I used the optgroup and got a unexpected error. Was using jars struts-core-2.0.14.jar and xwork-2.0.7.jar. Maybe updating the jars would help or any more info? Regards, JK On Mon, Nov 7, 2011 at 9:37 AM, Dave Newton davelnew...@gmail.com wrote: Normally you'd do this through an s:optgroup tag [1]. If you need functionality beyond the defaults, you'd need to roll your own tag, or consider the optgroup approach. Dave [1] http://struts.apache.org/2.x/docs/optgroup.html On Mon, Nov 7, 2011 at 12:32 PM, Jyothrilinga Rao jyoth...@gmail.com wrote: Hi, I am showing a list of files in the drop down and want to show two more options as follows option value=none selected=selectedselect one/option option value=ALL ALL /option In Struts1, we could have html:option within the html:select tag. In Struts2, I tried to use the headerKey headerValue attribute of s:select, but can only add one (select one). Is there any way I can specify a list for headers instead of manually adding it to my list in the action. My current code snippet: s:select cssClass=*InputText* name=*selectedFileNameCrDt* list=* fileNameList* listValue=*itemLabel* listKey=*itemValue *headerKey=* none* headerValue=*select one*/ Regards, JK - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: multiple header in struts2 select tag
Sorry, the format of my email broken again. Send it again. The error message is optGroupInternalListUiBean.parameters is undefined I had a quick look at the source of Struts2 and tag template, In [template/simple/optgroup.ftl]: line 23: #if parameters.optGroupInternalListUiBeanList?? line 24: #assign optGroupInternalListUiBeans=parameters.optGroupInternalListUiBeanList / line 25: #list optGroupInternalListUiBeans as optGroupInternalListUiBean line 26: optgroup line 27:#if optGroupInternalListUiBean.parameters.label?? error occurred in line 27, and the [optGroupInternalListUiBean] should be an instance of org.apache.struts2.components.ListUIBean, which inherit from org.apache.struts2.components.Component, and the method [getParameters] of [Component] should return a map, which should be never null. So, I think this error should not occur. The source version I have read is [struts2-core-2.2.3.jar], maybe you need upgrade to the latest version, and see if the error happen. 2011/11/28 Li Ying liying.cn.2...@gmail.com: The error message is optGroupInternalListUiBean.parameters is undefined I had a quick look at the source of Struts2 and tag template, In [template/simple/optgroup.ftl]: line 23: #if parameters.optGroupInternalListUiBeanList??line 24: #assign optGroupInternalListUiBeans=parameters.optGroupInternalListUiBeanList /line 25: #list optGroupInternalListUiBeans as optGroupInternalListUiBeanline 26: optgroup line 27: #if optGroupInternalListUiBean.parameters.label?? error occurred in line 27, and the [optGroupInternalListUiBean] should be an instance of org.apache.struts2.components.ListUIBean,which inherit from org.apache.struts2.components.Component,and the method [getParameters] of [Component] should return a map, which should be never null.So, I think this error should not occur. The source version I have read is [struts2-core-2.2.3.jar],maybe you need upgrade to the latest version,and see if the error happen. 2011/11/8 Jyothrilinga Rao jyoth...@gmail.com: Thank you Dave. I used the optgroup and got a unexpected error. Was using jars struts-core-2.0.14.jar and xwork-2.0.7.jar. Maybe updating the jars would help or any more info? Regards, JK On Mon, Nov 7, 2011 at 9:37 AM, Dave Newton davelnew...@gmail.com wrote: Normally you'd do this through an s:optgroup tag [1]. If you need functionality beyond the defaults, you'd need to roll your own tag, or consider the optgroup approach. Dave [1] http://struts.apache.org/2.x/docs/optgroup.html On Mon, Nov 7, 2011 at 12:32 PM, Jyothrilinga Rao jyoth...@gmail.com wrote: Hi, I am showing a list of files in the drop down and want to show two more options as follows option value=none selected=selectedselect one/option option value=ALL ALL /option In Struts1, we could have html:option within the html:select tag. In Struts2, I tried to use the headerKey headerValue attribute of s:select, but can only add one (select one). Is there any way I can specify a list for headers instead of manually adding it to my list in the action. My current code snippet: s:select cssClass=*InputText* name=*selectedFileNameCrDt* list=* fileNameList* listValue=*itemLabel* listKey=*itemValue *headerKey=* none* headerValue=*select one*/ Regards, JK - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Customizing validation
If your validate rules are fixed, only some parameters (integer/date format or something else) relies on the country setting, I suggest you implement it by retrieve the params via OGNL expression. The parameter for the Validators can be OGNL expression. These docs may help: http://struts.apache.org/2.x/docs/ognl.html http://commons.apache.org/ognl/language-guide.html If your validate rules are variable, you can implement your own Validator, and register it into struts2. Then, you can use it in the same way as you use the Bundled Validators. This documents may help: http://struts.apache.org/2.x/docs/validation.html#Validation-RegisteringValidators To learn how to write a validator, you can read the source code of Struts2/xWork, in package [com.opensymphony.xwork2.validator.validators] And you can find some samples via google. 2011/11/28 Jyothrilinga Rao jyoth...@gmail.com: Hi all, I am currently making use of the validator and able to work-out a example as discussed at http://struts.apache.org/2.x/docs/validation.html. My application has a concept of user's country which is stored in session. Now depending on the value of this attribute stored in session, I need to have different validation rules for the same form and action. I would still like to define validations outside of my action and JSP in a XML file. Is there something out of box provided which can fulfill my requirement ? or is there something I can extend on to fulfill this ? Thanks, JK. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: getText returns NULL when formating number using l10n
I have read the source of java.text.MessageFormat, looks like it output a null text to the result String when the argument is null. I think you can create a read-only property in your action (or your data model class), and implement the null check and format process in this property, code like: public String getPriceDisplay(String formatPattern) { if (this.price == null) { return } else { format it by the formatPattern } } and use this property in the jsp tag, code like: s:textfield key=orderItem.price value=%{orderItem.getPriceDisplay(getText('format.number'))} / 2011/11/22 Felipe Issa felipe.i...@simova.com.br: Hi. I'm trying to internationalize my application, and for that i need to use the struts l10n. I have managed to parse the number according to the user locale, but I'm having some troubles to display the number using the user locale. On Struts 2 documentation it says: to input a number, one might have noticed that the number is always shown in the Java default number format. Not only that this is not nice, if you are in a non-en locale, it will also cause trouble when submitting the form since type conversion is locale aware. The solution is to again use the message formats as defined above, by using the getText Method of ActionSupport: s:textfield key=orderItem.price value=%{getText('format.number',{orderItem.price})} / This maps to the method signature getText( String key, Object[] params ) in ActionSupport. (http://struts.apache.org/2.x/docs/formatting-dates-and-numbers.html) It display the number in the correct format when i use the value like this, but when the value is null it shows null instead of a empty textfield. Does anyone know how to fix it? Thanks in advice! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: getText returns NULL when formating number using l10n
or you can do the null check in the jsp code, before you create the param list for the format string. Code like: s:textfield key=orderItem.price value=%{getText('format.number',{orderItem.price == null ? : orderItem.price})} / 2011/11/22 Felipe Issa felipe.i...@simova.com.br: Hi. I'm trying to internationalize my application, and for that i need to use the struts l10n. I have managed to parse the number according to the user locale, but I'm having some troubles to display the number using the user locale. On Struts 2 documentation it says: to input a number, one might have noticed that the number is always shown in the Java default number format. Not only that this is not nice, if you are in a non-en locale, it will also cause trouble when submitting the form since type conversion is locale aware. The solution is to again use the message formats as defined above, by using the getText Method of ActionSupport: s:textfield key=orderItem.price value=%{getText('format.number',{orderItem.price})} / This maps to the method signature getText( String key, Object[] params ) in ActionSupport. (http://struts.apache.org/2.x/docs/formatting-dates-and-numbers.html) It display the number in the correct format when i use the value like this, but when the value is null it shows null instead of a empty textfield. Does anyone know how to fix it? Thanks in advice! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: method's namespace
This document may help: http://struts.apache.org/2.x/docs/convention-plugin.html#ConventionPlugin-Actionannotation 2011/11/21 叶伟平 weiwei5...@gmail.com: Dear All, I have a action class which's namespace is /(Annotation), and, I want to use another namespace for a method within the class. How to do that? Thanks Regards. Weiping Ye - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts Conventional plugin is not working, Not calling invoking my Action but page is displaying
Do you want to map your action to the following url? namespace: common action: homepage But your package configuration is: package name=mypackage extends=struts-default namespace=/ I think maybe this setting maps all the actions in this package to namespace /, but not common as you want. Read the following documents, may help: http://struts.apache.org/2.x/docs/package-configuration.html and http://struts.apache.org/2.x/docs/namespace-configuration.html 2011/11/13 srikanth sreekanth.n...@egovernments.org: struts.xml is like ?xml version=1.0 encoding=UTF-8 ? !DOCTYPE struts PUBLIC -//Apache Software Foundation//DTD Struts Configuration 2.0//EN http://struts.apache.org/dtds/struts-2.1.7.dtd; struts constant name=struts.devMode value=true / constant name=struts.configuration.xml.reload value=true/ constant name=struts.convention.action.packages value=my.struts2.example.web.actions / constant name=struts.custom.i18n.resources value=custom / constant name=struts.i18n.reload value=false / constant name=struts.locale value=en_IN / constant name=struts.multipart.maxSize value=10485760 / constant name=struts.multipart.parser value=jakarta/ package name=mypackage extends=struts-default namespace=/ ... /package /struts web.xml is like web-app xmlns=http://java.sun.com/xml/ns/javaee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd; version=2.5 . filter filter-namestruts2/filter-name filter-classorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter/filter-class /filter filter-mapping filter-namestruts2/filter-name url-pattern*.action/url-pattern /filter-mapping ... /web-app Project structure is like -XYZ.ear| |--xyz.war | |--lib| |- xyz.jar |- struts2-core-2.2.3.1.jar |- struts2-convention-plugin-2.2.3.1.jar |- xwork-core-2.2.3.1.jar |- freemarker-2.3.16.jar | etc (all jars required for struts2) xyz.jar is containing my struts.xml file xyz.jar contains my Action class as follows. my.struts2.example.web.actions.common //java imports.. @ParentPackage(mypackage) public class HomepageAction extends ActionSupport { public String execute() { return SUCCESS; } } xyz.war contains my jsp for HomepageAction like as follows ...WEB-INF/content/common/homepage.jsp With this my server is starting successfully and deployed as expected but when i request URL like http://localhost:8080/xyz/common/homepage.action Its not going to the HomepageAction execute method but the page is displaying thanks - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Dynamically setting the template directory in an Action
(1)I believe the word [template] in struts2 means, the template file to render a struts2 tag. for example, the file [struts2-core-2.2.3.jar]/template/xhtml/form.ftl is a template file to render the tag s:form using theme xhtml (2)what you are trying to do, is to change the jsp file location which will be used to render the action result. This is different to the [template]. maybe you can use [Parameters in action result definitions], described by the following document: http://struts.apache.org/2.x/docs/parameters-in-configuration-results.html 2011/11/11 Chris Rijk chrisr...@gmail.com: Hi all, Referring to this page: http://struts.apache.org/2.2.1/docs/selecting-template-directory.html It says the template directory can be specified in the session, for example to allow the user to change it on a per-session basis. I've been trying to do this for my application, but can't get it to work. I'm using the conventions library. If I copy WEB-INF/content to WEB-INF/content2 I can add a tag like @ResultPath(value=/WEB-INF/content2/) to an Action to change the template directory used to render the results, and this works as expected. However, that works on a per action/class basis, and I want to do it on a per session basis. I've tried setting templateDir in the session but this has no effect. Any ideas? For example, I've tried this in an action implementing the ServletRequestAware interface: public void setServletRequest(HttpServletRequest arg0) { HttpSession sess = arg0.getSession(true); sess.setAttribute(templateDir, /WEB-INF/content2/); } I also tried implementing SessionAware, eg: public void setSession(MapString, Object session) { session.put(templateDir, /WEB-INF/content2/); } - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Message lookup (from key) in Test
Hi Miguel: How did you generate the error message? (A)Did you add the message key to the action errors, like: this.addActionError(error.authorisation); (B)or did you retrieve the message text by the key, then add the text to the action errors, like: this.addActionError(this.getText(error.authorisation)); Method (B) is correct, (A) is not. 2011/11/16 Miguel Almeida mig...@almeida.at: Dear all, I am unit-testing an application under the skin using SpringStrutsTestCase as base (actually, things are a bit more complicated because I'm doing it from Cucumber, but that's another story). How do you get the value of your message from within the test? The assertion I'm trying is: assertEquals(expectedMessage, action.getActionErrors().iterator().next()); But actionErrors() contains the key (error.authorisation) and not the value (you cannot do this). What's the cleanest way to retrieve the value from the test? Cheers, Miguel Almeida - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Right way for exception handling
Hi, Ilya: But struts-2 breaks this scheme. 1) it does not pass exception to container so container can't log it. I used struts2 for several years. In our projects, struts-2 does not break this schema. I have read the source of struts2. When an exception is thrown from action execution, struts2 will catch it, and (1)set 500 error to the response code (2)put the exception instance into request attribute [javax.servlet.error.exception] and [javax.servlet.jsp.jspException] source code like this: package org.apache.struts2.dispatcher; class: Dispatcher // WW-1977: Only put errors in the request when code is a 500 error if (code == HttpServletResponse.SC_INTERNAL_SERVER_ERROR) { // send a http error response to use the servlet defined error handler // make the exception availible to the web.xml defined error page request.setAttribute(javax.servlet.error.exception, e); // for compatibility request.setAttribute(javax.servlet.jsp.jspException, e); } // send the error response response.sendError(code, e.getMessage()); you can handle exception by: (1)add this setting into web.xml: error-page exception-typejava.lang.Exception/exception-type location/some_path/errorException.jsp/location /error-page (2)create a errorException.jsp 2011/11/12 Ilya Kazakevich ilya.kazakev...@jetbrains.com: Hello, In bare container (tomcat) everything is good: Servlet throws exception and container logs it and displays 500 error page with certain status. Each uncounght exception should lead to 500 error because uncought exception is _program_ error. But struts-2 breaks this scheme. 1) it does not pass exception to container so container can't log it. 2) even if I use exception interceptor (ExceptionMappingInterceptor) struts does not set 500 error code to my result. So I have to set it in my JSP (or servlet) manually. I can't use static 500 error page as I did in tomcat. So, my questions are: 1) Why do not struts passes exception to container by default? Could I configure it to do so? 2) If struts can't do it -- how can I make it to send 500 status for my exception? I do not want to configure my jsp 3) Who really needs exeption handling in struts? Somebody wants user to be redirected to different actions based on exception type? What for? Smells like exception-based business logic moved from java to struts.xml and does not look like good practice. I need to write a lot just to get back to default container behavior (500 status and logging): 1) Create _new_ stack to set logEnabled and logLevel 2) Configure package to use it 3) Add global error result 4) Add global exception handling 5) Create JSP with status 500 instead of my 500.html page Is not it too big for such simple task? Ilya Kazakevich, Developer JetBrains Inc http://www.jetbrains.com Develop with pleasure! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [S2] Displaying user entered values after failed type conversion while using getText()?
I have 2 suggestion: (A)Declare the input data field in your action as a String, instead of date or integer. So, the String field can hold anything input from client side. But this will be inconvenience to use, because you have to convert the string value to the date or integer value by yourself, before you can use it. Another solution is: (B)Declare 2 fields in your action. One as date or integer, to hold the type converted valid value. Another as String, to hold the original input text. On the input page side, you also need 2 form elements. One is input, which will send data to the [real value] field, and another is hidden, which will send data to the [original input text] field. User can only see the input, and input data in it. you can create some JS code, to copy the input content to the hidden element, before the form be posted. When the type conversion fails, and the input page displayed again, the hidden element will contains the original input text, and the input element will contains empty text. You can create some JS code, to copy the hidden element content to the input element, after the page loaded. Or, you can simply set the value of the input element from the [original input text] field of Action. Hope this helps. 2011/11/17 Burton Rhodes burtonrho...@gmail.com: I am having an issue with displaying the original value entered on a form after failed type conversion. This bug is caused by my use of getText() in the form value fields. I'm curious how one solves this issue for making sure the field is formatted correctly upon display, but also making sure the users see the orignal malformed entry after failed type conversion. I have a few examples below. The last one displays works the way it should. The top two only present an empty field upon failed type conversion. [code snippets] !-- convert to java.util.Date: Will NOT display the incorrectly entered date -- s:textfield key=xaction.closedDate value=%{getText('format.dateShort',{xaction.closedDate != null ? xaction.closedDate :''})} / !-- convert to BigDecimal: Will NOT display the incorrectly entered number -- s:textfield key=xaction.listPrice value=%{getText('format.money',{xaction.listPrice != null ? xaction.listPrice :''})}/ !-- convert to Integer: Will display the incorrect value -- s:textfield key=xaction.beds / - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2 Initialization Plugin
I think lazy initialization is a simple choice, because it is not dependent on the J2EE container, this make your code easy to test. If you worry about duplicated-initialization triggered by multi request, the simple solution is, make your initialization code [synchronized], using reserved word [synchronized] of Java language. However, if your initialization process is too heavy, the lazy initialization mode will make the first access slow. If you care about this problem, the [ServletContextListener] and [initialization servlet] is a better choice. As Eric and Chris said, they can be good entry point to call your initialization process. I suggest: (1)implement your initialization process as a util-class or something, so you can do unit test, out of the J2EE context. (2)call the initialization process from [ServletContextListener], or [initialization servlet], or some lazy initialize code as you want. The basic principle is: (1)implement the real business logic in an independent mode (2)create some adapter code, to connect your business logic and your run time context 2011/11/11 Scott Smith ssm...@mainstreamdata.com: In struts 1, I used org.apache.struts.action.PlugIn as a way to create an object at web app startup and put it into the application context so that all sessions had access to it. What's the equivalent method in Struts2? That is, how can I have an object created at web application startup. I guess the alternative is lazy initialization (first guy who tries to access it and doesn't find it, creates it, and saves it into the app context; down side is I might end up with several sessions trying to create it until one finally makes it to the app context). Any better solutions? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: s:text encoding issue
I tried the JSP code which you posted. It works fine. What is your [locale]? you said, you [select Arabic], do you mean [locale] is [Arabic]? What name is your property file, and what is the content in it? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: How to use tabbed panels with s:form
JQuery UI can help you. Here is the home page: http://jqueryui.com/ Here is the tab ui demo: http://jqueryui.com/demos/tabs/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Unsubscribe from the group
Read the [ Unsubscribe ] section of this page: http://struts.apache.org/mail.html I believe you can do it by yourself. 2011/10/17 ashok ramasankar ramsankar.as...@gmail.com: Hi, Please unsubscribe my mail id from the user group - user@struts.apache.org Please do the needful. Thanks, Ashok - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2 date field problem
Did your problem happens when date input or output? For output case, the s:date tag can let you choose the format to use. See: http://struts.apache.org/2.x/docs/date.html For input case, Struts2 can convert HTTP parameters from String into most of data type you need, include Date. But for Date, it [uses the SHORT format for the Locale associated with the current request] So, if your parameters can not be converted to Date correctly, maybe you need: (1)change your input format (2)or build a new Type Converter to support the format you want. This page describes the details: http://struts.apache.org/2.x/docs/type-conversion.html And, the following code is a DateConverter we used in our project, which support several date formats: = START = import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Map; import org.apache.commons.lang.StringUtils; import org.apache.struts2.util.StrutsTypeConverter; public class DateConverter extends StrutsTypeConverter { private String[] dateFormats = new String[] { /MM/dd HH:mm:ss, /MM/dd }; @Override @SuppressWarnings(rawtypes) public Object convertFromString(final Map context, final String[] values, final Class toClass) { String dateStr = values[0]; if (StringUtils.isEmpty(dateStr)) { return null; } for (String formatStr : dateFormats) { SimpleDateFormat format = new SimpleDateFormat(formatStr); try { return format.parse(dateStr); } catch (ParseException e) { } } throw new RuntimeException(Could not parse date. [ + dateStr + ]); } @Override @SuppressWarnings(rawtypes) public String convertToString(final Map context, final Object o) { return o.toString(); } } = END = 2011/9/29 karthick.gunaseka...@wipro.com: I want to get the struts 2 date field as Date, But it return the string value, My bean property is date data type any way Is there to directly get the date data type from struts 2 date tag - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: slow request/response may be because of validation/conversion
I think conversion and validation should not be turned off. The [conversion] convert http parameters (which is String) to the real data type so your action can accept. The [validation] check the parameters if they a valid. And also, normally, conversion and validation should not take too much time. The log you showed to us start at 2011-10-10 10:55:42,187 and finished at 2011-10-10 10:55:42,393 So, it only cost 200 ms. I think you need printout more debug info, and find out where is the real bottle neck. And, as Carl said, the setting of [struts.devMode] can make Struts2 slow. [it has a significant impact on performance, since the entire configuration will be reloaded on every request] Try turn it off and see what happens. This page may help: http://struts.apache.org/2.x/docs/devmode.html - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: s:submit onclick=return false still call the action in IE 9!
This page may help: http://www.ontola.com/en/javascript-onclick-return-false-does-not-work-in-i - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Accessing variable in View [S 1.3.8]
I took a quick look at Struts1 document. Looks like the following information can help: http://struts.apache.org/1.x/struts-taglib/tagreference.html#html:link = START = To specify a single parameter, use the paramId attribute to define the name of the request parameter to be submitted. To specify the corresponding value, use one of the following approaches: Specify only the paramName attribute - The named JSP bean (optionally scoped by the value of the paramScope attribute) must identify a value that can be converted to a String. Specify both the paramName and paramProperty attributes - The specified property getter method will be called on the JSP bean identified by the paramName (and optional paramScope) attributes, in order to select a value that can be converted to a String. If you prefer to specify a java.util.Map that contains all of the request parameters to be added to the hyperlink, use one of the following techniques: Specify only the name attribute - The named JSP bean (optionally scoped by the value of the scope attribute) must identify a java.util.Map containing the parameters. Specify both name and property attributes - The specified property getter method will be called on the bean identified by the name (and optional scope) attributes, in order to return the java.util.Map containing the parameters. As the Map is processed, the keys are assumed to be the names of query parameters to be appended to the hyperlink. The value associated with each key must be either a String or a String array representing the parameter value(s), or an object whose toString() method will be called. If a String array is specified, more than one value for the same query parameter name will be created. = END = 2011/10/4 Anjib Mulepati anji...@hotmail.com: Hi All, I was wondering is there any way to read and store value of beans in JSP using Struts 1.3.8. I need this to pass the parameter as follow. logic:iterate id=group name=groupList tr class=gradeA id='bean:write name=group property=groupId /' td style=text-align: centerinput type=checkbox value=ON name=del //td tdhtml:link action=/getGroupDetail?id=*I need to get group id here*bean:write name=group property=groupName //html:link /td /tr /logic:iterate Thanks, Anjib - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Unicode Encoding request parameters
You don't need an extra-filter. The S2 default encoding is UTF-8. The code of S2 filter is: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter: public void doFilter(..) { .. prepare.setEncodingAndLocale(request, response); .. } and the code of PrepareOperations is : org.apache.struts2.dispatcher.ng.PrepareOperations public void setEncodingAndLocale(HttpServletRequest request, HttpServletResponse response) { dispatcher.prepare(request, response); } and the code of Dispatcher is: org.apache.struts2.dispatcher.Dispatcher public void prepare(HttpServletRequest request, HttpServletResponse response) { String encoding = null; if (defaultEncoding != null) { encoding = defaultEncoding; } .. if (encoding != null) { try { request.setCharacterEncoding(encoding); } catch (Exception e) { LOG.error(Error setting character encoding to ' + encoding + ' - ignoring., e); } } .. } and the code of property [defaultEncoding] is: @Inject(StrutsConstants.STRUTS_I18N_ENCODING) public void setDefaultEncoding(String val) { defaultEncoding = val; } the value of [defaultEncoding] will be injected by the property [StrutsConstants.STRUTS_I18N_ENCODING] which is struts.i18n.encoding. And this property is defined in [struts-default.properties], which's value is [UTF-8]: struts.i18n.encoding=UTF-8 You can read the following S2 documents: http://struts.apache.org/2.x/docs/strutsproperties.html If you want to change the default encoding, you can change the value of property [struts.i18n.encoding]. By the way. This encoding setting only works for the POST params (which are part of the form element). For the GET params(which are part of URL), the encoding can not be set in J2EE context. It will be parsed by the J2EE container (e.g: Tomcat) BEFORE your code is executed. In this case, the solution are: (1)do not use non-ascii chars in URL params or (2)change the Tomcat setting about url param encoding: [URIEncoding]. It is descriped in this document: http://tomcat.apache.org/tomcat-6.0-doc/config/http.html 2011/9/20 Zoran Avtarovski zo...@sparecreative.com: We have a struts2 multilingual web app that requires request parameters be encoded as Unicode (UTF-8). In order to get the POST parameters to work we had to implement a character encoding filter to encode all HTML parameters as UTF-8. I'd like to know if it's possible to do the encoding via S2 and avoid the use of another filter. We'e set the struts.i18n.encoding property to UTF-8 and I don't know what else to do. As always I'd appreciate any suggestions you guys might have. Z. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Is it possible to redirect after a Stream result action has completed?
I guess you can not do this. Because there should be ONLY ONE HTTP response for every HTTP request. So you can only return a file downlod or a redirect to the client, but not both. If you want to jump to another page after file download, may be you can try JavaScript solution in the client side. AJAX and JavaScript is very powerful today, If you can't implement something in the server side, maybe there are another solution in the client side. 2011/9/19 roger roger.var...@googlemail.com: Hi I have a .jsp page that contains a link. When the link is clicked an action is called that uses the stream result to download a data file to the client pc. When the action is complete and all the browser generated download dialogs have been cleared, the original .jsp that contains the download link is still displayed. I would like to be able to redirect to another page once the download has completed. Is this possible and if so pointers as to how I go about it would be welcome. Regards -- View this message in context: http://struts.1045723.n5.nabble.com/Is-it-possible-to-redirect-after-a-Stream-result-action-has-completed-tp4819005p4819005.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: S2 Action Setter Not Called
the problem is that you pushed a HashMap on the ValueStack's root. if you do that, all the values will be populated to the HashMap, not your action class you can try this code to fix it. ActionContext.getContext().put(browser, userSession.getBrowser()); (2011/02/04 17:12), Rubens Gomes wrote: Okay. I found what is causing the setters not to be called. I have an interceptor called ValueStackInterceptor (which is called prior to ParametersInterceptors) that is placing a String variable browser on the stack (please, see code below). If I comment out the line that places this variable on the stack (see below) everything works fine. I am showing the Interceptor and the line of code that is causing a problem. Can someone please help me understand what is the problem with this code? - package com.softlagos.web.struts2.interceptor; import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.apache.commons.lang.xwork.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts2.ServletActionContext; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.interceptor.AbstractInterceptor; import com.softlagos.web.common.UserSession; import com.softlagos.web.common.WebAppUtils; /** * Interceptor object used to initialize the Struts 2 Value Stack with some state information (like the * browser variable) that is needed in the results. * * @author Rubens Gomes * @version $Id: ValueStackInterceptor.java 3754 2011-02-03 00:39:46Z rgomes $ */ public final class ValueStackInterceptor extends AbstractInterceptor { private static final long serialVersionUID = 1; private static final Log logger = LogFactory.getLog(ValueStackInterceptor.class.getName()); public ValueStackInterceptor() { super(); } @Override public String intercept(final ActionInvocation invocation) throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); UserSession userSession = WebAppUtils.getUserSession(request); /* * The DetectUserAgentFilter code should be run prior to Struts 2 filter because that filter * is responsible for setting the browser on the HTTP userSession session object. */ if(userSession==null) throw new IllegalStateException(The userSession was not set.); if(StringUtils.isBlank(userSession.getBrowser())) { String msg = The userSession browser is null, which means that the user agent detection failed. Code cannot proceed at this point.; IllegalStateException ex = new IllegalStateException(msg); logger.error(msg, ex); throw ex; } if(logger.isInfoEnabled()) logger.info(Setting Struts2 value stack browser [ + userSession.getBrowser() + ].); MapString, Object context = new HashMapString, Object(); // browser is used on Result objects to render either a desktop or mobile JSP page. context.put(browser, userSession.getBrowser()); /* THE FOLLOWING LINE IS IMPACTING ON ACTION SETTER NOT TO BE CALLED */ ActionContext.getContext().getValueStack().push(context); /* --- Reverse Path --- */ return invocation.invoke(); } } - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Problem with character encoding during redirect to another action
I think this is not a struts issue. are you using tomcat as your server? you can try to set URIEncoding of Connector to utf-8 in server.xml (2011/01/26 23:45), Rafael Karbowski wrote: Hi @ all, I have a problem with the encoding of German umlauts. In the getter of the source action they are correct, but the setter of the destination action sets bad encoded values. So far I can´t find any solution for this problem. It would be nice, if somebody has an idea how to fix it. For a detailed description see http://stackoverflow.com/questions/4791166/struts-2-parameter-coding-problem-during-redirect-to-another-action Best Regards Rafael - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: html:link prompting me to download the jsp file
What HTML code does your html:link tag render? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Error validating struts-2.0.dtd
May be something getting wrong in Eclipse IDE. Try: (1)Delete the whole project from Eclipse IDE. But NOT delete the project content from the file system (2)Import the project to Eclipse again (3)Clean the project And see if the error get cleared? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Creating Tabs in Struts 2
You can use the tabbedPanel tag, as Maurizio Cucchiara has told you. http://struts.apache.org/2.2.1.1/docs/tabbedpanel.html Or you can use JQuery UI. Here are demos and docs: http://jqueryui.com/demos/tabs/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Calculate module of index in Struts2 iterator
That's just wired. The first idea in my head was, may be there is lacks of brackets in your expression. But then I checked the document of OGNL: http://www.opensymphony.com/ognl/html/LanguageGuide/apa.html Accordinting to this document, the operator [%] has higher precedence than operator [==]. Which means, the original expression without brackets should be same as the expression with brackets. So, I did not talk about the brackets thing. But of cause, it will be much more better to add the brackets. 2010/12/24 JOSE L MARTINEZ-AVIAL jlm...@gmail.com: I had to put the expression between brackets: s:if test=(#fieldNameStatus.index % 10 )==0x/s:if Thanks JL - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: problem mapping values from the jsp to the action
can you show the generated html file? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Calculate module of index in Struts2 iterator
You can put the following debug code in your jsp: s:property value=#fieldNameStatus.index / s:property value=#fieldNameStatus.index % 10 / s:property value=#fieldNameStatus.index % 10 ==0 / It may help you find out what the result of expression is. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2.2.1 and Tag Lib oddities
I think the tag-lib [/struts-tags] is defined in [struts2-core-2.2.1.jar/META-INF/struts-tags.tld]. Can you see this file in your Eclipse, under the [Web App Libraries]? Or, can you see the [Web App Libraries] in the [Java Build Path = Libraries] of your web-app? Or, you can [refresh] your whole app, see if the errors remain. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: cssClass attribute with @s.textfield ignored when inputError happens
I read the source code of [simple/css.ftl], it looks like trying to combine [cssClass] and [cssErrorClass]. So you can try: @s.textfield name=port value=port key=service.port maxsize=5 cssClass=prop-port cssErrorClass=inputError / see if the result is what you want? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: cssClass attribute with @s.textfield ignored when inputError happens
I read the source of [simple/text.ftl], and found nothing looks like rendering the extra [class=inputError] attribute. Can you tell me where it is? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Iterator: field errors.
Since after validation fails the iterator grid also empty I think, you need separate the field names by list index -- since your data model is a list--, to indicate which [textfield] should be captured by which POJO element. And also, you need separate the field name of validation error, to indicate POJO element it belongs. So, i think code should likes: JSP: s:iterator values=myList status=rowStatus s:textfield name=myList[#rowStatus.index].name / s:fielderror name=myList[#rowStatus.index].name / /s:iterator Validation: addFieldError(myList[index].name,getText(error.code)); - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Problem using scriplet object in s:if tag
It don't works, because the JSP local variable is not an OGNL local variable. The JSP local variable will be translated into a local variable of the Servlet code, and it is a local variable of Java language, so you can not reference it in the OGNL expression. An OGNL local variable should be [put into] the value stack of OGNL context, before you can reference it in other OGNL expression. Before you can reference an OGNL local variable, you need define it, using s:set tag (In struts2). See: http://www.opensymphony.com/ognl/html/LanguageGuide/basicSyntax.html and http://www.opensymphony.com/ognl/html/LanguageGuide/varref.html - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Invocation of type conversion manually
I think you don't need this bothering job. You can: (1)Define some properties in your base class of all your action classes. (2)Use these properties to capture data from the request. (3)Run your interceptor AFTER the interceptors of struts2. But BEFORE the execution of the Action class So, The interceptors of struts2 will do the data-conversion for you. Your interceptor can simply extract parameters all you need from the Action instance. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Bad Struts Day s:property/
Try: s:url value='/' + getText('IMAGE') / - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: submit date in textfield with custom date format
Read this doc: http://struts.apache.org/2.2.1/docs/type-conversion.html From [# 3 Creating a Type Converter] to [# 6 Applying a Type Converter for an application] - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: any option parameter for populating parameters to my bean?
Can you show us the entire Exception stack? I guess, this may be a type conversion error. According to this struts2 documents: http://struts.apache.org/2.x/docs/type-conversion.html#TypeConversion-BuiltinTypeConversionSupport XWork will automatically handle the most common type conversion for you. This includes support for converting to and from Strings for each of the following: dates - uses the SHORT format for the Locale associated with the current request So, I think the following things should be checked first: What the Locale associated with the current request is? What the short format of this locale is? Is your input string 2010/12/12 12:00:00 match this short format? The default date converter looks like depends on the Locale associated with the current request. So, the format it takes will vary. If you want this, you need create a new converter which takes a fixed date format. I did this before, it's not difficult, if you following the document. 2010/12/9 maven apache apachemav...@gmail.com: My action: public class MyAction{ private MyBean bean; //getter setter. } public class MyBean{ private Date start; //setter getter } s:form s:textfield name=bean.start / If the value of start is '2010-12-12 12:00:00',the parmameter start can be populated to my bean correctly,however if the format is '2010/12/12 12:00:00',it will show me a error can not parser the date',so I wonder if there is any parameter can be set for populating parameter? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Iterator: field errors.
What is the data type of objectList? How did you execute the validation, and how did you add the field error? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Cancel in a form re: bypass Validation
I think Michal was right. If you don't want execute validation for some Action Method, the annotation @SkipValidation is a good solution. And, in your case, I noticed that, your server side action is doing nothing when the [cancel] button clicked. I suggest you can put a html Link for your [cancel] button, instead of a submit button. So, when it be clicked, browser will jump to the next page, and your form will not be submitted. And of cause, the validation will not be executed. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: RE: RE: Result Type Stream Corrupted
Are the file size different? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Asking about BigDecimal in Struts 2
I hate MS SQL Server~ 2010/12/7 Yanto Bong yantob...@gmail.com: Hi Mead, thanks for the suggestion, but we want to keep the minimum changes on the code. if we convert into string in jsp/view pages, there are quite a lot of changes. however we already change our formatting script in our js library and it solved the issue. also this issue just happend when we connect to SQL Server, it won't happend when we use Oracle DB. Thanks Regards Yanto On Tue, Dec 7, 2010 at 11:07 AM, Mead Lai laiqi...@gmail.com wrote: Hello, 1,convert the munber into string in the jsp/view page. 2,write a JSTL to render that dataType by your self. Regards, Mead On Tue, Dec 7, 2010 at 10:25 AM, Yanto Bong yantob...@gmail.com wrote: Hi Li, thanks...unfortunately we already use this model in many places and we need to have BigDecimal return datetype. However we already solve this issue by changing our java script lib. Thanks On Mon, Dec 6, 2010 at 11:47 AM, Li Ying liying.cn.2...@gmail.com wrote: This looks like the result of toString() of BigDecimal. May be you can try this: http://download.oracle.com/javase/1.5.0/docs/api/java/math/BigDecimal.html#toPlainString%28%29 2010/12/6 Yanto Bong yantob...@gmail.com: Hi All, We've using BigDecimal as datatype in hibernate and model for Numeric (20,8) datatype in database. however when we display it in JSP using struts 2, if the value 0 then it will display correctly. However if the value is 0. in database, then it will display in JSP it will shown as *0E-8.* anyone have this issue before ? Thanks Regards - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: submit date in textfield with custom date format
what is your locale associated with the request? if your locale's date format is defferent from -MM-dd , you have to customize the type conversion to make it work. http://struts.apache.org/2.2.1/docs/type-conversion.html - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Bookmark and session
Do you mean, when user click some bookmark, you want to check if this bookmark belongs to this user? Basically, you can not control bookmark, because it is a browser operation. The only way i can tell is, to add a user id param to all your page url. So, when userA saved a bookmark, and when it clicked by userB, you can check the user id param and detect which user belongs to. If the user param in url is different to the user who is log in, you can redirect to the main page. This solution is a little ugly, and I don't know why you need it. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Problem in calling method from Struts.xml in struts2
It looks like, the latest class files were not deployed to the WebApp Context. Sometimes this happens. When you find something getting wrong, and your source code looks like right, Just try turn off the web app, and re-deployed your latest code again. See if it the error get fixed. Sometimes, this can save your lots of time. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Problem in calling method from Struts.xml in struts2
BTW, according to the exception message: The execute method of UserRegistrationAction IS CALLED, but some code invoked by this method raised an exception. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Asking about BigDecimal in Struts 2
This looks like the result of toString() of BigDecimal. May be you can try this: http://download.oracle.com/javase/1.5.0/docs/api/java/math/BigDecimal.html#toPlainString%28%29 2010/12/6 Yanto Bong yantob...@gmail.com: Hi All, We've using BigDecimal as datatype in hibernate and model for Numeric (20,8) datatype in database. however when we display it in JSP using struts 2, if the value 0 then it will display correctly. However if the value is 0. in database, then it will display in JSP it will shown as *0E-8.* anyone have this issue before ? Thanks Regards - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: any ideas about handle user's relogin using interceptor?
The problem will be: (1)How to save the information about who is logged in from which session. and (2)How to check this information before every action execution For problem 1, if you only have one app server, you can save this information in global variable, if you need support multi app servers, you can save it into DB. The data structure should like MapUserID, SessionID (in global variable) or TABLE (UserID VARCHAR, SessionID VARCHAR) (in DB) For problem 2, you are right, Interceptor will be a good choice. I think the whole architecture should likes: (1)After user login, save the logged in status into global variable or DB, and into current session. (2)Before every action execution, extract logged in user id from current session, and then check the global variable or DB, see if this user is logged in from the same session. If the same user is logged in from some session else, this means he/she has re-logged in from somewhere else, so you can remove the logged in status from current session, and then force the user login again. For example: (1)UserA, logged in from ComputerA. Let's say the session is SessionA. So in SessionA, the logged in user ID will be UserA. And in the global variable or DB, UserA will be marked logged in from SessionA (2)When the same user login from ComputerB. Let's say SessionB. In SessionB, the logged in user ID will be UserA. And in the global variable or DB, the logged in status of UserA will be overwritten by logged in from SessionB (3)Request any page again from ComputerA. The Interceptor can extract the logged in user id (which will be UserA) from current Session (which will be SessionA). And extract the logged in status from global variable or DB, which will be logged in from SessionB, and different from current session. So the Interceptor can say, UserA has re-logged in from some where else. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: any ideas about handle user's relogin using interceptor?
ActionContext is just a wrap class for convenience. If you need the real HttpSession. You should get the HttpRequest first, from ServletActionContext.getRequest(). See: http://struts.apache.org/2.2.1/struts2-core/apidocs/org/apache/struts2/ServletActionContext.html And then, you can get the HttpSession from HttpServletRequest.getSession(); See: http://download.oracle.com/javaee/5/api/javax/servlet/http/HttpServletRequest.html 2010/12/2 maven apache apachemav...@gmail.com: Thanks,your answer can not be detailed more. :) only a little confused. Map attibutes = ActionContext.getContext().getSession() I can get the session this manner,but it seems that it is a Map,not a HttpSession,so what is the id? I have debug the session yet,and I found there is a property in the Map: struts.troken,is this unique can be used as the session id? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Spring 3 Upgrade
I built a web app in this summer, using the latest Struts2.2.1 and the latest Spring3.x. And there was nothing going wrong. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: any ideas about handle user's relogin using interceptor?
The only data need to save is UserID and SessionID, I think it will not over 100 bytes per user. For 1000 user, the total memory will not over 10MB. So, you don't have to worry about memory problem. For the DB solution, if you worry about response speed. You can change the solution: Do not check for every request. Do it with some interval instead. For example: (1)check it once per 2 minutes OR (2)check it once per 10 requests. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: any ideas about handle user's relogin using interceptor?
I read your code, and noticed one thing. You saved the whole HttpSession instance in Map, this will waste memory. The information you really need is just the SessionID, but not the whole Session. SessionID can be retrieved from HttpSession.getId(); See: http://download.oracle.com/javaee/5/api/javax/servlet/http/HttpSession.html#getId%28%29 - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: any ideas about handle user's relogin using interceptor?
It looks like so. 2010/12/3 maven apache apachemav...@gmail.com: Thanks! So the way I use the interceptor is right? Nothing have to be changed except saving the session id intead of sessin it self? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Calling Struts Action from JavaScript
2010/12/1 Anjib Mulepati anji...@hotmail.com: Li When you say sending response using JSON what does that mean? I mean, send a string in JSON format as response. If your response is simple, for example, just a OK or ERROR flag, you can use plain text. But when you need send a complex data strut back to client side, for example, FLAG=ERROR ERROR_MESSAGE=[input data duplication, age is out of range] .. It will be hard to express in plain text format, so XML or JSON is a better choice. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Incorporating action interceptor configuration parameters into a message
I have read the source code of FileUploadInterceptor. I think it do the message getting in it's private method, and dose not use the maximumSize as a message format param. So I believe there is no simple way to extract interceptor interceptor param. The simplest way I known is, hard coding the value in your message properties file, like: struts.messages.error.file.too.large=File {1} is {3} bytes which exceeds the maximum 100123. It is a little ugly, but looks like the only way. The other way is, create a new class extend from FileUploadInterceptor, and override the error message building part, add the maximumSize as a message format param. But it need many code, I don't think this issue is worth doing so may work. 2010/12/1 stanl...@gmail.com: Thanks Li -- I saw what the interceptor was doing and decided that was not going to work. Would you mind posting the simple technique to extract the parameter from the interceptor configuration. I'll admit I'm not a Guice pro and studying the container build sent me straight to the bar last night. Scott - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Calling Struts Action from JavaScript
I recommend JSON when you need exchange complex data strut between client and server. Because it is very friendly to JavaScript, so you can easily handle complex data strut in your client side JavaScript code. Sample for JSON can be find in the web site Biesbrock has told you. The idea of JSON is very simple, and the libraries are very easy to use. I think you can study it in short time. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Calling Struts Action from JavaScript
OR, You can send a whole HTML code of the table as response. In this case, your server side view will be simple, just like any normal JSP. The client side will receive the HTML code, and you can insert this HTML piece into your page. But it will be difficult to manipulate, because what you get is not the raw data. Basically, if you want some simple html view, you can generate it on server side, by using normal JSP. If you want more complex flexible view, it is better to response the raw data(in JSON), and manipulate it on the client side, by JavaScript. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: labelizing submit buttons
I think your tag has a leak of attribute method Your code: s:submit key=btn.search / will generate HTML likes: input type=submit name=btn.search value=Search/ When you click this button, there will be a http request parameter like btn.search=Search. Struts2 will accept this parameter, and try to save it to your action property. So, there will be a property setting, which cause method invoking likes: YourAction.getBtn().setSearch(Search) But your action does not have a property named btn, so getBtn() will get a null, and of cause the setSearch part will fail. If you add a method attribute to submit tag, like: s:submit key=btn.search method=search / It will generate HTML like: input type=submit value=Search name=method:search / Notice, the name is now method:search So, when you click this button, the http request will be: method:search=Search. Struts will recognize the prefix method:, so it know that this is a flag to specify which method to execute, but not a input data which need to be set in to property of Action. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: binding paramters in struts2 without the form
Struts will not automatically populate fields based on parameters passed via the URL I always use URL to binding parameters to Action. And I have read source code of ParametersInterceptor, I think this Interceptor will populate all the params to Action. And it dose not treat params via URL or via POST differently. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Calling OGNL static method with date argument issue
What is the error message? And, how did you defined the property today? Is it the same data type as the static method param? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Calling Struts Action from JavaScript
Chris is right. On the client side, there is not such a concept of Struts Action.There is Server Side Resource only. You have to access(post or get) it by URL, param, and you must handle the response from the server side. Code should looks like: (1)Client side JavaScript Send a request to Server side. (Post or Get) (2)Server side do the validation first. When the param data is not good. Do nothing, and send a FAIL FLAG+ErrorMessage as response. (3)When the validation passed, insert data into DB, and send a OK FLAG as response. (4)Client Side JavaScript receive the response. If it is a FAIL, show error on the page. If it is a OK, append data to the table. About the response, You can use plain text, HTML, XML, or JSON. I recommend JSON, because it is very friendly to client side JavaScript - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Incorporating action interceptor configuration parameters into a message
The source code of FileUploadInterceptor is: http://svn.apache.org/repos/asf/struts/struts2/trunk/core/src/main/java/org/apache/struts2/interceptor/FileUploadInterceptor.java .. if (maximumSize != null maximumSize file.length()) { String errMsg = getTextMessage(action, struts.messages.error.file.too.large, new Object[]{inputName, filename, file.getName(), + file.length()}, locale); .. } .. It dose not pass the maximumSize to the message text as a param. So I think you have to hard code it in your message text. But I believe it is simple, and not extra coding need. 2010/12/1 stanl...@gmail.com: Before I wrap myself around my own axle, does anyone know a straightforward technique for substituting the maximumSize into a message property text according to the following scenario. action name=singleUpload class=FileUploadAction method=upload interceptor-ref name=fileUpload param name=maximumSize100123/param param name=allowedTypes image/png,image/x-png /param /interceptor-ref interceptor-ref name=basicStack / result name=input/jsp/SingleUpload.jsp/result result/jsp/Confirm.jsp/result /action struts.messages.error.file.too.large=File {1} is {3} bytes which exceeds the maximum DD I see the value 100123 in the FileUploadInterceptor inside the ActionInvocation, but before I write stupid code, I'd like to see if there might be a straightforward approach. Peace, Scott - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Upload file content to text box using struts 1.3.8
(1)Select file from a [file input] (2)Upload it to your Action (by a post) (3)In your action, read in the CSV data, and store into some property(let's say CSVDataProperty) (4)Show your page again, and set the default value of the textarea by CSVDataProperty 2010/11/30 Anjib Mulepati anji...@hotmail.com: Can anyone help me on getting file content (txt/CSV file) to be load in text area of web page? I have textarea in webpage and want to load the content of the file to that textarea. I am using struts 1.3.8. I couldn't fig out how can mimic file input button. Any hint will be appreciated. Thanks Anjib - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Upload file content to text box using struts 1.3.8
Why do you need two forms? Can't you put the FileUpload and the textarea in one form? And in your Action, you can create 2 method, one handle the file upload, and the other one handle the other request - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Upload file content to text box using struts 1.3.8
Another way is, using AJAX: (1)Send a file upload post, (using AJAX), to your FileUploadAction (2)FileUploadAction just read in the CSV file content, and return it as HTTP Response (3)On client side, AJAX can receive the Server response, then you can put it to the textarea (using JQuery) See: http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: javax.servlet.ServletException: BeanUtils.populate
I think the reason of the Exception maybe: (1)the data you post is named like liste[0].nom (2)Struts1 accept this http param, and try to translate it to a form property, by using a lib named Apache Commons BeanUtils See: http://commons.apache.org/beanutils/ (3)BeanUtils treats nested property access likes liste[0].nom as some chained java method invokes, like: targetBean.getListe[0].setNome(someValue) (4-1)If you did not initialize the array liste, it will be a null, so of cause getListe will get a null, and then, getListe[0] should throw a NullPointException (4-2)If you initialized the array, but there is no item in it, then getListe[0] should throw an IndexOutOfBoundsException (4-3)If you initialized the array, but the items in it is null, then getListe[0] will get a null, and then setNome(someValue) should throw a NullPointException So, you should initialize the array, and items in it, before you can capture data posted from client side. Years ago, I meet the same problem. But I used List instead of array. So I created a new class named AutoList. When you call the get(index) method on it, it will create a new item instance if the item dose not exist yet. By using this AutoList, when BeanUtils try to invoke method likes getListe(0).setNome(someValue), the item instance will be created automatically if need. In your case, my suggest is: (1)use AutoList, instead of Array Or (2)Since you have done the array/item initialization in the the method setNom(int index , Personne nom), so you can use this method instead of getListe[0].setNome(someValue). Which mean, in html side, the data name should be nom[0] instead of liste[0].nom How ever, I recommend AutoList solution strongly, because I believe this is a very common problem in Struts1. You may meet it somewhere else, so AutoList class will be very convenient. And also, if you use AutoList, you don't have to change the data name on the html side, which means, you can use struts tag lib as normal. If you need this AutoList class, I can send it to you. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: javax.servlet.ServletException: BeanUtils.populate
I have dug it out from my old project. The code is not very beautiful, you can modify it if you wish, but please don't change the author information. Here is the code: package com.ewsoft.common.utils; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.List; /** * A List class which can create items as need.br / * When method get(index) and add(index, element) is called,br / * and if there is no item in this index, item instances will be created * automatically to avoid a NullPointerException. * * @author Li Ying(liying.cn.2...@gmail.com) */ public class AutoListE extends Object extends ArrayListE { private ClassE elementClass; public AutoList(final ClassE elementClass) { super(); this.elementClass = elementClass; } private void ensureSize(final int size) { synchronized (this) { while (this.size() size) { add(createNewElement()); } } } private E createElementByConstructor() { try { ConstructorE[] constrArray = (ConstructorE[]) elementClass .getConstructors(); ConstructorE constructor = null; Class[] paramTypes = null; for (ConstructorE constr : constrArray) { if (constructor == null) { constructor = constr; paramTypes = constr.getParameterTypes(); } else if (constr.getParameterTypes().length paramTypes.length) { constructor = constr; paramTypes = constr.getParameterTypes(); } } List paramList = new ArrayList(); for (int i = 0; i paramTypes.length; i++) { paramList.add(null); } return constructor.newInstance(paramList.toArray()); } catch (Exception e) { return null; } } private E createNewElement() { return createElementByConstructor(); } /* * (non-Javadoc) * * @see java.util.ArrayList#get(int) */ @Override public final E get(final int index) { ensureSize(index + 1); return super.get(index); } /* * (non-Javadoc) * * @see java.util.ArrayList#add(int, java.lang.Object) */ @Override public final void add(final int index, final E element) { ensureSize(index); super.add(index, element); } } - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: javax.servlet.ServletException: BeanUtils.populate
There will be only one class, which will be the class of the elements in the List. I just want to find the Constructor with the least parameters if there are more than one constructors for this class. Once I get the constructor, I can use it to create instance and append it to List automatically. This is the final purpose of the AutoList class. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: javax.servlet.ServletException: BeanUtils.populate
What happens when (1)liste is null or (2)liste is filled by null element or (3)index accessed is out of bound? 2010/11/27 Peter Nguyen pe...@peternguyen.id.au: Li, I think the issue is here is most likely point 3. When the form is submitted, I suspect struts is trying to call getListe(int) to retrieve a Personne bean before calling the respective setters. So in this case, Dominque probably just needs an additional getter in the action form that will return the required bean: public Personne getListe(int i) { return (Personne) liste[i]; } Peter. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: File Download with multiple files. Design question
Any examples of doing this in struts 2 You can get the HttpServletResponse by: ServletActionContext.getResponse() And then, you can set the download file name, by: response.setHeader(Content-Disposition, attachment; filename= + fileName); And then, you can get the OutputStream, by: response.getOutputStream() Finally, you can output zipped data to the OutputStream. how to navigate to the next display after the download? I believe you can not navigate to the next page. Because for one http request, the server side can send only one response. If you want to download file and then show next page, it need 2 responses. I think this is impossible mission for one http request. If you send a file download response, then the browser will download it, and don't refresh the page, which means the current displayed page will remain. If you really want to implement this, may be you need some client side JavaScript to send a file download request first, and then send another request to display the next page. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Databinding a checkboxlist
try s:checkboxlist list=@my.site.enums.co...@values() listKey=label listValue=label name=colors / 2010/11/19 Altenhof, David Aron dalte...@iupui.edu: Trying to figure out a way to do the following without much luck. I have an enumeration with a list of menu options and corresponding labels such as: public enum Color { RED(Red), BLUE(Blue), GREEN(Green); private String myLabel; private Color(String label){ this.myLabel = label; } public String getLabel(){ return this.myLabel; } } This can be easily used to create a checkboxlist: p Please enter your favorite colors: /p s:checkboxlist list=@my.site.enums.co...@values() listValue=label name=colors / I also have a set of Color on the Action that came from the persistence layer and has a Color for each of the user's (past) choices: public SetColor getColors() { return colors; } Question is: How do I automagically check the appropriate checkbox if they have a corresponding value in getColors? I guess I'm looking for something like a databind from other languages. I suppose one could iterate over the enum and create individual checkboxes for each while testing to see if they have an already selected color, but I thought there might be a more direct way... -David - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: struts2.1 validation problem! with fileUploadStack
Maybe you can add a property in your action which return the current date. And reference this property in your validation configuration. Or create a Static method in an Utility class, return return the current date, And reference this property in your validation configuration. If both of these don't work, you have to implement your check by a validate method in your action. 2010/11/19 Mead Lai laiqi...@gmail.com: Thank you, Dave. Your explain is helpful for me to understand it. I want to validate the birthday in struts2 validation.xml, The range of date is between 1900-01-01 and current Date. How to get current date time in the struts2 validation.xml,? Thanks! field name=birth field-validator type=date param name=min1900-01-01/param param name=max${current Date}/param messageyour birthday shall be ${min}---${max}/message /field-validator /field Regards, Mead On Thu, Nov 18, 2010 at 8:04 PM, Dave Newton davelnew...@gmail.com wrote: Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: File Download with multiple files. Design question
My suggestion: (1)I believe you can use ZipOutputStream to output the zipped data to the response OutputStream directly, instead of a temp file. So no temp file need to be created. OR (2)You can create a batch application, repeatedly run it with some interval (use cron or something). And in this batch app, you can check the timestamp of your temp files, and delete them if they are old enough. I think the first way is the best, because there is not any side effects. But the second way is also valuable, because it can help you to clean up your working folder when you really need temp files. 2010/11/19 RogerV roger.var...@googlemail.com: Hi I have a requirement to present the user with a list of files stored on the server, and then download the files selected to the user. If the user selects a single file - no problem. However if the user selects multiple files, then, unless anyone knows different, all the files have to be sent in the single input stream read by the stream result. Therefore I create a temporary file with File.createTempFile() and use the ZipOutputStream to zip the files and then return an input stream over the temp file. This works suprisingly well. However, the problem I've now got is, how to get rid of the temp files I am creating on the server? file.deleteOnExit() is no use because the server VM will (in theory) never shutdown. Once the download is complete Struts automatically re-displays the original selection screen and provided the user uses the applicatoin supplied navigation to exit then I can delete the temp file, but if they simply close the browser or use the browser back button to navigate away I'm still left with the temp files sitting around. Creating the zipfile in memory is not an option as some of these can potentially be huge if the user goes mad and selects everything in sight. Is there someway of detecting/intercepting the fact that the Stream result has completed before Struts gets on with deciding what .jsp to display next so that I can safely clean up? Any other suggested approaches would be welome. Regards -- View this message in context: http://old.nabble.com/File-Download-with-multiple-files.-Design-question-tp30256036p30256036.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor Stack config
Hi RogerV I don't think config-browser plugin tells you which stack are you using, it just show you all of actions in namespaces you have configured, of course, including default namespace (2010/11/18 18:18), RogerV wrote: Hi I'm setting up a new Struts 2 project - the first time I've started from scratch in ages. I think it must be age, but I seem to have forgotten a lot of the basics :( Could someone look at my struts.xml and tell me why the config-browser plugin shows that I'm using the default stack rather than the prepareParamsPrepare stack as intended. Regards. struts constant name=struts.enable.DynamicMethodInvocation value=true / constant name=struts.devMode value=true / constant name=struts.objectFactory value=org.apache.struts2.spring.StrutsSpringObjectFactory / package name=default namespace=/ extends=struts-default interceptors interceptor-stack name=paramsPrepareParamsStack interceptor-ref name=exception/ interceptor-ref name=alias/ interceptor-ref name=i18n/ interceptor-ref name=checkbox/ interceptor-ref name=multiselect/ interceptor-ref name=params dojo\..*,^struts\..* /interceptor-ref interceptor-ref name=servletConfig/ interceptor-ref name=prepare/ interceptor-ref name=chain/ interceptor-ref name=modelDriven/ interceptor-ref name=fileUpload/ interceptor-ref name=staticParams/ interceptor-ref name=actionMappingParams/ interceptor-ref name=params dojo\..*,^struts\..* /interceptor-ref interceptor-ref name=conversionError/ interceptor-ref name=validation input,back,cancel,browse /interceptor-ref interceptor-ref name=workflow input,back,cancel,browse /interceptor-ref /interceptor-stack /interceptors default-interceptor-ref name=paramsPrepareParamsStack/ /package /struts - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: OGNL map key reading
try: invoke the [get] method on map: s:property value=currentPageHotelList[#stat.index].get(#roomindex)/ or reference property on map: s:property value=currentPageHotelList[#stat.index].(#roomindex)/ or iterator on values of map: s:iterator value=currentPageHotelList[#stat.index].values var=item s:property value=#item/ /s:iterator or iterator on keys of map: s:iterator value=currentPageHotelList[#stat.index].keys var=itemKey s:property value=currentPageHotelList[#stat.index].get(#itemKey)/ /s:iterator - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Interceptor Stack config
Why you define paramsPrepareParamsStack again? I believe it is already defined in the default configuration file, you can just use it. 2010/11/18 RogerV roger.var...@googlemail.com: Hi I'm setting up a new Struts 2 project - the first time I've started from scratch in ages. I think it must be age, but I seem to have forgotten a lot of the basics :( Could someone look at my struts.xml and tell me why the config-browser plugin shows that I'm using the default stack rather than the prepareParamsPrepare stack as intended. Regards. struts constant name=struts.enable.DynamicMethodInvocation value=true / constant name=struts.devMode value=true / constant name=struts.objectFactory value=org.apache.struts2.spring.StrutsSpringObjectFactory / package name=default namespace=/ extends=struts-default interceptors interceptor-stack name=paramsPrepareParamsStack interceptor-ref name=exception/ interceptor-ref name=alias/ interceptor-ref name=i18n/ interceptor-ref name=checkbox/ interceptor-ref name=multiselect/ interceptor-ref name=params dojo\..*,^struts\..* /interceptor-ref interceptor-ref name=servletConfig/ interceptor-ref name=prepare/ interceptor-ref name=chain/ interceptor-ref name=modelDriven/ interceptor-ref name=fileUpload/ interceptor-ref name=staticParams/ interceptor-ref name=actionMappingParams/ interceptor-ref name=params dojo\..*,^struts\..* /interceptor-ref interceptor-ref name=conversionError/ interceptor-ref name=validation input,back,cancel,browse /interceptor-ref interceptor-ref name=workflow input,back,cancel,browse /interceptor-ref /interceptor-stack /interceptors default-interceptor-ref name=paramsPrepareParamsStack/ /package /struts -- View this message in context: http://old.nabble.com/Interceptor-Stack-config-tp30239747p30239747.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts2, convention plugin, websphere 6.1
Everything submit from the client side, are passed as String. So you can't take object instance as your parameter. You need take the ids of these objects as parameter, and load object by the ids by you self. 2010/11/18 Harsh C hchau...@gmail.com: I think that is probably what it was. Basically in my action, I had a list of model objects (modelList) and a model object (selectedModel). I changed the Model type object selectedModel to String type selectedModelId and things work fine now. Now my question is, if I had a checkboxlist backed by a list of Model objects, and upon checking some models, I wanted a list of selectedModel objects, is there a way in struts to do it? Thanks, HC On Wed, Nov 17, 2010 at 11:47 AM, Dave Newton davelnew...@gmail.com wrote: Could also be a type conversion error. On Nov 17, 2010 2:46 PM, Harsh C hchau...@gmail.com wrote: So, result input is some kind of default result that struts sends a user to? Is validation turned on by default, as I did not specify any validation? If so, how can I turn it off? Thanks, HC On Wed, Nov 17, 2010 at 11:39 AM, Dave Newton davelnew...@gmail.com wrote: Failed validation will send user back to the input result. Dave On Nov 17, 2010 2:29 PM, Harsh C hchau...@gmail.com wrote: Hi, I have an input page which has a checkbox list in a form. Clicking submit takes the user to a 2nd JSP. The problem is that when I don't select a checkbox and click on submit, I get to the output page, of course no value is displayed on the output page though. But if I select a checkbox and click submit, I get an error saying No result defined for action .action.ModelHomeAction and result input I just started with struts and don't really know why it is looking for the result input. I would appreciate any help with this. Relevant code is below. input.jsp s:form method=post action=modelUpload s:checkboxlist name=selectedModel list=modelList listKey=modelId listValue=modelName/ s:submit/s:submit /s:form output.jsp s:property value=selectedModel/ Action private ArrayListModel modelList; private Model selectedModel = new Model(); public ArrayListModel getModelList() { FrameworkHandler handler = new FrameworkHandler(); return handler.getModels(); } public void setModelList(ArrayListModel modelList) { this.modelList = modelList; } public Model getSelectedModel() { return selectedModel; } public void setSelectedModel(Model selectedModel) { this.selectedModel = selectedModel; } public String execute() throws Exception { LOG.debug(Model Home Action); return SUCCESS; } public String upload() throws Exception{ return SUCCESS; } struts.xml action name=modelHome class=.action.ModelHomeAction method=execute result name=success/jsp/input.jsp/result /action action name=modelUpload class=.action.ModelHomeAction method=upload result name=success/jsp/output.jsp/result /action -- *Thanks, Harsh* -- *Thanks, Harsh* - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Another stupid question re: Interceptors
I suggest you to do these things in the following way: (1)put 2 method in IdentifyAction. The first [execute] method returns [input], show the input page to user. (2)In the Identify-input.jsp, submit fields to [IdentifyAction] itself, but another method: [verify] (3)when validation fails, the result will be [input] automatically, which means, the input page will be shown again. (4)when validation validation passes, your method [verify] will be executed. You can implement your business logic in it. If the verification fails, you can return a result [input], and back to the input page again. If the verification pass, you can return another result, and forward(or redirect) to the next action; or you can return a result [success], show the Identify-success.jsp page. (5)another thing need to notice is, method [execute] should be marked by [skipvalidation] annotation - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Setting object from param tag fails in Struts 2.2.1
I don't think this is a bug. Because the basic idea of WEB app is: everything is passed as String. Actually, there is a special layer in struts2 for data conversion. Your action may take int/long/boolean/date or something else as it's parameters, but all the original request parameters are String, and they are converted to appropriate data type by struts2 automatically. See: http://struts.apache.org/2.2.1/docs/type-conversion.html So, if param tag convert your parameter into String, I don't think this acting is incorrect, because the Action which receive this parameter should take the responsibility to convert it from String to something it need. In your case, your are calling an action from some action else. But think about calling it from the client side (for example: in browser), how could you pass an object instance as parameter? The only thing you can pass is String. So, my suggestion is: (1)Don't use an object instance as the parameter. Use the object id (can be int, string, and so on) instead. And in the action, load the object by id If you worry about the performance issue caused by object loading, you can use cache. OR (2)If your action will be accessed from other actions only, but never be called from the client side. Then you can delete the parameter from the action. Use request (or session) attribute instead. Before calling the action, put the object into request (or session) attribute. And in the action, load it from request (or session) attribute. 2010/11/17 Raj Nagappan r...@velocitylabs.com: I did some experimenting with this by removing the lazy load and putting the actual object directly on a property in the action class. This had no effect. So then I created a catch-all method setKeywordList(Object obj) to see what was being passed in. The actual data being passed in is a single element String array. The only element in the array is a string keywordl...@1f75664 ie. the Struts param tag is calling toString() on the object and passing the resulting string inside an array to the action class. I would say this is a regression bug from 2.0.x, yes? Raj. On 16/11/2010 9:18 PM, Raj Nagappan wrote: Hi, The parameter is definitely an object, if I replace the JSP below with h1s:property value=photoSet.keywordListLazyLoad//h1 h1s:property value=photoSet.keywordListLazyLoad.id//h1 I get keywordl...@3bcdf1, 15 which is correct. Furthermore if I add a setKeywordList(String[] param) method or setKeywordList(String param) method into the action class, it never invokes those new methods but still throws exactly the same exception. The only other thing I can think of is that it's trying to set the cglib proxy object on the action class and is complaining about that. We are using cglib-nodep-2.2 to lazy load the KeywordList, and it worked perfectly fine in Struts 2.0. (Sorry if this appears multiple times, I keep getting a spam rejection notice.) Raj. On 6:59 AM, Li Ying wrote: [Ljava.lang.String; means a String array. Looks like you are trying to copy a List from one action to another. By somehow, struts2 is looking for a set method which take a String array as it's parameter. 2010/11/15 Raj Nagappanr...@velocitylabs.com: Hi, we recently upgraded from Struts 2.0.14 to 2.2.1 and I notice that the following JSP code to inject an object property from one action into another action has stopped working: s:if test=hotoSet.keywordListLazyLoad != null s:action namespace=search name=KeywordList executeResult=true ignoreContextParams=rue s:param name=eywordList value=photoSet.keywordListLazyLoad/ /s:action /s:if So it checks that the object is not null and then tries to set it on the parameter keywordList. This worked perfectly fine in 2.0.x, but in 2.2 on the server side we get: java.lang.NoSuchMethodException: KeywordListAction.setKeywordList([Ljava.lang.String;) Â Â at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1226) Â Â at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1474) Â Â at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85) Â Â at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162) And the resulting error displayed on the web page is: Exception name: No result defined for action KeywordListAction and result input No result defined for action KeywordListAction and result input at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:375) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277) at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263) at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept (AnnotationValidationInterceptor.java:68) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept Is this a bug or do I need to do something differently
Re: Setting object from param tag fails in Struts 2.2.1
[Ljava.lang.String; means a String array. Looks like you are trying to copy a List from one action to another. By somehow, struts2 is looking for a set method which take a String array as it's parameter. 2010/11/15 Raj Nagappan r...@velocitylabs.com: Hi, we recently upgraded from Struts 2.0.14 to 2.2.1 and I notice that the following JSP code to inject an object property from one action into another action has stopped working: s:if test=photoSet.keywordListLazyLoad != null s:action namespace=/search name=KeywordList executeResult=true ignoreContextParams=true s:param name=keywordList value=photoSet.keywordListLazyLoad/ /s:action /s:if So it checks that the object is not null and then tries to set it on the parameter keywordList. This worked perfectly fine in 2.0.x, but in 2.2 on the server side we get: java.lang.NoSuchMethodException: KeywordListAction.setKeywordList([Ljava.lang.String;) at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1226) at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1474) at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85) at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162) And the resulting error displayed on the web page is: Exception name: No result defined for action KeywordListAction and result input No result defined for action KeywordListAction and result input at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:375) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277) at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263) at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept (AnnotationValidationInterceptor.java:68) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept Is this a bug or do I need to do something differently for 2.2? Raj. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Running external Javascript files through Struts/Freemarker -- access to ActionContext and ValueStack?
My suggestion: (1)Reference your js file as a static resource. (2)If the js need some dynamic information from your action. You can put js variables or hidden tags in your jsp, and retrieve these variables or hidden tags in your js. The js can be static outside resource, but [dynamic information] will be inlined in your jsp. This is a little ugly, but i think it is very simple. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Missing message for key welcome.title in bundle (default bundle) for locale es
I think there are several problem (1)You have defined the same message key in different resource bundle (ApplicationResource and MessageResources). This may be not a good way to maintenance resource (2)message-resources parameter=com/myapp/struts/MessageResources_es/ is not very good. The resource bundle should be reference by base name, and the suffix will be appended automatically for different user locale. So, I suggest you to change the setting to message-resources parameter=com/myapp/struts/MessageResources/ (3)If you define more than one [message-resources] in struts-config.xml, they need to be distinguished by different key, and also, you need specify the bundle when you reference them. For example, if you defined: message-resources key=resources01 parameter=package.Resources01/ message-resources key=resources02 parameter=package.Resources02/ then you should reference them by: bean:message bundle=resources02 key=some.message.key/ (4)I am not very sure, but I think the resource bundle name in struts-config.xml should be separated by dot instead of slash 2010/11/10 bladu ego...@hotmail.com: Hi Steven and Li, I have found out that my locale is [es]. But the problem still continues because, when I create the Welcome Struts application in Netbeans, In the package com.myapp.struts there is a default properties file create called ApplicationResource.properties, which has in English. welcome.title=Struts Application welcome.heading=Struts Applications in Netbeans! welcome.message=It's easy to create Struts applications with NetBeans. As I wanted to create a multilanguage application in Spasnish and English I created MessageResources_es.properties, which the following content. welcome.title=Holamundo Struts welcome.heading=Bienvenida! welcome.message=Holamundo Struts And In the Struts-config I add the following line message-resources parameter=com/myapp/struts/MessageResources_es/ below to message-resources parameter=com/myapp/struts/ApplicationResource/ But when I run the application it still gives me the same error. Regards -- View this message in context: http://old.nabble.com/Missing-message-for-key-%22welcome.title%22-in-bundle-%22%28default-bundle%29%22-for-locale-es-tp30175630p30179101.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Problem with Struts 1 form
(1)Is there any Proxy Server between the client PC and the Web App Server? (2)When the action going wrong, is there any Error or Exception message on the Server side? (3)There is a configuration item to control the max-file-size you can upload. You may need change it to more than 200MB. [maxFileSize - The maximum size (in bytes) of a file to be accepted as a file upload. Can be expressed as a number followed by a K, M, or G, which are interpreted to mean kilobytes, megabytes, or gigabytes, respectively. [250M] (optional)] for more information, see: http://struts.apache.org/1.3.10/userGuide/configuration.html#struts-config - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Problem with Struts 1 form
3. No such value is set. So I guess it is taking default value right now. As I said, You may need change it to more than 200MB. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Missing message for key welcome.title in bundle (default bundle) for locale es
try message-resources parameter=com/myapp/struts/MessageResources/ This is right. The name of a resource bundle, should not include the locale suffix. Actually, a resource bundle, contains several resource files which have the same base name and different suffix for each locale. For more information, see: http://download.oracle.com/javase/6/docs/api/java/util/ResourceBundle.html and make sure your locale is es_ES and not just es (not sure if it matters, but just to be on the save side) It matters. When user locale is [es_ES], the resource locale can be used should be (in the priority order): (1)es_ES or (2)es or (3)NONE When user locale is [es], the resource locale can be used should be (in the priority order): (1)es or (2)NONE Which means, resource locale [es_ES] can not be used for user locale [es] - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: ONGL EL expression problem.
s:iterator value=list.{?#this.id == titleID'} Is there an unnecessary quotation mark after [titleID]? Try delete it and see if works. If it still not working, My suggestion is: (1)you can implement the search logic in the method [viewPage], and access the search result via a new property. or (2)use a Map instead of a List, so you can retrieve the value by the key or (3)in your action class, add a new [Object Indexed Property] which retrieve the value from your list by the titleID see: http://www.opensymphony.com/ognl/html/LanguageGuide/indexing.html#N101C5 2010/11/9 Mead Lai laiqi...@gmail.com: Hello all, I have a Action contain a list ListadminTitleVO, and a String property titleID, how to display the value from list? Detail code is here: //**IndexAction** public class IndexAction{ private ListAdminTitleVO list; private String titleID; //get set public String viewPage() { //#{'a1':'admin','a2':'manager','a3':'member','a4':'user','a5':'guest'}// simple data list this.list = BS.getAdminTitleList(); //set a id this.titleID = a5; return view; } } //**AdminTitle** public class AdminTitle{ private String id; private String name; // get set ... } //**JSP page** s:select list=list listKey=id listValue=name value=a4/, 'user' item will be selected. Now, I want to display the name in plain text way! Get the name by titleID in the Action ${list[0].name}, I can get first item from List, and display the name= 'admin'; but ${list[titleID].name} is showing Error on page. How can I get the adminTitle.name on the page, by the certain adminTitle.id The following code run fine. s:iterator value=list.{?#this.id == 'a4'} s:property value=name / :s:property value=id / /s:iterator but s:iterator value=list.{?#this.id == titleID'} s:property value=name / :s:property value=id / /s:iterator it show nothing... What shall I do to pass the this.titleID in the Action into the struts2 Regards, Mead - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Have you ever used InputConfig annotation?
Actually, I am using interface [ValidationWorkflowAware] instead of annotation [InputConfig] for the purpose of repopulation when input validation fail happen. You can see how ValidationWorkflowAware work when you read the source code of DefaultWorkflowInterceptor. Basically, the idea is similar. But, [InputConfig] need you to appoint a method name every time. So I think it is more convenient if I use ValidationWorkflowAware. My solution looks like: (1)Define a class BaseAction as the base class for all my Action class (2)In BaseAction, implement [ValidationWorkflowAware] (3)In the method [getInputResultName], call a protected method [loadData] which is empty(for now), and then return [INPUT] as the result name (4)In specific action class, override the method [loadData], and do the real repolulation job for this page So I can keep all the action class do the same work in the same way. When the project and the develop team get large, I think the consistency of code convention is much important than just get the job done. Hope this helps. 2010/11/6 Alfredo Manuel Osorio Martinez alfredo.oso...@afirme.com: Hello, By looking at DefaultWorkflowInterceptor I saw an annotation that I didn't know existed. I am talking about: com.opensymphony.xwork2.interceptor.annotations.InputConfig I think it can be used for input repopulation and can be used as an alternative to Preparable and s:action/. What surprised me was that there is a little documentation about the use of the annotation or examples. Haver you ever used this one before? Is it a good idea to use it for input repopulation for example collections for selects in case a validation fails? Thanks - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: How to use s:optiontransferselect/
if I click the button to move the items, it doesn't work. Does any javascript error show up? Can you show us your entire source code? 2010/11/6 Mead Lai laiqi...@gmail.com: Hi All, I am now using s:optiontransferselect tag with simple theme. It shows two select-list fine, but if I click the button to move the items, it doesn't work. Any clue can help me? Now I am trying to write a double-select with JQury HTML. Thank you in advance. Regards, Mead - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org