Re: Setter in action triggers twice. Bug?
2010/4/20 Francisco José Aquino García fj.aqu...@gmail.com: Where are the sources for xwork-core-2.1.6 then? Here you have the latest version svn.apache.org/viewvc/struts/struts2/trunk/ The old can be found here http://svn.opensymphony.com/fisheye/browse/xwork Regards -- Łukasz http://www.lenart.org.pl/ Kapituła Javarsovia 2010 http://javarsovia.pl - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Setter in action triggers twice. Bug?
Nice, that 'merge' parameter. I'm still using Struts2 2.1.6 and had already stumbled on this. Worked around it using params.excludeParams on the statically-parameterized actions to filter out the static params. Browsing the latest distribution I've noticed that it bundles xwork-core-2.1.6.jar but the latest version listed on the XWork home page is 2.1.5... has Struts2 forked xwork-core-2.1.6 from the official XWork? 2009/7/17 Musachy Barroso musa...@gmail.com We cant change it because it would break backward compatibility. I added a merge parameter to the static parameters interceptor(defaults to true): http://jira.opensymphony.com/browse/XW-709 fixed in xwork trunk. Thanks for reporting! musachy On Fri, Jul 17, 2009 at 12:02 PM, Dale Newfieldd...@newfield.org wrote: Musachy Barroso wrote: Ok I see it now. The staticparams interceptor adds the params to the request params map, so that would explain why it is called again. We could add a setting to the result to prevent this if needed. I would argue that each of {staticP,actionMappingP,p}arams should both set the discovered and acceptable params on the action and add the discovered and acceptable params to the map so that ParameterAware actions can be handed the full set of parameters detected by the interceptors. It sounds like params is setting both those discovered by it and those that already managed to get into that map before it runs. This shouldn't be a big deal as setting a parameter should be idempotent, but I would agree that this is a bug. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Hey you! Would you help me to carry the stone? Pink Floyd - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Setter in action triggers twice. Bug?
2010/3/17 Francisco José Aquino García fj.aqu...@gmail.com: Browsing the latest distribution I've noticed that it bundles xwork-core-2.1.6.jar but the latest version listed on the XWork home page is 2.1.5... has Struts2 forked xwork-core-2.1.6 from the official XWork? Yap, XWork is part of Struts 2 and was moved to Apache. Regards -- Łukasz http://www.lenart.org.pl/ Kapituła Javarsovia 2010 http://javarsovia.pl - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Setter in action triggers twice. Bug?
Ok, this is all great, but problem still is not solved. You can see configs provided @ war. I will put this simple: My app`s config is taken from struts-blank, so its minimal, and there are no explicit changes in interceptor stack for any of actions. Why this crap happens then? I really dont care what calls who - what matters here - why this even happens on such minimalistic configuration?
Re: Setter in action triggers twice. Bug?
you are confusing static parameters with request parameters. You *do not* need to add param to your action mapping to get the parameters bound the class fields. You add param to your action mapping to inject things into your action, IoC style, but is is not needed for request parameters. So if you have something like: param name=cmd/param and you call the action like /action?cmd=aaa, then setCmd(...) will be called 2 times, one for the static param(bbb), and another time for the request param (aaa). musachy On Fri, Jul 17, 2009 at 1:23 AM, Ritvars Rundzānsrrundz...@gmail.com wrote: Ok, this is all great, but problem still is not solved. You can see configs provided @ war. I will put this simple: My app`s config is taken from struts-blank, so its minimal, and there are no explicit changes in interceptor stack for any of actions. Why this crap happens then? I really dont care what calls who - what matters here - why this even happens on such minimalistic configuration? -- Hey you! Would you help me to carry the stone? Pink Floyd - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Setter in action triggers twice. Bug?
action name=person-*-* class=example.Person param name=cmd{1}/param param name=id{2}/param resultjsp/abc.jsp/result /action You *do not* need to add param to your action mapping to get the parameters bound the class fields. I understand that. As you can see, example request (/person-aaa-bbb?dum=ccc) gives 1 request param (classical meaning, bound automaticaly) , and extracts 2 params from URI part before *?* (THIS, I GUESS, *CANT BE BINDED* AUTOMATICALY). I DO NOT pass cmd and id as request params (classical meaning: ?param=val) in this example. But they are passed, thats true. Ok, write me then action mapping , that urls like /person-aaa-bbb?dum=ccc maps to action PersonAction, and sets 3 params - cmd, id and dum.
Re: Setter in action triggers twice. Bug?
Ok I see it now. The staticparams interceptor adds the params to the request params map, so that would explain why it is called again. We could add a setting to the result to prevent this if needed. musachy On Fri, Jul 17, 2009 at 10:18 AM, Ritvars Rundzānsrrundz...@gmail.com wrote: action name=person-*-* class=example.Person param name=cmd{1}/param param name=id{2}/param resultjsp/abc.jsp/result /action You *do not* need to add param to your action mapping to get the parameters bound the class fields. I understand that. As you can see, example request (/person-aaa-bbb?dum=ccc) gives 1 request param (classical meaning, bound automaticaly) , and extracts 2 params from URI part before *?* (THIS, I GUESS, *CANT BE BINDED* AUTOMATICALY). I DO NOT pass cmd and id as request params (classical meaning: ?param=val) in this example. But they are passed, thats true. Ok, write me then action mapping , that urls like /person-aaa-bbb?dum=ccc maps to action PersonAction, and sets 3 params - cmd, id and dum. -- Hey you! Would you help me to carry the stone? Pink Floyd - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Setter in action triggers twice. Bug?
Musachy Barroso wrote: Ok I see it now. The staticparams interceptor adds the params to the request params map, so that would explain why it is called again. We could add a setting to the result to prevent this if needed. I would argue that each of {staticP,actionMappingP,p}arams should both set the discovered and acceptable params on the action and add the discovered and acceptable params to the map so that ParameterAware actions can be handed the full set of parameters detected by the interceptors. It sounds like params is setting both those discovered by it and those that already managed to get into that map before it runs. This shouldn't be a big deal as setting a parameter should be idempotent, but I would agree that this is a bug. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Setter in action triggers twice. Bug?
We cant change it because it would break backward compatibility. I added a merge parameter to the static parameters interceptor(defaults to true): http://jira.opensymphony.com/browse/XW-709 fixed in xwork trunk. Thanks for reporting! musachy On Fri, Jul 17, 2009 at 12:02 PM, Dale Newfieldd...@newfield.org wrote: Musachy Barroso wrote: Ok I see it now. The staticparams interceptor adds the params to the request params map, so that would explain why it is called again. We could add a setting to the result to prevent this if needed. I would argue that each of {staticP,actionMappingP,p}arams should both set the discovered and acceptable params on the action and add the discovered and acceptable params to the map so that ParameterAware actions can be handed the full set of parameters detected by the interceptors. It sounds like params is setting both those discovered by it and those that already managed to get into that map before it runs. This shouldn't be a big deal as setting a parameter should be idempotent, but I would agree that this is a bug. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- Hey you! Would you help me to carry the stone? Pink Floyd - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Setter in action triggers twice. Bug?
can you put a breakpoint in the setter and see where is it called from? (both times) musachy On Thu, Jul 16, 2009 at 8:08 AM, Ritvars Rundzānsrrundz...@gmail.com wrote: Hi! I am wondering, why setters for cmd and id fields @ my Person action (see below) is called twice. For example, when browser requests /person-aaa-bbb?dum=ccc , this gets stdout-ed : example.per...@113981b 18061339 setCmd ]aaa[ setId ]bbb[ setCmd ]aaa[ setDum ]ccc[ setId ]bbb[ execute I know setter is just a setter, but this thing is really annoying me :) - definately this kind of behaviour is undesirable. Any thoughts? 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.enable.DynamicMethodInvocation value=false / constant name=struts.devMode value=false / package name=default namespace=/ extends=struts-default action name=person-*-* class=example.Person param name=cmd{1}/param param name=id{2}/param resultjsp/abc.jsp/result /action action name=index result type=redirectAction param name=actionNameHelloWorld/param param name=namespace/example/param /result /action /package /struts --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- Action: --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- package example; import com.opensymphony.xwork2.ActionSupport; @SuppressWarnings(serial) public class Person extends ActionSupport { // private String cmd; private String id; private String dum; // public String execute() throws Exception { System.out.println( execute ); return SUCCESS; } public Person() { System.out.println( this + + this.hashCode() ); } // public String getCmd() { return cmd; } public void setCmd(String cmd) { System.out.println( setCmd ] + cmd + [ ); this.cmd = cmd; } public String getId() { return id; } public void setId(String id) { System.out.println( setId ] + id+ [ ); this.id = id; } public String getDum() { return dum; } public void setDum(String dum) { System.out.println( setDum ] + dum+ [ ); this.dum = dum; } } --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- I uploaded war, so you can see this mystic stuff for yourself: With no jars (grab them from struts2-blank app), 4kb: http://maiss.02.lv/faili/batman/s2test_nolibs.war Working version, 4mb: http://maiss.02.lv/faili/batman/s2test.war -- Hey you! Would you help me to carry the stone? Pink Floyd - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Setter in action triggers twice. Bug?
I put BP @ setCmd. 1st hit: Daemon Thread [http-8080-2] (Suspended (breakpoint at line 28 in Person)) Person.setCmd(String) line: 28 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object...) line: 597 OgnlRuntime.invokeMethod(Object, Method, Object[]) line: 517 OgnlRuntime.callAppropriateMethod(OgnlContext, Object, Object, String, String, List, Object[]) line: 812 OgnlRuntime.setMethodValue(OgnlContext, Object, String, Object, boolean) line: 964 ObjectAccessor(ObjectPropertyAccessor).setPossibleProperty(Map, Object, String, Object) line: 75 ObjectAccessor(ObjectPropertyAccessor).setProperty(Map, Object, Object, Object) line: 131 ObjectAccessor.setProperty(Map, Object, Object, Object) line: 28 OgnlRuntime.setProperty(OgnlContext, Object, Object, Object) line: 1656 CompoundRootAccessor.setProperty(Map, Object, Object, Object) line: 50 OgnlRuntime.setProperty(OgnlContext, Object, Object, Object) line: 1656 ASTProperty.setValueBody(OgnlContext, Object, Object) line: 101 ASTProperty(SimpleNode).evaluateSetValueBody(OgnlContext, Object, Object) line: 177 ASTProperty(SimpleNode).setValue(OgnlContext, Object, Object) line: 246 Ognl.setValue(Object, Map, Object, Object) line: 476 OgnlUtil.setValue(String, MapString,Object, Object, Object) line: 192 OgnlValueStack.setValue(String, Object, boolean) line: 155 OgnlValueStack.setValue(String, Object) line: 143 StaticParametersInterceptor.intercept(ActionInvocation) line: 129 DefaultActionInvocation.invoke() line: 236 CheckboxInterceptor.intercept(ActionInvocation) line: 93 DefaultActionInvocation.invoke() line: 236 FileUploadInterceptor.intercept(ActionInvocation) line: 235 DefaultActionInvocation.invoke() line: 236 ModelDrivenInterceptor.intercept(ActionInvocation) line: 89 DefaultActionInvocation.invoke() line: 236 ScopedModelDrivenInterceptor.intercept(ActionInvocation) line: 128 DefaultActionInvocation.invoke() line: 236 ProfilingActivationInterceptor.intercept(ActionInvocation) line: 104 DefaultActionInvocation.invoke() line: 236 DebuggingInterceptor.intercept(ActionInvocation) line: 267 DefaultActionInvocation.invoke() line: 236 ChainingInterceptor.intercept(ActionInvocation) line: 126 DefaultActionInvocation.invoke() line: 236 PrepareInterceptor.doIntercept(ActionInvocation) line: 138 PrepareInterceptor(MethodFilterInterceptor).intercept(ActionInvocation) line: 87 DefaultActionInvocation.invoke() line: 236 I18nInterceptor.intercept(ActionInvocation) line: 148 DefaultActionInvocation.invoke() line: 236 ServletConfigInterceptor.intercept(ActionInvocation) line: 164 DefaultActionInvocation.invoke() line: 236 AliasInterceptor.intercept(ActionInvocation) line: 128 DefaultActionInvocation.invoke() line: 236 ExceptionMappingInterceptor.intercept(ActionInvocation) line: 176 DefaultActionInvocation.invoke() line: 236 StrutsActionProxy.execute() line: 52 Dispatcher.serviceAction(HttpServletRequest, HttpServletResponse, ServletContext, ActionMapping) line: 468 ExecuteOperations.executeAction(HttpServletRequest, HttpServletResponse, ActionMapping) line: 77 StrutsPrepareAndExecuteFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 76 ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 235 ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206 StandardWrapperValve.invoke(Request, Response) line: 233 StandardContextValve.invoke(Request, Response) line: 191 StandardHostValve.invoke(Request, Response) line: 128 ErrorReportValve.invoke(Request, Response) line: 102 StandardEngineValve.invoke(Request, Response) line: 109 CoyoteAdapter.service(Request, Response) line: 286 Http11Processor.process(Socket) line: 845 Http11Protocol$Http11ConnectionHandler.process(Socket) line: 583 JIoEndpoint$Worker.run() line: 447 Thread.run() line: 619 --- 2nd one: Daemon Thread [http-8080-2] (Suspended (breakpoint at line 28 in Person)) Person.setCmd(String) line: 28 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object...) line: 597 OgnlRuntime.invokeMethod(Object,
Re: Setter in action triggers twice. Bug?
#1 is from the static param interceptor, so you have that set up somewhere, and the second one is from the normal request parameter (params interceptor) On Thu, Jul 16, 2009 at 10:35 AM, Ritvars Rundzānsrrundz...@gmail.com wrote: I put BP @ setCmd. 1st hit: Daemon Thread [http-8080-2] (Suspended (breakpoint at line 28 in Person)) Person.setCmd(String) line: 28 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object...) line: 597 OgnlRuntime.invokeMethod(Object, Method, Object[]) line: 517 OgnlRuntime.callAppropriateMethod(OgnlContext, Object, Object, String, String, List, Object[]) line: 812 OgnlRuntime.setMethodValue(OgnlContext, Object, String, Object, boolean) line: 964 ObjectAccessor(ObjectPropertyAccessor).setPossibleProperty(Map, Object, String, Object) line: 75 ObjectAccessor(ObjectPropertyAccessor).setProperty(Map, Object, Object, Object) line: 131 ObjectAccessor.setProperty(Map, Object, Object, Object) line: 28 OgnlRuntime.setProperty(OgnlContext, Object, Object, Object) line: 1656 CompoundRootAccessor.setProperty(Map, Object, Object, Object) line: 50 OgnlRuntime.setProperty(OgnlContext, Object, Object, Object) line: 1656 ASTProperty.setValueBody(OgnlContext, Object, Object) line: 101 ASTProperty(SimpleNode).evaluateSetValueBody(OgnlContext, Object, Object) line: 177 ASTProperty(SimpleNode).setValue(OgnlContext, Object, Object) line: 246 Ognl.setValue(Object, Map, Object, Object) line: 476 OgnlUtil.setValue(String, MapString,Object, Object, Object) line: 192 OgnlValueStack.setValue(String, Object, boolean) line: 155 OgnlValueStack.setValue(String, Object) line: 143 StaticParametersInterceptor.intercept(ActionInvocation) line: 129 DefaultActionInvocation.invoke() line: 236 CheckboxInterceptor.intercept(ActionInvocation) line: 93 DefaultActionInvocation.invoke() line: 236 FileUploadInterceptor.intercept(ActionInvocation) line: 235 DefaultActionInvocation.invoke() line: 236 ModelDrivenInterceptor.intercept(ActionInvocation) line: 89 DefaultActionInvocation.invoke() line: 236 ScopedModelDrivenInterceptor.intercept(ActionInvocation) line: 128 DefaultActionInvocation.invoke() line: 236 ProfilingActivationInterceptor.intercept(ActionInvocation) line: 104 DefaultActionInvocation.invoke() line: 236 DebuggingInterceptor.intercept(ActionInvocation) line: 267 DefaultActionInvocation.invoke() line: 236 ChainingInterceptor.intercept(ActionInvocation) line: 126 DefaultActionInvocation.invoke() line: 236 PrepareInterceptor.doIntercept(ActionInvocation) line: 138 PrepareInterceptor(MethodFilterInterceptor).intercept(ActionInvocation) line: 87 DefaultActionInvocation.invoke() line: 236 I18nInterceptor.intercept(ActionInvocation) line: 148 DefaultActionInvocation.invoke() line: 236 ServletConfigInterceptor.intercept(ActionInvocation) line: 164 DefaultActionInvocation.invoke() line: 236 AliasInterceptor.intercept(ActionInvocation) line: 128 DefaultActionInvocation.invoke() line: 236 ExceptionMappingInterceptor.intercept(ActionInvocation) line: 176 DefaultActionInvocation.invoke() line: 236 StrutsActionProxy.execute() line: 52 Dispatcher.serviceAction(HttpServletRequest, HttpServletResponse, ServletContext, ActionMapping) line: 468 ExecuteOperations.executeAction(HttpServletRequest, HttpServletResponse, ActionMapping) line: 77 StrutsPrepareAndExecuteFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 76 ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 235 ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 206 StandardWrapperValve.invoke(Request, Response) line: 233 StandardContextValve.invoke(Request, Response) line: 191 StandardHostValve.invoke(Request, Response) line: 128 ErrorReportValve.invoke(Request, Response) line: 102 StandardEngineValve.invoke(Request, Response) line: 109 CoyoteAdapter.service(Request, Response) line: 286 Http11Processor.process(Socket) line: 845 Http11Protocol$Http11ConnectionHandler.process(Socket) line: 583 JIoEndpoint$Worker.run() line: 447 Thread.run() line: 619 --- 2nd one: Daemon Thread [http-8080-2] (Suspended (breakpoint at line 28 in Person)) Person.setCmd(String) line: 28 NativeMethodAccessorImpl.invoke0(Method, Object,
Re: Setter in action triggers twice. Bug?
Look carefully! As you can see, BOTH setters origin from static params interceptor (1st: line 129, 2nd - line 148). And i do not have set it up somewhere - look @ war. Config is as simple as possible.
Re: Setter in action triggers twice. Bug?
uh? This is from the 2nd stack: ParametersInterceptor.doIntercept(ActionInvocation) line: 187 ParametersInterceptor(MethodFilterInterceptor).intercept(ActionInvocation) musachy On Thu, Jul 16, 2009 at 1:33 PM, Ritvars Rundzānsrrundz...@gmail.com wrote: Look carefully! As you can see, BOTH setters origin from static params interceptor (1st: line 129, 2nd - line 148). And i do not have set it up somewhere - look @ war. Config is as simple as possible. -- Hey you! Would you help me to carry the stone? Pink Floyd - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Setter in action triggers twice. Bug?
Yes, 2nd one contains ParametersInterceptor call, but both of them contains StaticParametersInterceptor call. You mentioned, that static param interceptor, so you have that set up somewhere. There are no explicitly defined interceptors @ my-super-app. Ok, whatewer, this is irrelevant. Just deploy war and see it all for yourself. Sources are included, so feel free to compile them for yourself, if u think this is neccessary.
Re: Setter in action triggers twice. Bug?
Ritvars Rundza-ns wrote: Yes, 2nd one contains ParametersInterceptor call, but both of them contains StaticParametersInterceptor call. You mentioned, that static param interceptor, so you have that set up somewhere. There are no explicitly defined interceptors @ my-super-app. The default stack contains the static params interceptor. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org