S2 Losing Session in interceptor
Hey there, I have built an interceptor to store and retrieve ActionErrors using the session for redirect-action results. The weird thing is I seem to lose the values the first time it is run through. private static final String KEY="org.etc..."; public String intercept(ActionInvocation actionInvocation) throws Exception { ActionContext actionContext = actionInvocation.getInvocationContext(); Map session = actionContext.getSession(); if (session.containsKey(KEY)) { Collection actionErrors = (Collection) session.remove(KEY); if (actionInvocation.getAction() instanceof ValidationAware) { ((ValidationAware) actionInvocation.getAction()).setActionErrors(actionErrors); } } String result = actionInvocation.invoke(); if (actionInvocation.getResult() instanceof ServletActionRedirectResult && actionInvocation.getAction() instanceof ValidationAware) { if (action.hasActionErrors()) { session.put(KEY, action.getActionErrors()); } } return result; } So say I have an invalid session (or timeout). I catch the exception and then chain to an action that will build the error message and redirect back to the login page. When I step through the interceptor it will be fired twice. The first time it is being fired by the action that built the error message. Everything looks ok and it adds the action errors to the session. The second time is for the action that displays the login page but when that interceptor is fired, the session that is returned is empty. This only happens the first time I do this, if I continue to throw exceptions everything works as I had expected. All help is appreciated, Jonathan -- View this message in context: http://www.nabble.com/S2-Losing-Session-in-interceptor-tp17063809p17063809.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Struts 2 & Dynamic Validation results
I am try to migrate an app from struts 1 -> 2 I am trying to do basic validation on a form. Fields a and b are required. in the resource bundle I have errors.required={0} is required. How do you put dynamic values into these messages so that it shows up: [blah blah blah] is required. [Some other field] is required. Thanks in advance, Jonathan -- View this message in context: http://www.nabble.com/Struts-2---Dynamic-Validation-results-tp16809171p16809171.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re:
I can't use ${x} because I am not always looking for x. The basics of what I am doing is building a tile that will print out any property in my action/form. So I have some JSP #1 that says ... And for each definition it inserts JSP #2 that looks like... I just can't figure out how to write that property tag. I need it to show the value of the property passed in. As I said if I could use runtime expressions I could just write So I can't use the: Or use with either the "bare" JSP 2.0+ notation or via . It would work if I knew to write in 'x' for the currentProperty, but since I have to evaluate property to get x it doesn't work. Any other thoughts? Thanks, Jonathan newton.dave wrote: > > --- JRD <[EMAIL PROTECTED]> wrote: >> I have a .JSP where I want to write out the values of them dynamically. >> >> >> >> >> How do I write a using currentProperty that would >> result it showing my actions value (1). >> >> If I were using runtime expressions I would write it like >> >> but that is verboten by the tld. > > Why wouldn't you just use ${x} (in a JSP 2.0+ container) or value="x"/>? > > If you're dead-set on using the "currentProperty" thing use > ${currentProperty} or . > > Or use with either the "bare" > JSP > 2.0+ notation or via . > > Dave > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/%3Cs%3Aproperty-with-dynamic-values-tp16711862p16722511.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
user@struts.apache.org
Hi there, I have an action/form that contains properties x, y, & z with values 1, 2, & 3. I have a .JSP where I want to write out the values of them dynamically. How do I write a using currentProperty that would result it showing my actions value (1). If I were using runtime expressions I would write it like but that is verboten by the tld. All help is appreciated, Jonathan -- View this message in context: http://www.nabble.com/%3Cs%3Aproperty-with-dynamic-values-tp16711862p16711862.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]