[ https://issues.apache.org/jira/browse/WW-4066?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13666479#comment-13666479 ]
Chris Cranford edited comment on WW-4066 at 5/24/13 5:25 PM: ------------------------------------------------------------- One of the reasons why our base action overrides the action errors, message, and field message methods was because it allowed us to simply call {{addActionMessage("some.message");}} without having to wrap the message itself using {{getText}}. That part is what has worked up until the latest builds. What I'll propose to our team is that we'll modify all actions to make use of the {{getText()}} call within each action where we pass a message to the methods that we were originally overriding and remove their overrides from the base action. That should bring the code base in line with the expectations and avoid the {{StringIndexOutOfBoundsException}} error. But what still troubles me with this is related to the developer notifications themselves. I modified the {{ItemSearchAction}} as follows: {code} public ItemSearchAction() { this.criteria = new ItemSearchCriteria(); } {code} Technically, that should instantiate the model prior to any method invocations on the action itself in a similar fashion as your interceptor proposal would insure the model is created before trying to set the parameters on the action. But unfortunately, when I display the action messages which resulted from the form submission to the action, I still get notifications that there were issues with all the form elements. Looking at the tags used in the form itself, the submit tag doesn't dictate any attributes as required. We typically use the key attribute so that it does the localization lookup for the value attribute. Using key also sets the name attribute of the tag but with the non-localization value. When using key='button.search', I end up with the following: {code}<input type='submit' id='form_button_search' name='button.search' value='Search'>{code} Following your developer notifications, that implies I need some object called 'button' inside the model with a property called 'search'. Is the use of the key attribute of a submit tag with a phrase that contains a '.' when the action implements the {{ModelDriven<T>}} interface not possible without generating these warnings? It seems the only viable options here is either A) don't use a '.' in the key names, B) modify the model to contain the hierarchy so use of '.' is possible, or C) don't use the key attribute at all and simply use the value attribute where it contains: {code}value='%{getText('button.search')}'{code} What do you suggest? Lastly, I still can't seem to submit the values for the itemConditionTypes, itemNumberTypes, itemNumbers, and itemSearchTypes arrays and the excel property without the developer notifications even when the model is instantiated upon the creation of the action itself. Are we sure that creating the model with your above proposed solution will 'fix' my test case? was (Author: crancran): One of the reasons why our base action overrides the action errors, message, and field message methods was because it allowed us to simply call {{addActionMessage("some.message");}} without having to wrap the message itself using {{getText}}. That part is what has worked up until the latest builds. What I'll propose to our team is that we'll modify all actions to make use of the {{getText()}} call within each action where we pass a message to the methods that we were originally overriding and remove their overrides from the base action. That should bring the code base in line with the expectations and avoid the {{StringIndexOutOfBoundsException}} error. But what still troubles me with this is related to the developer notifications themselves. I modified the {{ItemSearchAction}} as follows: {code} public ItemSearchAction() { this.criteria = new ItemSearchCriteria(); } {code} Technically, that should instantiate the model prior to any method invocations on the action itself in a similar fashion as your interceptor proposal would insure the model is created before trying to set the parameters on the action. But unfortunately, when I display the action messages which resulted from the form submission to the action, I still get notifications that there were issues with all the form elements. Looking at the tags used in the form itself, the submit tag doesn't dictate any attributes as required. We typically use the key attribute so that it does the localization lookup for the value attribute. Using key also sets the name attribute of the tag but with the non-localization value. When using key='button.search', I end up with the following: {code}<input type='submit' id='form_button_search' name='button.search' value='Search'>{code} Following your developer notifications, that implies I need some object called 'button' inside the model with a property called 'search'. Is the use of the key attribute of a submit tag with a phrase that contains a '.' when the action implements the {{ModelDriven<T>}} interface not possible without generating these warnings? It seems the only viable options here is either A) don't use a '.' in the key names, B) modify the model to contain the hierarchy so use of '.' is possible, or C) don't use the key attribute at all and simply use the value attribute where it contains: {code}value='%{getText('button.search')}'{code} What do you suggest? Lastly, I still can't seem to submit the values for the itemConditionTypes, itemNumberTypes, itemNumbers, and itemSearchTypes arrays without the developer notifications even when the model is instantiated upon the creation of the action itself. Are we sure that creating the model with your above proposed solution will 'fix' my test case? > Submitting form with parameters using brackets while devMode=true yields > StringIndexOutOfBoundsException > -------------------------------------------------------------------------------------------------------- > > Key: WW-4066 > URL: https://issues.apache.org/jira/browse/WW-4066 > Project: Struts 2 > Issue Type: Bug > Components: Core Actions > Affects Versions: 2.3.14 > Reporter: Chris Cranford > Assignee: Lukasz Lenart > Fix For: 2.3.16 > > Attachments: testcase.zip > > > Our BaseAction which extends ActionSupport overrides the addActionMessage() > with the following: > {code:java} > @Override > public void addActionMessage(String message) { > super.addActionMessage(getText(message)); > } > {code} > With the above method in place during devMode=true, the following error stack > trace occurs: > {noformat} > java.lang.StringIndexOutOfBoundsException: String index out of range: -1 > at java.lang.String.substring(String.java:1871) > at > com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:426) > at > com.opensymphony.xwork2.util.LocalizedTextUtil.findText(LocalizedTextUtil.java:362) > at > com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:208) > at > com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:123) > at com.opensymphony.xwork2.ActionSupport.getText(ActionSupport.java:103) > at com.setech.dw.common.web.BaseAction.addActionMessage(BaseAction.java:209) > at > com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:337) > at > com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:241) > {noformat} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira