Struts 2.5 ParameterAware and HttpParametersAware
we are using struts 2.3.xx after upgrade to struts 2.5.12 we found that the ParameterAware is deprecated and we must use HttpParametersAware. There is an action class which extends ParameterAware and change some parameters before action (It remove input masks for example removes , from 123,456,789) : public class Sample extends ActionSupport implements ModelDriven,ParameterAware { @Override public void setParameters(Map parameters) { for (String[] values : parameters.values()) { for (int i = 0; i < values.length; i++) { values[i] = Mask.removeMask(values[i]); } } } } --- We tried to do this with new HttpParametersAware and some thing like: --- for (Entry entry : parameters.entrySet()) { String key = entry.getKey(); Parameter newParam = new Parameter.Request( key, entry.getValue().getValue().replaceAll(",", "")); } But I face the error HttpParameters are immutable, you cannot put value directly! Can we change parameters like we used to do it in struts 2.3.x. how ?! ~Regards, ~~Alireza Fattahi
Struts 2 and Spring 4, how to get the validator or action object from spring application context
We are using Struts 2.5 and spring 4. The struts is configured spring as mentioned in https://struts.apache.org/docs/spring-and-struts-2.html. The struts `actions` and `validators` are spring managed beans and I can `inject` ( or `autowire`) other beans in them. This validator is working fine which shows the validator is an spring bean: public class MyValidator(){ @javax.inject.Inject private HelperClass aHelperClass; } Now, i want to get the `MyValidator` class from spring application context and use it. The below codes did not worked and returned null applicationContext.getBean("MyValidator"); applicationContext.getBean("foo.bar.MyValidator"); I look at `applicationContext.getBeanDefinitionNames()` but could not find the `validator`. So how can I get the struts validator from spring `applicationContext` ~Regards, ~~Alireza Fattahi Struts 2 and Spring 4, how to get the validator or action object from spring application context | | | | || | | | | | Struts 2 and Spring 4, how to get the validator or action object from sprin... We are using Struts 2.5 and spring 4. The struts is configured spring as mentioned in https://struts.apache.org/... | | | |
Define a bean of java.io.FileInputStream in Spring makes the Struts stream result not work
We are using the struts with spring in a project. Consider a simple action with **stream** result @Action(value = "sample-export", results = { @Result(name = "success", type = "stream", params = { "inputName", "exportInputStream", "contentType", "${exportContentType}; charset=UTF-8", "Content-Disposition", "attachment; filename=\"${filename}\"", "contentDisposition", "attachment; filename=\"${filename}\"", "bufferSize", "2048" }) }) public String export() throws ClientException { //buildExportInputStream() creates and returns new ByteArrayOutputStream by using jasper exportInputStream = buildExportInputStream(); LOG.debug("Exporting to {} file ", getFilename()); return SUCCESS; } This works fine. Some thing strange happens when I add below line in `spring-applicaiton-context.xml` !! After adding above line the inputStream of action will be a zero size file! When I set a break point in **StreamResult**, **doExecute** method the `inputStream.read(oBuff)` is always **-1**. The created bean (**sampleStream**) will be referenced by other beans by using ref for example ``. When I change this structure and use **sampleStream** as an inline parameter it works fine: Well can you help me to find what is going wrong ?! Why defining a bean of `FileInputStream` will cause this happens ?! Also asked at:Define a bean of java.io.FileInputStream in Spring makes the Struts stream result not work | | | | | | | | | | | Define a bean of java.io.FileInputStream in Spring makes...We are using the struts with spring in a project. Consider a simple action with stream result @Action(value = "sample-export", results = { @Result(name = "success",... | | | | View on stackoverflow.com | Preview by Yahoo | | | | | ~Regards, ~~Alireza Fattahi
Re: Struts 2 'top' object in struts 2.5
Also Asked at: http://stackoverflow.com/questions/32816417/struts-2-top-object-in-struts-2-5 ~Regards, ~~Alireza Fattahi From: Alireza Fattahi To: Struts Users Mailing List Sent: Monday, 28 September 2015, 17:49 Subject: Struts 2 'top' object in struts 2.5 According to http://struts.apache.org/docs/s2-026.html : Support for expression using top will be dropped in upcoming Struts version 2.5! We used the top object in lots of jsp pages as below (which shows a list of currencyTypes and look up the name from struts messages):It currently works with struts 2.3.24.1 but according to above comment, will above select box works for 2.5, or we will not have the top reference any more?! If this is true, please let me know how should we fix above select?! Also asked at: Struts 2 'top' object in struts 2.5 | | | | | | | | | | | Struts 2 'top' object in struts 2.5According to http://struts.apache.org/docs/s2-026.html : Support for expression using top will be dropped in upcoming Struts version 2.5! We used the top object in ... | | | | View on stackoverflow.com | Preview by Yahoo | | | | | ~Regards, ~~Alireza Fattahi
Struts 2 'top' object in struts 2.5
According to http://struts.apache.org/docs/s2-026.html : Support for expression using top will be dropped in upcoming Struts version 2.5! We used the top object in lots of jsp pages as below (which shows a list of currencyTypes and look up the name from struts messages):It currently works with struts 2.3.24.1 but according to above comment, will above select box works for 2.5, or we will not have the top reference any more?! If this is true, please let me know how should we fix above select?! Also asked at: Struts 2 'top' object in struts 2.5 | | | | | | | | | | | Struts 2 'top' object in struts 2.5According to http://struts.apache.org/docs/s2-026.html : Support for expression using top will be dropped in upcoming Struts version 2.5! We used the top object in ... | | | | View on stackoverflow.com | Preview by Yahoo | | | | | ~Regards, ~~Alireza Fattahi
Struts 2.5 BETA1
Sorry to post it here, subscribing to d...@struts.apache.org di not worked and I didn't get response emial.--The Struts 2.5 BETA1 make the struts 2 conversation plugin fails. This happens because of renaming theorg.apache.struts2.dispatcher.ServletActionRedirectResult;org.apache.struts2.dispatcher.ServletRedirectResult; After tweking these packages to:org.apache.struts2.result.ServletActionRedirectResultorg.apache.struts2.result.ServletRedirectResult the conversation plugin worked fine... As this is a useful plugin is it possible to keep the removed packages. ~Regards, ~~Alireza Fattahi
Re: Struts 2 manually call a custom validation in an action
Please see: http://stackoverflow.com/questions/29603916/struts-2-manually-call-a-custom-validation-in-an-action ~Regards, ~~Alireza Fattahi From: Alireza Fattahi To: Struts Mailing List Sent: Monday, 13 April 2015, 16:40 Subject: Struts 2 manually call a custom validation in an action We have used struts 2 validation with lots of custom validation to validate our forms. @Validations( customValidators = { @CustomValidator(type = "AccountFormat", fieldName = "accountNo") } ) Also we can can manually validate a form by overriding the validate method public void validate(){ //Username can't be blank if(username.equals("")){ addFieldError("username", "The Username can't be empty"); } Is it possible to call the `custom validations` in the `validate()`. **Why we need it ?!** All validation rules are packed in custom validations, which is perfect. There are some few forms which need to have their own manual validation. We end up cut and pasting some of custom validation rules in these manual validation forms too, it would be best if we could call validations here ~Regards, ~~Alireza Fattahi
Struts 2 manually call a custom validation in an action
We have used struts 2 validation with lots of custom validation to validate our forms. @Validations( customValidators = { @CustomValidator(type = "AccountFormat", fieldName = "accountNo") } ) Also we can can manually validate a form by overriding the validate method public void validate(){ //Username can't be blank if(username.equals("")){ addFieldError("username", "The Username can't be empty"); } Is it possible to call the `custom validations` in the `validate()`. **Why we need it ?!** All validation rules are packed in custom validations, which is perfect. There are some few forms which need to have their own manual validation. We end up cut and pasting some of custom validation rules in these manual validation forms too, it would be best if we could call validations here ~Regards, ~~Alireza Fattahi
Upgrading to Struts 2.3.20 and jCaptcha 1.0
.java:142) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2957) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1210) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1690) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:791) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2957) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1210) Caused by: java.lang.ClassNotFoundException: org.apache.struts.action.Action at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) ... 40 more ~Regards, ~~Alireza Fattahi
Struts 2 override resource messages keys
Consider this And default.properties content islabel.sample = Default Sample And the customize.properties content is//Duplicate key label.sample = Customize Sample Calling will result in Customize Sample If we review the above strust i18n this seems correct behavior as we first defined default and then the customize, so the keys in customize properties will override the keys in default.Now we try to override the customize messages dynamically. So In some where like an startup servlet, we add customize messages as:LocalizedTextUtil.clearDefaultResourceBundles(); LocalizedTextUtil.addDefaultResourceBundle("messages/customize"); This will not work! As alternative if we remove default from i18n property and do it as below, we will get the customize valueLocalizedTextUtil.clearDefaultResourceBundles(); LocalizedTextUtil.addDefaultResourceBundle("messages/default"); LocalizedTextUtil.addDefaultResourceBundle("messages/customize"); Is it possible to keep the list of default properties in xml and only add customize ones at run time ~Regards, ~~Alireza Fattahi
Re: OGNL Static Method call wrapper
The problem of static methods was not the issue I was talking about. Static methods are there you can use them or not, OGNL supports calling static methods.The struts team decided to disable this feature.Lots of framework users, use this feature ( may be they have set -Xmx .. parameters or not) But they are using it. Let them decide if they should use static method or not. Now: If some one decide to use static method call in validators or JSPs) Is it good to have a method in Action Supports which can be used to help faster integration and mean while enable users to call static method envocation in action and JSPs ?! ~Regards, ~~Alireza Fattahi From: Martin Gainty To: Struts Users Mailing List Sent: Monday, 19 January 2015, 17:00 Subject: RE: OGNL Static Method call wrapper No *Unless* you configure app to implement max heap -Xmx2048M -XX:PermSize=2048M -XX:MaxPermSize=2048m dont declare any entity Static anything .statics are notorious for parking in Permgen where of course the accumulation of other statics will eventually cause OOM http://stackoverflow.com/questions/8387989/where-is-a-static-method-and-a-static-variable-stored-in-java-in-heap-or-in-sta read this q&a on how variables and methods and classes declared statically essentially violate OOP http://stackoverflow.com/questions/7026507/why-are-static-variables-considered-evil Martin __ > Date: Mon, 19 Jan 2015 13:02:19 + > From: afatt...@yahoo.com.INVALID > To: user@struts.apache.org > Subject: OGNL Static Method call wrapper > > As the OGNL static method will be disabled soon ... we could use a wrapper to > call those static methods > Do you think it is a good idea to add a method ActionSupport for calling the > static methods > > So instead of @foo.bar@isValidAmount(amount) > we can use callStaticMethod("foo.bar.isValidAmount",amount) > > In this way there will be no need to add different method wrappers every time > we want to call static method and we can update the code lot easier, The > callStaticMethod (String methodName, String... Parameters) can use > reflection to call static methods > > Please review > http://stackoverflow.com/questions/28018861/struts-2-refactoring-code-to-avoid-ognl-static-method-access > > > ~Regards, > ~~Alireza Fattahi
OGNL Static Method call wrapper
As the OGNL static method will be disabled soon ... we could use a wrapper to call those static methods Do you think it is a good idea to add a method ActionSupport for calling the static methods So instead of @foo.bar@isValidAmount(amount) we can use callStaticMethod("foo.bar.isValidAmount",amount) In this way there will be no need to add different method wrappers every time we want to call static method and we can update the code lot easier, The callStaticMethod (String methodName, String... Parameters) can use reflection to call static methods Please review http://stackoverflow.com/questions/28018861/struts-2-refactoring-code-to-avoid-ognl-static-method-access ~Regards, ~~Alireza Fattahi
STRUTS_2_3_21
At github I found that the STRUTS_2_3_21 is released. But I can not download it from maven repo, I wonder how can we get it from maven.Also at struts.apache.org the final release is 2.3.20, is it a normal delay from release to site update, or 2.3.21 is just a (somehow) middle release. ~Regards, ~~Alireza Fattahi
Re: OGNL is used to call action's methods
Yes I am using the convention plugin !!Well, will this be fixed, or we should try the suggested workaround ?! ~Regards, ~~Alireza Fattahi From: Lukasz Lenart To: Struts Users Mailing List Sent: Tuesday, 16 December 2014, 11:02 Subject: Re: OGNL is used to call action's methods I think it can be related to your problem as well https://issues.apache.org/jira/browse/WW-4433 do you use the Convention Plugin? 2014-12-15 16:05 GMT+01:00 Alireza Fattahi : > If the action ends without exception, every thing will work fine.How ever > when the action throws the exception, we will face the and which I mentioned. > I tried to review the code, and I find that if the action throws the > exception the OgnlRuntime consume the exception and convert it to > InvocationTargetException ( line 1299) which later will be converted to > ognl.MethodFailedException ( line 1305) > So the action exception will not be re-thrown and the OGNL tries to handle it > by its own. > I think there must be a mechanism to stop OGNL runtime in a way that it > re-throw the action exception. > Hope I could describe what I mean ;) If you like I can send some sample codes > or a sample application. ~Regards, > ~~Alireza Fattahi > From: Lukasz Lenart > To: Struts Users Mailing List > Sent: Monday, 15 December 2014, 17:04 > Subject: Re: OGNL is used to call action's methods > > 2014-12-15 13:59 GMT+01:00 Alireza Fattahi : >> I checked and it was no same method name. Do you suggest I check other >> places too ~Regards, >> ~~Alireza Fattahi > > Check inheritance tree - it was known problem > > > > > 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 > > > - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: OGNL is used to call action's methods
If the action ends without exception, every thing will work fine.How ever when the action throws the exception, we will face the and which I mentioned. I tried to review the code, and I find that if the action throws the exception the OgnlRuntime consume the exception and convert it to InvocationTargetException ( line 1299) which later will be converted to ognl.MethodFailedException ( line 1305) So the action exception will not be re-thrown and the OGNL tries to handle it by its own. I think there must be a mechanism to stop OGNL runtime in a way that it re-throw the action exception. Hope I could describe what I mean ;) If you like I can send some sample codes or a sample application. ~Regards, ~~Alireza Fattahi From: Lukasz Lenart To: Struts Users Mailing List Sent: Monday, 15 December 2014, 17:04 Subject: Re: OGNL is used to call action's methods 2014-12-15 13:59 GMT+01:00 Alireza Fattahi : > I checked and it was no same method name. Do you suggest I check other places > too ~Regards, > ~~Alireza Fattahi Check inheritance tree - it was known problem 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
Re: OGNL is used to call action's methods
I checked and it was no same method name. Do you suggest I check other places too ~Regards, ~~Alireza Fattahi From: Lukasz Lenart To: Struts Users Mailing List Sent: Monday, 15 December 2014, 15:51 Subject: Re: OGNL is used to call action's methods 2014-12-15 13:17 GMT+01:00 Alireza Fattahi : > I used below strategy for error manager: > All actions can throw exception.There is a Error Manager Interceptor which > catch all exceptions and convert them to a json message and return it. > try { return invocation.invoke(); } catch (Exception ex) { > //Make some json result > response.getWriter().write(String.format("{ \"%s\":\"%s\"}", > DEFAULT_GLOBAL_ERROR_KEY, ex)); > return Action.NONE; } > > This was working in Struts 2.3.16. > After switching to 2.3.20 this is not working. When an action throws an > exception, I got below warning > DEBUG accessor.XWorkMethodAccessor Error calling method through OGNL: > object: [foo.LoginProcess@61d18d46] method: [result] args: [[]] > I think it is because OGNL is used to call action's methods. ~Regards, > ~~Alireza Fattahi It's probably because you're using similar names, have you read that [1]? [1] http://struts.apache.org/docs/security.html#Security-OGNLisusedtocallaction'smethods 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
OGNL is used to call action's methods
I used below strategy for error manager: All actions can throw exception.There is a Error Manager Interceptor which catch all exceptions and convert them to a json message and return it. try { return invocation.invoke(); } catch (Exception ex) { //Make some json result response.getWriter().write(String.format("{ \"%s\":\"%s\"}", DEFAULT_GLOBAL_ERROR_KEY, ex)); return Action.NONE; } This was working in Struts 2.3.16. After switching to 2.3.20 this is not working. When an action throws an exception, I got below warning DEBUG accessor.XWorkMethodAccessor Error calling method through OGNL: object: [foo.LoginProcess@61d18d46] method: [result] args: [[]] I think it is because OGNL is used to call action's methods. ~Regards, ~~Alireza Fattahi
Re: The %{#attr.counter.index} is not working in 2.3.20
Thanks. Issue created https://issues.apache.org/jira/browse/WW-4432 ~Regards, ~~Alireza Fattahi From: Lukasz Lenart To: Struts Users Mailing List Sent: Monday, 15 December 2014, 12:00 Subject: Re: The %{#attr.counter.index} is not working in 2.3.20 2014-12-15 9:15 GMT+01:00 Lukasz Lenart : > 2014-12-15 9:04 GMT+01:00 Alireza Fattahi : >> Below code is not working in struts 2.3.20 >> >varStatus="counter" begin="1"> >name="site.intro.intro%{#attr.counter.index}.caption"/> >> The %{#attr.counter.index} is not returning any value and no exception is >> thrown in the log the below message is shown: >> WARN ognl.SecurityMemberAccess Package of target >> [javax.servlet.jsp.jstl.core.LoopTagSupport$1Status@680cabbd] or package of >> member [public int >> javax.servlet.jsp.jstl.core.LoopTagSupport$1Status.getIndex()] are excluded! >> >> When I set struts.excludedPackageNamePatterns to empty, it works: >> Is it correct ?! >> It was working with 2.3.16. ~Regards, >> ~~Alireza Fattahi > > It's related to the new security mechanism introduced with 2.3.20 [1] > - but package and class don't match the excluded set :\ > > [1] > http://struts.apache.org/docs/security.html#Security-Internalsecuritymechanism javax.* is an excluded package ;-) You can simply redefine the excluded packages - please also register a bug to change the default "struts.excludedPackageNamePatterns" 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
The %{#attr.counter.index} is not working in 2.3.20
Below code is not working in struts 2.3.20 The %{#attr.counter.index} is not returning any value and no exception is thrown in the log the below message is shown: WARN ognl.SecurityMemberAccess Package of target [javax.servlet.jsp.jstl.core.LoopTagSupport$1Status@680cabbd] or package of member [public int javax.servlet.jsp.jstl.core.LoopTagSupport$1Status.getIndex()] are excluded! When I set struts.excludedPackageNamePatterns to empty, it works: Is it correct ?! It was working with 2.3.16. ~Regards, ~~Alireza Fattahi
Json result
Hi, Conisider this action: SampleAction{privateListsamples;//With setters and gettersprivateListanotherList;//With setters and gettersprivateStringanString;//With setters and getters@Action(value ="/loadSelect",results ={@Result(name ="success",type ="json")})publicStringloadSomeSamples(){samples =newArrayList();//Put some object in samples.returnSUCCESS;}} This will result to: {"samples":{"0":{"property":"a"},"1":{"property":"b"},"2":{"property":"c"}},"anString":"hello","anotherList":{"0":{"prop1":"a","prop2":"b"},"1":{"prop1":"c","prop2":"d"}}} Is it possible to configure json result to make below result {"samples":{"0":{"property":"a"},"1":{"property":"b"},"2":{"property":"c"}}} ~Regards, ~~Alireza Fattahi
Find action method in interceptor ( One action class with lots of action methods in it)
Please consider below action class: public class MyAction extends ActionSupport{ @Action("action1") public String action1(){ } @Action("action2") public String action2(){ } @Action("action3") public String action3(){ } } Is there any way in an inerceptor which I can find which method was really executed. I can find the class with myActionClass = invocation.getAction().getClass(); As I have many action methods in one class, how can I found which method was executed ~Regards, ~~Alireza Fattahi
Re: Struts 2 get custom action anotation in interceptors
Thanks! A complete code sample at: http://stackoverflow.com/questions/24021534/struts-2-get-custom-action-anotation-in-interceptors ~Regards, ~~Alireza Fattahi On Wednesday, 4 June 2014, 12:22, Lukasz Lenart wrote: Take a look on com.opensymphony.xwork2.util.AnnotationUtils 2014-06-03 19:37 GMT+02:00 Alireza Fattahi : > Consider below action class with three action mappings. Two of them are > annotated with a custom annotation `@AjaxAction` > > public class MyAction extends ActionSupport{ > > @Action("action1") > @AjaxAction //My custom anotation > public String action1(){ > } > > @Action("action2") > public String action2(){ > } > > @Action("action3") > @AjaxAction //My custom anotation > public String action3(){ > } > } > > > In an interceptor I want to access the `@AjaxAction` annotation. Is there any > built in support for this?! > > If not can I shall read the action name with > `ActionContext.getContext().getName();` and save a list of `ajaxAction` names > in interceptor as an array and compare action name with this array! any > better way?! > > private static final String[] AJAX_ACTIONS = new String[] {"action1", >"action3"} > > //in interceptor > String actionName = ActionContext.getContext().getName(); > if (Arrays.asList(AJAX_ACTIONS).contains(actionName)) { > // do something > } > > > ~Regards, > ~~Alireza Fattahi - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Struts 2 get custom action anotation in interceptors
Consider below action class with three action mappings. Two of them are annotated with a custom annotation `@AjaxAction` public class MyAction extends ActionSupport{ @Action("action1") @AjaxAction //My custom anotation public String action1(){ } @Action("action2") public String action2(){ } @Action("action3") @AjaxAction //My custom anotation public String action3(){ } } In an interceptor I want to access the `@AjaxAction` annotation. Is there any built in support for this?! If not can I shall read the action name with `ActionContext.getContext().getName();` and save a list of `ajaxAction` names in interceptor as an array and compare action name with this array! any better way?! private static final String[] AJAX_ACTIONS = new String[] {"action1", "action3"} //in interceptor String actionName = ActionContext.getContext().getName(); if (Arrays.asList(AJAX_ACTIONS).contains(actionName)) { // do something } ~Regards, ~~Alireza Fattahi
Re: Struts 2 Access messages with JSTL instead of s:text
As mentioned the ${action.getText('sample')} will work, but this is JSTL method invocation and you need JSTL 2.2 (ex: tomcat 7) ~Regards, ~~Alireza Fattahi On Friday, 30 May 2014, 16:20, Yaragalla Muralidhar wrote: you have to use fmt tags in jstl. Using jstl is a good idea. *Thanks and Regards,* Muralidhar Yaragalla. *http://yaragalla.blogspot.in/ <http://yaragalla.blogspot.in/>* On Wed, May 28, 2014 at 10:04 AM, Alireza Fattahi wrote: > In struts 2 the > > > > (is equivalent to...) > > JSTL: ${pageTitle} > > I use JSTL version which is more compact. > > Can we do the same thing with application messages?! To get text from > message resources we do as below: > > > > Now, is there any JSTL version insteadof `` ? > > > -- > > > Meanwhile, I tried to find a way to pass textprovider to jsp. But I could > not find a way > > public class BaseActionSupport extends ActionSupport{ > > //Same as ActionSupport > private TextProvider Provider; //with setter and getter > > public TextProvider getSampleTextProvider() { > > TextProviderFactory tpf = new TextProviderFactory(); > if (container != null) { > container.inject(tpf); > } > return tpf.createInstance(getClass(), this); > } > > } > In jsp: > > ${provider.text("label.password")} //Error The function text must be > used with a prefix when a default namespace is not specified > > Is it a correct approach?! > > PS: In the > http://notsoyellowstickies.blogspot.com/2011/05/making-struts-2-and-jstl-share-message.html > mentioned that I can somehow share struts 2 and jstl messages, but I should > still use `` > > > ~Regards, > ~~Alireza Fattahi
Struts 2 Access messages with JSTL instead of s:text
In struts 2 the (is equivalent to...) JSTL: ${pageTitle} I use JSTL version which is more compact. Can we do the same thing with application messages?! To get text from message resources we do as below: Now, is there any JSTL version insteadof `` ? -- Meanwhile, I tried to find a way to pass textprovider to jsp. But I could not find a way public class BaseActionSupport extends ActionSupport{ //Same as ActionSupport private TextProvider Provider; //with setter and getter public TextProvider getSampleTextProvider() { TextProviderFactory tpf = new TextProviderFactory(); if (container != null) { container.inject(tpf); } return tpf.createInstance(getClass(), this); } } In jsp: ${provider.text("label.password")} //Error The function text must be used with a prefix when a default namespace is not specified Is it a correct approach?! PS: In the http://notsoyellowstickies.blogspot.com/2011/05/making-struts-2-and-jstl-share-message.html mentioned that I can somehow share struts 2 and jstl messages, but I should still use `` ~Regards, ~~Alireza Fattahi
Access messages with JSTL instead of s:text
In struts 2 the (is equivalent to...) JSTL:${pageTitle} I use JSTL version which is more compact. Can we do the same thing with application messages?! To get text from message resources we do as below: Now, is there any JSTL version instead of ? Meanwhile, I tried to find a way to pass textprovider to jsp. But I could not find a way publicclassBaseActionSupportextendsActionSupport{//Same as ActionSupportprivateTextProviderProvider;//with setter and getterpublicTextProvidergetSampleTextProvider(){TextProviderFactorytpf =newTextProviderFactory();if(container !=null){container.inject(tpf);}returntpf.createInstance(getClass(),this);} } In jsp: ${provider.text("label.password")}//Error The function text must be used with a prefix when a default namespace is not specified ~Regards, ~~Alireza Fattahi
Make ${} operator XSS safe in Struts 2 (same as tapestry)
Hi, As mentioned in http://www.disasterarea.co.uk/blog/xss-vulnerabilities-in-web-frameworks-2/ The ${} is not xss safe in struts 2 while it is safe in tapestry 5. I am not a Tapestry guy, but I want to know if above is correct. As far as I know the ${} is part of JSLT and it does not depend on any web frameworks. So if above sentence is correct and the ${}is XSS safe in tapestry, how can we make it safe in struts 2. To test above in struts 2, I run struts2-showcase app, opened modelDriven\modelDrivenResult.jsp and add below line: Am I safe ${name} Now when you run the show case, go to model driven sample, and enter alert('') as gangester name you can see the alert! ~Regards, ~~Alireza Fattahi
Re: globaly escapeAmp
I found this in some pages, and thought may be the option is there: http://code.google.com/p/struts2-jquery/issues/detail?id=51 https://github.com/Dinous/d3kode/blob/master/src/struts.xml ~Regards, ~~Alireza Fattahi On Tuesday, 25 February 2014, 13:48, Lukasz Lenart wrote: 2014-02-24 10:41 GMT+01:00 Alireza Fattahi : > Is there any way to globally disable escape when generating url with s:url ?! > I found some one mentioned this: > > There is no such option in Struts - maybe someone did a custom interceptor or org.apache.struts2.components.UrlRenderer 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
Struts 2 defining a base action
We are creating a base action to manage export function. This base class deals with file name and content type. public class public abstract class AbstractExportAction{ //Will be override protected abstract InputStream exportInputStream() ; @Action(value = "export", results = { @Result(name = "success", type = "stream", params = { "inputName", "inputStream", "contentType", "${exportContentType}; charset=UTF-8", "Content-Disposition", "attachment; filename=\"${filename}\"", "contentDisposition", "attachment; filename=\"${filename}\"", "bufferSize", "2048" }) }) public String export() throws ClientException { inputStream = exportInputStream(); LOG.debug("Exporting to {} file ", getFilename()); return SUCCESS; } //setter getters for filename and exportContentType } Now the other actions extend above class and return they own data as InputStream package action.account; public class AccountsSummary extends AbstractExportAction { @Override protected InputStream exportInputStream() { } } *We have /account/export.action without any need to deal with file name and content * Generally every thing works fine, but in below case, the export action will not map to correct class: * Action A extends AbstractExportAction * Action B extends AbstractExportAction * Action A and B are in same namespace (package) In above case, struts ( struts convention plugin) randomly took one action A or B and map export action to that class. Do you think we are using correct approach?! ~Regards, ~~Alireza Fattahi
Assign html id to token
I try to ready token via javascript. The will not generate the id ! and still the output is: Should I read it by name ?! ~Regards, ~~Alireza Fattahi
globaly escapeAmp
Is there any way to globally disable escape when generating url with s:url ?! I found some one mentioned this: But it seems it is not working ! ~Regards, ~~Alireza Fattahi
Dynamic ID generated by FreeMaker
Hi, I found that in struts 2.3.16 the id is generated for input and selects by adding the form name and input name. For example id="loginForm#userName" I try to change this so only it generate the only input name as its id. I reviwed the text.ftl and find below line: <#if parameters.id??> id="${parameters.id?html}"<#rt/> Which means if id is defined use it. But I could not find where/how the autumatic generated ID is used here. ~Regards, ~~Alireza Fattahi
Showing Action Exception as Ajax Errors
Hi, We are using struts2 JSONValidationWithInterceptor. This interceptor grabs the errors from validation and convert them to json message How can we have same feature! An interceptor which grabs the action exceptions and serialize them as json errors. I try below interceptor. When an exception happens it works, when there are no errors and I should pass {} to response it is not working! ___ String target=Action.NONE; try { target=invocation.invoke(); response.getWriter().print("{}"); response.setContentType("application/json"); return target; } catch (BussinessException ex) { StringBuilder sb = new StringBuilder(); sb.append("{ "); sb.append("\"errors\": [\""); sb.append("Bussiness Exception Happend"); sb.append("\"]}"); response.setContentType("application/json"); response.getWriter().print(sb.toString()); return Action.NONE; } ~Regards, ~~Alireza Fattahi
Re: Passing jsp tag attribute to Struts 2 tags
Actually I am not calling any action class getKeyLable I try to: 1- Make the s:label tag get a dynamic (Is it poosibel ?!) 2- The above dynamic value must be read from jsp tag ( The s:label is used in a tag itself) ~Regards, ~~Alireza Fattahi On Saturday, 19 October 2013, 15:35, Martin Gainty wrote: * In this example, a label is rendered. The label is retrieved from a ResourceBundle via the key attribute * giving you an output of 'User Name: Ford.Prefect'. Assuming that i18n message userName corresponds * to 'User Name' and the action's getUserName() method returns 'Ford.Prefect' * * * * <s:label key="userName" /> * * * * * <s:label name="userName" label="User Name" /> * * what is returned by your Action Class getLabelKey Method Martin __ Verzicht und Vertraulichkeitanmung Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. > Date: Sat, 19 Oct 2013 04:23:55 -0700 > From: afatt...@yahoo.com > Subject: Passing jsp tag attribute to Struts 2 tags > To: user@struts.apache.org > > > Hi, > > I am creating a new tag in jsp, named `RequiredLabel` , but I can not pass > tag attribute to struts label ( The css are based on YAML) > > The tag will be used as: > > > The label should be get from struts as it must be localized. > <%@tag description="Renders a label with required css and error label" >pageEncoding="UTF-8"%> > <%@attribute name="name" required="true" %> > <%@taglib prefix="s" uri="/struts-tags"%> > > > > > > > I tried `#attr.name` and `#param.name` but none of them worked! > Do you know any solution ?! > > > > ~Regards, > ~~Alireza Fattahi
Re: [ANN] Struts 2.3.15.3 GA release available - security fix
I am creating a new tag in jsp, named `RequiredLabel` , but I can not pass tag attribute to struts label ( The css are based on YAML) The tag will be used as: The label should be get from struts as it must be localized. <%@tag description="Renders a label with required css and error label" pageEncoding="UTF-8"%> <%@attribute name="name" required="true" %> <%@taglib prefix="s" uri="/struts-tags"%> I tried `#attr.name` and `#param.name` but none of them worked! Do you know any solution ?! ~Regards, ~~Alireza Fattahi
Passing jsp tag attribute to Struts 2 tags
Hi, I am creating a new tag in jsp, named `RequiredLabel` , but I can not pass tag attribute to struts label ( The css are based on YAML) The tag will be used as: The label should be get from struts as it must be localized. <%@tag description="Renders a label with required css and error label" pageEncoding="UTF-8"%> <%@attribute name="name" required="true" %> <%@taglib prefix="s" uri="/struts-tags"%> I tried `#attr.name` and `#param.name` but none of them worked! Do you know any solution ?! ~Regards, ~~Alireza Fattahi
Re: Prevent Ajax Multi-Request in Struts 2
Jose, I am still in the middel of this problem :( Can you please let me know what do you mean by "check HTTP header" ?! ~Regards, ~~Alireza Fattahi From: JOSE L MARTINEZ-AVIAL To: Struts Users Mailing List ; Alireza Fattahi Sent: Thursday, 26 September 2013, 16:13 Subject: Re: Prevent Ajax Multi-Request in Struts 2 Hi, Since XHR request can not be cross-domain, you can not get a CSRF through XHR( the browser will not allow other page to send a XHR to your server). The only option would be a normal post against your supposed-ajax URL. In order to protect against it, we check for an HTTP header that is sent on any ajax request by our javascript framework (Dojo). A normal form can not be manipulate to add that header, so if the request is suppose to be ajax, and it does not have the header, you can reject it, because it is a CSRF attempt Regards JL 2013/9/25 Alireza Fattahi > Hi, > > We want to avoid multi-request sent via Ajax in struts 2 web based > application. > > The `s:token` can be used in regular request-response jsp pages, but it > will not work for ajax requests. The problem is the returned respond, which > does not populate new value for struts token. > > I found this issue at > http://stackoverflow.com/questions/13353577/howto-do-csrf-protection-in-struts2-application-for-ajax-requestsbutI > wonder if there is any better way for that? (I think this is a very > common issue which must have been managed in struts) > > > ~Regards, > ~~Alireza Fattahi >
config-browser plugin and validateAnnotatedMethodOnly
Hi, There seems to be a bug in the config-browser plugin, Action Information, validator tab. When I configure the validation as validateAnnotatedMethodOnly, the validator tab still shows all the validations instead of method specific validations. I used @Validations for validating methods and @Action for defining actions. Please let me know if anyone has seen this issue before. ~Regards, ~~Alireza Fattahi
Re: Prevent Ajax Multi-Request in Struts 2
Thanks, I was lootking Multi-Request preventation, is my problem equals to CSRF issue. ~Regards, ~~Alireza Fattahi From: Martin Gainty To: Struts Users Mailing List Sent: Friday, 27 September 2013, 0:12 Subject: RE: Prevent Ajax Multi-Request in Struts 2 To Mitigate add a "nonce" to the form https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF) Saludos Martin- > Date: Thu, 26 Sep 2013 08:43:12 -0400 > Subject: Re: Prevent Ajax Multi-Request in Struts 2 > From: jlm...@gmail.com > To: user@struts.apache.org; afatt...@yahoo.com > > Hi, > Since XHR request can not be cross-domain, you can not get a CSRF through > XHR( the browser will not allow other page to send a XHR to your server). > The only option would be a normal post against your supposed-ajax URL. In > order to protect against it, we check for an HTTP header that is sent on > any ajax request by our javascript framework (Dojo). A normal form can not > be manipulate to add that header, so if the request is suppose to be ajax, > and it does not have the header, you can reject it, because it is a CSRF > attempt > > > Regards > > JL > > > > 2013/9/25 Alireza Fattahi > > > Hi, > > > > We want to avoid multi-request sent via Ajax in struts 2 web based > > application. > > > > The `s:token` can be used in regular request-response jsp pages, but it > > will not work for ajax requests. The problem is the returned respond, which > > does not populate new value for struts token. > > > > I found this issue at > > http://stackoverflow.com/questions/13353577/howto-do-csrf-protection-in-struts2-application-for-ajax-requestsbutI > > wonder if there is any better way for that? (I think this is a very > > common issue which must have been managed in struts) > > > > > > ~Regards, > > ~~Alireza Fattahi > >
Prevent Ajax Multi-Request in Struts 2
Hi, We want to avoid multi-request sent via Ajax in struts 2 web based application. The `s:token` can be used in regular request-response jsp pages, but it will not work for ajax requests. The problem is the returned respond, which does not populate new value for struts token. I found this issue at http://stackoverflow.com/questions/13353577/howto-do-csrf-protection-in-struts2-application-for-ajax-requests but I wonder if there is any better way for that? (I think this is a very common issue which must have been managed in struts) ~Regards, ~~Alireza Fattahi
Re: report.conversion.errors
I found it in java doc http://struts.apache.org/release/2.0.x/struts2-core/apidocs/com/opensymphony/xwork2/util/XWorkConverter.html ~Regards, ~~Alireza Fattahi From: Lukasz Lenart To: Struts Users Mailing List Sent: Saturday, 21 September 2013, 19:18 Subject: Re: report.conversion.errors Where did you find that information? Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ 2013/9/21 Alireza Fattahi : > Hi, > > I want to stop xwork conversion from showing error during converting string > to int. > I found report.conversion.errors parameter which must be set in > xwork-conversion.properties > But it is not working, and during application starup up I get this error. > How should I use this parameter > > [ERROR] - conversion.impl.DefaultConversionPropertiesProcessor:error(): > Conversion registration error > java.lang.ClassNotFoundException: false > at >org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680) > at >org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526) > at >com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:152) > at >com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:108) > at >com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:233) > at >com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:153) > at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:151) > at >com.opensymphony.xwork2.conversion.impl.DefaultTypeConverterCreator.createTypeConverter(DefaultTypeConverterCreator.java:23) > at >com.opensymphony.xwork2.conversion.impl.DefaultConversionPropertiesProcessor.loadConversionProperties(DefaultConversionPropertiesProcessor.java:64) > at >com.opensymphony.xwork2.conversion.impl.DefaultConversionPropertiesProcessor.process(DefaultConversionPropertiesProcessor.java:40) > at >com.opensymphony.xwork2.conversion.impl.XWorkConverter.setConversionPropertiesProcessor(XWorkConverter.java:179) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at >sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at >sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at >com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:299) > at >com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:438) > at >com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:499) > at >com.opensymphony.xwork2.inject.ContainerImpl$7.call(ContainerImpl.java:539) > at >com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:593) > at >com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:537) > at >com.opensymphony.xwork2.config.impl.LocatableFactory.create(LocatableFactory.java:32) > at >com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:130) > at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51) > at >com.opensymphony.xwork2.inject.ContainerImpl$ParameterInjector.inject(ContainerImpl.java:469) > at >com.opensymphony.xwork2.inject.ContainerImpl.getParameters(ContainerImpl.java:484) > at >com.opensymphony.xwork2.inject.ContainerImpl.access$000(ContainerImpl.java:34) > at >com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:299) > at >com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:438) > at >com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:499) > at >com.opensymphony.xwork2.inject.ContainerImpl$7.call(ContainerImpl.java:539) > at >com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:593) > at >com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:537) > at >com.opensymphony.xwork2.config.impl.LocatableFactory.create(LocatableFactory.java:32) > at >com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:130) > at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51) > at >com.opensymphony.xwork2.inject.ContainerImpl$ParameterInjector.inject(ContainerImpl.java:469) > at >com.opensymphony.xwork2.inject.ContainerImpl.getParameters(ContainerImpl.java:484) > at >com.opensymphony.xwork2.inject.ContainerImpl.access$000(ContainerImpl.java:34) > at >com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:299) > at >com.opensymphony.xwork2.inject.
report.conversion.errors
$000(ContainerImpl.java:34) at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:299) at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:438) at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:499) at com.opensymphony.xwork2.inject.ContainerImpl$7.call(ContainerImpl.java:539) at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:593) at com.opensymphony.xwork2.inject.ContainerImpl.inject(ContainerImpl.java:537) at com.opensymphony.xwork2.config.impl.LocatableFactory.create(LocatableFactory.java:32) at com.opensymphony.xwork2.inject.ContainerBuilder$4.create(ContainerBuilder.java:130) at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:51) at com.opensymphony.xwork2.inject.ContainerImpl.getInstance(ContainerImpl.java:514) at com.opensymphony.xwork2.inject.ContainerImpl.getInstance(ContainerImpl.java:524) at com.opensymphony.xwork2.inject.ContainerImpl$9.call(ContainerImpl.java:555) at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:584) at com.opensymphony.xwork2.inject.ContainerImpl.getInstance(ContainerImpl.java:553) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:243) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:446) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:490) at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:424) at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:115) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) ~Regards, ~~Alireza Fattahi
Re: How configure struts2 to get validation rules from Spring via @value
Let me ask this way. In below validation @IntRangeFieldValidator(type =ValidatorType.FIELD,min ="10" is there any way we can read '10' from external resource files ! ~Regards, ~~Alireza Fattahi From: Lukasz Lenart To: Struts Users Mailing List Sent: Tuesday, 17 September 2013, 12:48 Subject: Re: How configure struts2 to get validation rules from Spring via @value Code formatting? Maybe use some web service to present your code. Does system.properties is defined as a Struts 2 properties file? 2013/9/17 Alireza Fattahi : > We are using spring 3 and struts 2. We use spring @value annotation to get > values from property files. > We want to get validation rules from property files instead of hard-coding > them in action. > Here is sample property system.properties transfer.account.min.amount=10 > Here is the action: > publicclassTransferToAccountimplementsPreparable{@Value("${transfer.account.min.amount}")publicStringminAmount;//...execute > and other methods omitted@IntRangeFieldValidator(type > =ValidatorType.FIELD,min ="${minAmount}",key > ="validate.int.min")publicvoidsetAmount(Integeramount){this.amount =amount;} > The minAmount is populated correctly by value 10, but the validation is not > working. > > > To see if parameters are passed correctly, I make a test as below. > Assume we want to get a key from spring managed property file ( This is just > a test ;) ) > system.properties > transfer.account.min.amount.key=validate.int.min > The resource bundel is: validate.int.min = This field must be more than ${min} > ...and make this change > @IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key > ="${transfer.account.min.amount.key}") > Now when an error happens the validation message shows validate.int.min, > instead of fetching this value from resource bundle! > Of course, when you run below code: > @IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key > ="validate.int.min") > The error message is fetched resource bundle correctly! > > > If I can use annotation in this way, please let me know what is my mistake! > If I can not use annotations like this, please let me know what is > the best way to avoid hard coding the validaiton rolls in actions. > > > ~Regards, > ~~Alireza Fattahi - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: How configure struts2 to get validation rules from Spring via @value
Let me ask this way. In below validation @IntRangeFieldValidator(type =ValidatorType.FIELD,min ="10" is there any way we can read '10' from external resource files ! ~Regards, ~~Alireza Fattahi From: Lukasz Lenart To: Struts Users Mailing List Sent: Tuesday, 17 September 2013, 12:48 Subject: Re: How configure struts2 to get validation rules from Spring via @value Code formatting? Maybe use some web service to present your code. Does system.properties is defined as a Struts 2 properties file? 2013/9/17 Alireza Fattahi : > We are using spring 3 and struts 2. We use spring @value annotation to get > values from property files. > We want to get validation rules from property files instead of hard-coding > them in action. > Here is sample property system.properties transfer.account.min.amount=10 > Here is the action: > publicclassTransferToAccountimplementsPreparable{@Value("${transfer.account.min.amount}")publicStringminAmount;//...execute > and other methods omitted@IntRangeFieldValidator(type > =ValidatorType.FIELD,min ="${minAmount}",key > ="validate.int.min")publicvoidsetAmount(Integeramount){this.amount =amount;} > The minAmount is populated correctly by value 10, but the validation is not > working. > > > To see if parameters are passed correctly, I make a test as below. > Assume we want to get a key from spring managed property file ( This is just > a test ;) ) > system.properties > transfer.account.min.amount.key=validate.int.min > The resource bundel is: validate.int.min = This field must be more than ${min} > ...and make this change > @IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key > ="${transfer.account.min.amount.key}") > Now when an error happens the validation message shows validate.int.min, > instead of fetching this value from resource bundle! > Of course, when you run below code: > @IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key > ="validate.int.min") > The error message is fetched resource bundle correctly! > > > If I can use annotation in this way, please let me know what is my mistake! > If I can not use annotations like this, please let me know what is > the best way to avoid hard coding the validaiton rolls in actions. > > > ~Regards, > ~~Alireza Fattahi - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
How configure struts2 to get validation rules from Spring via @value
We are using spring 3 and struts 2. We use spring @value annotation to get values from property files. We want to get validation rules from property files instead of hard-coding them in action. Here is sample property system.properties transfer.account.min.amount=10 Here is the action: publicclassTransferToAccountimplementsPreparable{@Value("${transfer.account.min.amount}")publicStringminAmount;//...execute and other methods omitted@IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key ="validate.int.min")publicvoidsetAmount(Integeramount){this.amount =amount;} The minAmount is populated correctly by value 10, but the validation is not working. To see if parameters are passed correctly, I make a test as below. Assume we want to get a key from spring managed property file ( This is just a test ;) ) system.properties transfer.account.min.amount.key=validate.int.min The resource bundel is: validate.int.min = This field must be more than ${min} ...and make this change @IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key ="${transfer.account.min.amount.key}") Now when an error happens the validation message shows validate.int.min, instead of fetching this value from resource bundle! Of course, when you run below code: @IntRangeFieldValidator(type =ValidatorType.FIELD,min ="${minAmount}",key ="validate.int.min") The error message is fetched resource bundle correctly! If I can use annotation in this way, please let me know what is my mistake! If I can not use annotations like this, please let me know what is the best way to avoid hard coding the validaiton rolls in actions. ~Regards, ~~Alireza Fattahi
Re: s:if and locale
Thanks for your solution . The did not work! I don't know why ! But I used your solution which seems much better tahn mine ! ~Regards, ~~Alireza Fattahi From: Chris To: Struts Users Mailing List ; Alireza Fattahi ; Chris Sent: Monday, 9 September 2013, 7:49 Subject: Re: s:if and locale Hello , Could you please write how do you define The locale is = ${locale} //Here the correct locale is displayed! I see in my browser ( even source code ) The locale is = //Here the correct locale is displayed! Please try this expresion and tell us if it works You will have to test your "locale" it in every jsp ? Couldn't you use for example, a global.properties file and struts.xml in the file global.properties :cssfile=englshstyle.css in the file global_es.properties :cssfile=spanishstyle.css in yourjsp : It works with sample http://struts.apache.org/development/2.x/docs/message-resource-files.html but the links are with parameter like action?request_locale=en and you will need many properties file HI, I have used the strtuts I18n feature for managing the localization. The site works fine and the messages are selected from correct resource bundels. I have this problem I want to change css base on the user locale. So I use below code in jsp: ** The locale is = ${locale} //Here the correct locale is displayed! //This condition is always false ** No matter what the locale value is, always the else condition is triggered !! The jsp out puts ** The locale is=en_US ** When I see the Struts ValueStack with the locale value is correct and is what it has too. Is there any thing wrong with my test conditin please help! ~Regards, ~~Alireza Fattahi
s:if and locale
HI, I have used the strtuts I18n feature for managing the localization. The site works fine and the messages are selected from correct resource bundels. I have this problem I want to change css base on the user locale. So I use below code in jsp: ** The locale is = ${locale} //Here the correct locale is displayed! //This condition is always false ** No matter what the locale value is, always the else condition is triggered !! The jsp out puts ** The locale is=en_US ** When I see the Struts ValueStack with the locale value is correct and is what it has too. Is there any thing wrong with my test conditin please help! ~Regards, ~~Alireza Fattahi
Spring Plugin
Hi, When we are using spring plugin, all the objects actions, interceptors, filters are managed by spring. Is it correct?! ~Regards, ~~Alireza Fattahi
convetion maps parent actions too!
Hi, I am usging convetion. All my actions extended a base action like public class AccountAction extends MyBaseActionSupport{ } The convention maps the MyBaseActionSupport too. Is there any way we can avoid it. ~Regards, ~~Alireza Fattahi
Spring Anotaction with Strust
Hi, May be this a spring question but please help me... Consider the example: http://struts.apache.org/release/2.2.x/docs/spring-and-struts-2.html I want to use spring anotation for defining the beans. So I make a EditServiceInMemory class as below: @Configuration public class EditServiceInMemory{ @Bean public void editService() { } } Accroding to spring above should be same as: But the anotation is not working! Is is any thing regarding to spring plug in ?! I also added the below in applicationContext.xml: ~Regards, ~~Alireza Fattahi
Re: Test with StrutsJUnit4TestCase
I forgot to merntion: When I extend StrutsJUnit4TestCase the assertTrue method is not found ! ~Regards, ~~Alireza Fattahi From: Alireza Fattahi To: Struts Users Mailing List Sent: Saturday, 17 August 2013, 13:18 Subject: Test with StrutsJUnit4TestCase Hi, Regarding to page: http://struts.apache.org/release/2.2.x/docs/struts-2-junit-plugin-tutorial.html I could not find the getConfigPath() method in StrustTestCase class I searched the javadocs and I found that only the StrutsJUnit4TestCase class has the getcinfigpath() method. So I should start to use JUnit4, but the example in above link seems not good for that. 1- Does any one know a toturial that can help me to start with this. 2- When I add struts2-junit-plugin to maven, should I manually add junit for to maven. the struts2-junit-plugin does not have any dependecy with junit4 har. ~Regards, ~~Alireza Fattahi
Test with StrutsJUnit4TestCase
Hi, Regarding to page: http://struts.apache.org/release/2.2.x/docs/struts-2-junit-plugin-tutorial.html I could not find the getConfigPath() method in StrustTestCase class I searched the javadocs and I found that only the StrutsJUnit4TestCase class has the getcinfigpath() method. So I should start to use JUnit4, but the example in above link seems not good for that. 1- Does any one know a toturial that can help me to start with this. 2- When I add struts2-junit-plugin to maven, should I manually add junit for to maven. the struts2-junit-plugin does not have any dependecy with junit4 har. ~Regards, ~~Alireza Fattahi
Re: AJAX Jsp tags
Thanks for you comments !! I have a question about tiles. I used tiles a lot in normal NON-AJAX base sites. Now I am designing a new fully ajax base site. My question is why should I use tiles! The code which contains the base layout is written once. Consider below layout | | | Header | | | | | | Menu1 Menu2 Menu3 | | | | | | | | | | Page content | | | | | | | | | | | | FOOTER | | | There will be a HomePage.jsp, which will have the structure of above above layout Menus, PageContent, Footer. The HomePage.jsp will have all the DIVs to layout the page. Then there will be a DIV for page conetent which will be changed when users click the menu. So, when user clicks the menu1 link the Ajax will replace the page content with page1.jsp. And all the remaining part of the page will not reload from server! The page1.jsp will only have the required content of page1, it will not have any header, menu and footer. I though that with Ajax technology there we will not required to use tiles any more. ~Regards, ~~Alireza Fattahi From: Chris Pratt To: Struts Users Mailing List Cc: Alireza Fattahi Sent: Monday, 12 August 2013, 10:50 Subject: Re: AJAX Jsp tags Excellent post Ken. I absolutely agree with everything you mention. I too use jQuery and jQuery UI directly in my JSP templates (not through some tag library) and find it easier and more powerful. I can also throw in a +1 for Tiles as a compositing technology that is indispensable in large sites. (*Chris*) On Sun, Aug 11, 2013 at 10:26 PM, Ken McWilliams wrote: > I have some experience creating custom struts2 tags, but for ajax I do not > advise this route at all. XML is not meant as a replacement for a > programming language, it is meant for configuration. It might seem > intuitive without further investigation that there are a limited number of > HTML UI elements and their functionality quite straight forward and so it > would seem reasonable that a configuration only route could work in the > general case. This is wrong as evidenced by all efforts to define dynamic > UI elements using XML. > > Even JavaFX tried to use xml and that was abandoned, they had the benefit > of designing the entire environment from the ground up, which is hardly the > case here. > > Not sure if you are familiar with the popular Question and Answer site > "Stack Overflow", however a great many questions regarding the struts2 ajax > tags go unanswered. If people could find solutions for their configuration > issues I wouldn't be so open with my negative view of ajax tags. Since it > is most often new users of Struts2 that attempt to use these tags and to > what appears to be dismal results I can't help but think that these tags > may actually be of harm to the struts2 image. > > I've only experimented with the jquery ajax tags breifly and experienced > frustration. Also before that experimented with the now deprecated dojo > tags. I had used the dojo tags within their prescribed limits but it is > much more enjoyable to have freedom. They were just too cumbersome. As soon > as you use JavaScript everything is far easier. > > Try to use Unobtrusive JavaScript: > http://en.wikipedia.org/wiki/Unobtrusive_JavaScript > > This will make your html "tag l
Re: AJAX Jsp tags
Thanks for your comment. Did you have any experience with struts jquery tag or other tags too? Or you complete suggest that we write our own tags ! ~Regards, ~~Alireza Fattahi From: Ken McWilliams To: Struts Users Mailing List Sent: Friday, 9 August 2013, 8:22 Subject: Re: AJAX Jsp tags Don't use a JSP AJAX tag library. The dojo JSP tags didn't work well not because of dojo or an fault of the tag authors, the technologies simply don't mesh. It's as sane to program Java via XML as it is to program JavaScript via XML. XML is used for configuration. At first glance you think you'll only need trivial behaviour but this is seldom ever the case, JS UI components are much easier to work with and you will need to provide your own handlers, which are often required even in the simple cases. XML can not account for all these cases and does not provides the means to add custom handlers in a way that would be as simple as using the underlying JS framework naturally. Further the tag authors often lag behind the UI components that they wrap, the documentation and features often fall behind too. With even a trivial understanding of JS you should be able to produce the same results as the Tags in the same time frame, as you gain experience you'll quickly superseded the capabilities of any tag library. On Thu, Aug 8, 2013 at 11:02 AM, Chris Pratt wrote: > The dojo based tags are deprecated, the jQuery based tags are not. > (*Chris*) > > > On Thu, Aug 8, 2013 at 9:54 AM, Alireza Fattahi > wrote: > > > Hi, > > > > I have confused with struts 2 ajax please correct me: > > 1- The dojo plugin is deprecated ( > > http://struts.apache.org/release/2.3.x/docs/ajax-tags.html) > > 2- According to above we are not recommended to use dojo plugin in new > > projects. > > 3- All tags that mentioned in above page like: a, autocompliter,bind ... > > shall not be used. > > 4- According to page > http://struts.apache.org/release/2.3.x/docs/ajax.html > > : > > "First, you can use some type of JSP tag. Here, you don't have to > know > > very much at all about Ajax or JavaScript. The taglib does all the work, > > and you just have to figure out how to use the taglib. The standard > > Struts 2 taglib includes several Ajax JSP tags," > > 5- The "Ajax JSP tags" link above will redirect to > > http://struts.apache.org/release/2.3.x/docs/ajax-tags.html, which is > > deprecated!! > > > > I don't get it ! > > Can we use AJAX Jsp tags or they are deprecated ? > > > > > > ~Regards, > > ~~Alireza Fattahi > > >
AJAX Jsp tags
Hi, I have confused with struts 2 ajax please correct me: 1- The dojo plugin is deprecated (http://struts.apache.org/release/2.3.x/docs/ajax-tags.html) 2- According to above we are not recommended to use dojo plugin in new projects. 3- All tags that mentioned in above page like: a, autocompliter,bind ... shall not be used. 4- According to page http://struts.apache.org/release/2.3.x/docs/ajax.html: "First, you can use some type of JSP tag. Here, you don't have to know very much at all about Ajax or JavaScript. The taglib does all the work, and you just have to figure out how to use the taglib. The standard Struts 2 taglib includes several Ajax JSP tags," 5- The "Ajax JSP tags" link above will redirect to http://struts.apache.org/release/2.3.x/docs/ajax-tags.html, which is deprecated!! I don't get it ! Can we use AJAX Jsp tags or they are deprecated ? ~Regards, ~~Alireza Fattahi
Re: Plug in page link broken
Hi, I also could not find the OVAL plugin link in Strust2Pluginfs/Home. But you can visit it by directly going to: https://cwiki.apache.org/confluence/display/S2PLUGINS/OVal+Plugin ~Regards, ~~Alireza Fattahi From: Lukasz Lenart To: Struts Users Mailing List Sent: Monday, 15 July 2013, 11:11 Subject: Re: Plug in page link broken Thanks for reporting, corrected in the source. For now you can use this https://cwiki.apache.org/confluence/display/S2PLUGINS/Home Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ 2013/7/12 Alireza Fattahi : > Hi, > > The plugin page link : https://cwiki.apache.org/S2PLUGINS/home.html in struts > site is broken: > > > Not Found > The requested URL /S2PLUGINS/home.html was not found on this server. > > > Apache/2.2.22 (Ubuntu) Server at cwiki.apache.org Port 80 > > > ~Regards, > ~~Alireza Fattahi - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Tags Attributes
Hi, Does anyone why: generates error: Attribute un_defined_attribute invalid for tag fielderror according to TLD But Does not generate an error and creates below html: is it hard coded some where ?! ~Regards, ~~Alireza Fattahi
Re: json validation with utf-8 error messages
Hi, I used to save the messages.resources with UTF-8 encoding and the showed correctly but the json validation messages not! I saved mesages.resource with ansi encoding and chaned all strings from native to ascii ( by http://native2ascii.net/ ) the json validation messages displayed correctly but the did not show correct messages, just question marks. I added <%@ page contentType="text/html; charset=utf-8" %> to the page and now I have correct json validation messages AND I don't know is it best practice or not. ~Regards, ~~Alireza Fattahi From: Lukasz Lenart To: Struts Users Mailing List Sent: Monday, 15 July 2013, 13:30 Subject: Re: json validation with utf-8 error messages 2013/7/15 Alireza Fattahi : > Any comments?! Any example?!?!?!?!?!?! 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
json validation with utf-8 error messages
Hi, The characters of error messages with json validation and a utf-8 error message is not displayed correctly. I added SetEncoding org.apache.catalina.filters.SetCharacterEncodingFilter encoding UTF-8 and SetEncoding * But it did not fix the issue. Any comments?! ~Regards, ~~Alireza Fattahi
Re: Int Validator
Thanks. Do you know how can I change below message: Invalid field value for field "amount" ?! ~Regards, ~~Alireza Fattahi From: Dave Newton To: Struts Users Mailing List Sent: Saturday, 13 July 2013, 16:16 Subject: Re: Int Validator The field value error comes from the type conversion process. The field should be an int or an Integer, with the caveat that an int has a default value of 0, which may not be desirable. Save On Jul 12, 2013 11:56 PM, "Alireza Fattahi" wrote: > Hi, > > I want to validate the amount filed to be an integer with minimum value of > 1 > I describe the field type as Integer (not int ) > Add below validation rule > > > ${getText("validate.required")} > > > 10 > ${getText("validate.int.min")} > > > > When the amount is empty I get validate.required error. > > When I type a text instead of integer I get Invalid field value for field > "amount" . I don't know where it comes from and how can I change it. > > Also please let me know if I should define the amount as int, Integer or > String ! > > > ~Regards, > ~~Alireza Fattahi
Int Validator
Hi, I want to validate the amount filed to be an integer with minimum value of 1 I describe the field type as Integer (not int ) Add below validation rule ${getText("validate.required")} 10 ${getText("validate.int.min")} When the amount is empty I get validate.required error. When I type a text instead of integer I get Invalid field value for field "amount" . I don't know where it comes from and how can I change it. Also please let me know if I should define the amount as int, Integer or String ! ~Regards, ~~Alireza Fattahi
Plug in page link broken
Hi, The plugin page link : https://cwiki.apache.org/S2PLUGINS/home.html in struts site is broken: Not Found The requested URL /S2PLUGINS/home.html was not found on this server. Apache/2.2.22 (Ubuntu) Server at cwiki.apache.org Port 80 ~Regards, ~~Alireza Fattahi
Re: Using Two Parent Pakages!!
Hi, The json plug in has a package json-default and the "json" result type is defined in this package. To use this result type you should do some thing like: 1- Make a new package and extend it 2- Copy and past the in my package 3- Make this package the parent package. My question is: If the struts finds the result-type "json",in struts2-json-plugin.jar , why doesn't it make this result-type available to all actions ? Why should I address struts where this result type is defined ? ~Regards, ~~Alireza Fattahi ____________ From: Alireza Fattahi To: Struts Users Mailing List Sent: Wednesday, 10 July 2013, 10:50 Subject: Re: Using Two Parent Pakages!! Hi, So I define some thing like Is it possible that I say the struts that this the default package for all packages ?! ~Regards, ~~Alireza Fattahi From: Lukasz Lenart To: Struts Users Mailing List ; Alireza Fattahi Sent: Wednesday, 10 July 2013, 10:27 Subject: Re: Using Two Parent Pakages!! 2013/7/10 Alireza Fattahi : > Thanks ! > > I found a code > here:http://struts.apache.org/release/2.0.x/docs/zero-configuration.html > > > @ParentPackage({"my-parent-package1, my-parent-package2"}) package > com.mycompany.myapp.actions import org.apache.struts2.config.ParentPackage; > > > Can I do it ?! Right, you can extend from more than one package http://struts.apache.org/release/2.0.x/docs/package-configuration.html 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
Re: Define the a property
Hi, Sorry for sending the email directly, it was a mistake ! Any way, I expect that when this happens a warning message displayed to the developers not a full stack trace. You know, usually when you see this stack, it shows that something terribly bad happened !! Do you know which interceptor creates this ? ~Regards, ~~Alireza Fattahi From: Lukasz Lenart To: Alireza Fattahi Sent: Wednesday, 10 July 2013, 16:43 Subject: Re: Define the a property Could you ask such questions on the User Mailing List? And this was introduced to warn developer about missing properties or typo in properties. This warning is only emitted in devMode. Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ 2013/7/10 Alireza Fattahi : > Well, who make this?! > I think it was preaperparam interceptor, can we update log4j in the way that > ikt does not show these warning . > > > ~Regards, > ~~Alireza Fattahi > > From: Lukasz Lenart > To: Alireza Fattahi > Sent: Wednesday, 10 July 2013, 13:51 > Subject: Re: Define the a property > > No, but you will get warning in devMode > > 2013/7/10 Alireza Fattahi : >> Hi, >> >> Should we always define the a property in the action for all the textfiled >> that we have in the form >> >> See below: >> >> >> >> Error setting expression 'echo' with value ['Hello World!!!', ] - [unknown >> location] >> at >> >> com.opensymphony.xwork2.ognl.OgnlValueStack.handleRuntimeException(OgnlValueStack.java:201) >> at >> >> com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:178) >> at >> >> com.opensymphony.xwork2.ognl.OgnlValueStack.setParameter(OgnlValueStack.java:152) >> at >> >> com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:329) >> at >> >> com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:241) >> at >> >> com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) >> at >> >> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) >> at >> >> com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249) >> at >> >> com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) >> at >> >> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246) >> >> ~Regards, >> ~~Alireza Fattahi >> >> > >
Re: Global Validation
Hi, Well I mean is there a way which I can tell the validation frame work that all "required string" validations should display this message The ${TheFiledWhichFailed} must be a string And then I define: Username Address So when the validation fails it generates: The username must be string. The address must be string. . Or should I do it: Username Username must be string. Address Address must be string. ~Regards, ~~Alireza Fattahi From: Lukasz Lenart To: Struts Users Mailing List Sent: Wednesday, 10 July 2013, 16:47 Subject: Re: Global Validation 2013/7/10 Alireza Fattahi : > Hi, > > Are there Global Validation in struts 2 ?! What you mean by that? Validations which affects each and every action? If so, no. 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
Global Validation
Hi, Are there Global Validation in struts 2 ?! ~Regards, ~~Alireza Fattahi
Re: Possible client side validation bug in Struts 2.3.15
Hi, I get these two warnings: 2013-07-10 16:42:45,683 WARN (com.opensymphony.xwork2.interceptor.ParametersInterceptor:56) - Parameter [struts.enableJSONValidation] is on the excludeParams list of patterns! 2013-07-10 16:42:45,683 WARN (com.opensymphony.xwork2.interceptor.ParametersInterceptor:56) - Parameter [struts.validateOnly] is on the excludeParams list of patterns! How can I fix it ?! I put below in struts.xml But it did not help. ~Regards, ~~Alireza Fattahi
REST Plugin with convention plugin
Hi, I am trying to use REST Plugin with convention plugin . For all REST actions I should extend RestActionMapper, After I extend RestActionMapper instead of ActionSuppor, the convention plugin those not find the action any more ! ~Regards, ~~Alireza Fattahi
Re: Using Two Parent Pakages!!
Hi, So I define some thing like Is it possible that I say the struts that this the default package for all packages ?! ~Regards, ~~Alireza Fattahi From: Lukasz Lenart To: Struts Users Mailing List ; Alireza Fattahi Sent: Wednesday, 10 July 2013, 10:27 Subject: Re: Using Two Parent Pakages!! 2013/7/10 Alireza Fattahi : > Thanks ! > > I found a code > here:http://struts.apache.org/release/2.0.x/docs/zero-configuration.html > > > @ParentPackage({"my-parent-package1, my-parent-package2"}) package > com.mycompany.myapp.actions import org.apache.struts2.config.ParentPackage; > > > Can I do it ?! Right, you can extend from more than one package http://struts.apache.org/release/2.0.x/docs/package-configuration.html 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
Re: Using Two Parent Pakages!!
Thanks ! I found a code here:http://struts.apache.org/release/2.0.x/docs/zero-configuration.html @ParentPackage({"my-parent-package1, my-parent-package2"}) package com.mycompany.myapp.actions import org.apache.struts2.config.ParentPackage; Can I do it ?! ~Regards, ~~Alireza Fattahi From: Lukasz Lenart To: Struts Users Mailing List ; Alireza Fattahi Sent: Wednesday, 10 July 2013, 10:13 Subject: Re: Using Two Parent Pakages!! 2013/7/10 Alireza Fattahi : > Hi, > > I am using the convention in with json plugin so I add: > value="json-default" /> > Now I want to use the REST plugin so I should add: > value="rest-default" /> json-default [1] contains just one result definition and two interceptors, so you can merge it into your own package > How can I solve it ! Question mark would be better than exclamation mark ;-) [1] https://svn.apache.org/repos/asf/struts/struts2/trunk/plugins/json/src/main/resources/struts-plugin.xml 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
Using Two Parent Pakages!!
Hi, I am using the convention in with json plugin so I add: Now I want to use the REST plugin so I should add: How can I solve it ! ~Regards, ~~Alireza Fattahi
Re: convention redirect to slash
I do not use any configuration. There is an index.jsp: <% response.sendRedirect("index.action"); %> and the index.action is has a execute and simple return SUCCESS and redirects to a jsp. As I said it is the struts 2 jquery showcase sample! I am new, please let me know if I should describe any thing else !! ~Regards, ~~Alireza Fattahi From: Lukasz Lenart To: Struts Users Mailing List ; Alireza Fattahi Sent: Tuesday, 9 July 2013, 17:40 Subject: Re: convention redirect to slash Ok, but could you share configuration of results? How do you perform redirect? 2013/7/9 Alireza Fattahi : > Here it is: > > I acutally downloaded the struts 2 jquery plug in and add > > to it! > > > > > > value="com.jgeppert.struts2.jquery.showcase" /> > value="json-default" /> > > > > > > > > ~Regards, > ~~Alireza Fattahi > > > > From: Lukasz Lenart > To: Struts Users Mailing List ; Alireza Fattahi > > Sent: Tuesday, 9 July 2013, 17:22 > Subject: Re: convention redirect to slash > > > 2013/7/9 Alireza Fattahi : >> The >> >> is not working ! >> It keeps redirecting to slash >> >> any comments ?! > > Could you share your struts.xml? Os some snippets with results? > > > 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 - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
by pass the validation
Hi, When I put SomeAction-validation.xml nead an action class, the validation is always checked before execute method. If I have more than one method in the action, will the validation execute for them too ?! Is there any way that I can configure which methods should by pass the validation ~Regards, ~~Alireza Fattahi
Re: convention redirect to slash
Here it is: I acutally downloaded the struts 2 jquery plug in and add to it! ~Regards, ~~Alireza Fattahi From: Lukasz Lenart To: Struts Users Mailing List ; Alireza Fattahi Sent: Tuesday, 9 July 2013, 17:22 Subject: Re: convention redirect to slash 2013/7/9 Alireza Fattahi : > The > > is not working ! > It keeps redirecting to slash > > any comments ?! Could you share your struts.xml? Os some snippets with results? 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
convention redirect to slash
Hi, The is not working ! It keeps redirecting to slash any comments ?! ~Regards, ~~Alireza Fattahi
Re: Extending Template
Yes it is a typo. I have this in the struts.xml ~Regards, ~~Alireza Fattahi From: Lukasz Lenart To: Struts Users Mailing List Sent: Tuesday, 9 July 2013, 11:12 Subject: Re: Extending Template 2013/7/9 Alireza Fattahi : > Hi, > > I want to extend the css_xhtml. > > 1- /WEB-INF/classes/template/mytemp > 2- Put the theme.properties in it . > 3- Add the parent = css_xhtml > 4- Update the the struts.xml as below: > > is it typo here or in your code? 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
Extending Template
Hi, I want to extend the css_xhtml. 1- /WEB-INF/classes/template/mytemp 2- Put the theme.properties in it . 3- Add the parent = css_xhtml 4- Update the the struts.xml as below: I got below error: -- Error reading included file template/mytemp/controlheader.ftl The problematic instruction: -- ==> include "/${parameters.templateDir}/${parameters.theme}/controlheader.ftl" [on line 24, column 1 in template/css_xhtml/text.ftl] -- Template template/mytemp/controlheader.ftl not found. -- I expect that every thing should go fine !! I have just extended the template, should I copy all the css_xhtml folder from struts2-core jar. ~Regards, ~~Alireza Fattahi
Struts2+Hinerneta Validator+Spring
Hi, I want to use hibernate validation with struts and spring. I found the "Full Hibernate Plugin" which combines the struts 2 and hibernate and hibernate validation. It has its own API for using the hibernate, but it does not use the Spring. However, I want to use is! So: 1- Can I use "Full Hibernate Plugin", "Hibernate Validation" feature only. 2- If not, are there any other frameworks which helps us with that. 3- I found a method described in http://vamshisomanchi.wordpress.com/2008/07/26/struts-20-hibernate-validator/ any other simpler way ~Regards, ~~Alireza Fattahi
@result dosenot have value
Hi, I am using @Result but it does not have the value filed !! it only has location,name,type and tiles. I am using struts 2.1.8 So below does not work: @Action(value = "/register", interceptorRefs = { @InterceptorRef(value = "i18nStack") }, results = { @Result( value="register.jsp",location = "register", name = "input", type = "tiles" ) }) ~Regards, ~~Alireza Fattahi