• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Action not getting invoked in struts 2

 
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm migrating an app from Struts 1 to Struts 2 and am missing some basic concepts. For some reason, my desired action in my class is not getting invoked. I have this servlet ...


public class AccountsAction extends ActionSupport implements ServletRequestAware, ValidationAware, Validateable {

...

public String pcFlow() {
logger.info("Entering pc flow action.");
return _redirect();
} // pcFlow

...
}


and this defined in my struts.xml file ...


<package name="myapp" namespace="/" extends="struts-default">

<default-action-ref name="index" />
<action name="pcFlow" class="com.myco.regui.struts.accounts.AccountsAction">
<result name="success">jsp/pcredirect.jsp</result>
<result name="input">jsp/start.jsp</result>
<result name="error">jsp/start.jsp</result>
</action>

...
</package>


Although the "validate" method in the above class is getting called properly, the desired action "pcFlow" is not getting invoked, which I know because nothing gets logged from teh debug statement. Any ideas what basic thing I'm missing?

Thanks, - Dave
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags. (Also, minor nit--you don't have a servlet, you have an action.)

How would S2 know to call that method? The default method is execute(). If you want to call a specific, non-default method then you need to specify that in the action mapping via the "method" attribute.
 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. When I added the "method" attribute to the action tag, everything worked. -
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just as a heads-up, too--some method names are meaningful to the validation and workflow interceptors and may produce unexpected behaviour if you use one of them by accident.
 
reply
    Bookmark Topic Watch Topic
  • New Topic