Re: how to use Advanced wildcards
Hi Mounir, > It works like a charm now. Wondering why nobody else had a similar > problem maybe the majority is opting for the rest-plugin? Glad you finally worked out. Yeah, I think at rest-plugin, urlrewrite lib, plain wildcard, and so on or probably because it is just not a wellknown feature. BTW, Did you redefined the value of struts.action.extension constant? if yes, what is the current value? Have you ever experienced this behavior on plan redirect action (my guess is that this have no to do with the advanced wildcard mapping) ? Twitter :http://www.twitter.com/m_cucchiara G+ :https://plus.google.com/107903711540963855921 Linkedin:http://www.linkedin.com/in/mauriziocucchiara Maurizio Cucchiara
Re: how to use Advanced wildcards
Hi Maurizio, first let me sincerly thank you for fixing this issue [1]. It works like a charm now. Wondering why nobody else had a similar problem maybe the majority is opting for the rest-plugin? Anyway there's still a small issue regarding the redirectAction though. After calling the parametrised actionName ... display/{1}/{2} ... the URL gets cluttered with the now redundant parameters (action & eventId) and there's still an extra ".action" attached to it as well. like in http://localhost:8080/myEvents/display/edit/150.action?action=edit&eventId=150 That's the kind of URL signature that I'd like to avoid. Is there a way to circumvent this? Thank you again. - Mounir [1] https://issues.apache.org/jira/browse/WW-3747?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel Am 25.01.2012 10:24, schrieb Maurizio Cucchiara: I played with regex pattern and I realized that the example provided in docs doesn't work [1]. Could you file an issue on jira [2]? [1] http://struts.apache.org/2.3.1.2/docs/wildcard-mappings.html [2] https://issues.apache.org/jira/browse/WW Maurizio Cucchiara On 24 January 2012 10:34, Mounir Benzid wrote: Hi, I'm having some trouble figuring out how to use the advanced wildcards feature in struts II. What I'm trying to do looks as follows A) /WEB-INF/pages/myevents/createevent.jsp /display/{action}/{eventId} B) /WEB-INF/pages/myevents/createevent.jsp There 2 issues with this A) As long as I don't use any regexp patterns like [0-9]+ in the configuration struts is happily matching the url against "EventAction" http://blah/event/modify/edit/123 works perfectly fine. Though in the above example the regexp in {eventId:[0-9]+} seems to prevent this. http://blah/event/modify/edit/123 doesn't get resovled B) I'm not able to use the same mechanics to redirectAction to another action (say from A) to B). I was hoping that "action" and "eventId" are automagically populated through the value stack in A) and then then matching action B is called. These are my constants btw: thanks a lot! - Mounir - 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: Testing with StrutsTestCase in a Tiles application - NullPointerException
For future reference, I found the answer in http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/ Basically, you need to initialize the tiles listener. As I already used setupBeforeInitDispatcher to set the applicationContext attribute, I added the code there (inside the if(tilesApplication) segment): /** Overrides the previous in order to skip applicationContext assignment: context is @autowired * @see org.apache.struts2.StrutsSpringTestCase#setupBeforeInitDispatcher() **/ @Override protected void setupBeforeInitDispatcher() throws Exception { //init context servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, applicationContext); if(tilesApplication){ servletContext.addInitParameter(BasicTilesContainer.DEFINITIONS_CONFIG, "WEB-INF/tiles.xml"); final StrutsTilesListener tilesListener = new StrutsTilesListener(); final ServletContextEvent event = new ServletContextEvent(servletContext); tilesListener.contextInitialized(event); } } Miguel Almeida On Fri, 2012-01-27 at 17:35 +, Miguel Almeida wrote: > Hi there, > > I trying to test an application with the help of StrutsTestCase (a class > that extends from StrutsSpringTestCase, to be more precise). > StrutsTestCase (which is in the struts junit plugin) involves proxied > actions to make tests more light. > > I have used the same method in another application that doesn't have > tiles successfully. Here, however, I am running into an exception when > running the actionProxy.execute() : > > > java.lang.NullPointerException > at > org.apache.struts2.views.tiles.TilesResult.doExecute(TilesResult.java:105) > at > org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186) > > > I found a user that described the problem very well on stackOverflow: > http://stackoverflow.com/questions/5823709/npe-in-strutstestcase-after-enabling-tiles > > There is also a 2008 question on the mailing list > (http://www.mail-archive.com/user@struts.apache.org/msg77582.html ). > Petrelli tried to answer, but no solution was posted. > > From these resources, do you know what the problem might be and if it is > possible to use StrutsTestCase to test an application that has Tiles > enabled through the StrutsTilesListener? > > > Cheers, > > Miguel Almeida >