• 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

Call Actions in a different module from default module

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

I've written a struts application which I've split into a number of
modules, i.e user, account etc.

I want to have a login form on the home page (within default module) to allow the user to login, however all the user management actions e.g createUserAction, loginAction, logoffAction and corresponding forms are defined in another module in the struts-config-user.xml config file.

I've created a home.jsp page which contains a form, using the
html:form and html:text tags, and have included the necessary taglibs.

I have set the form action to "/user/login", which corresponds to the
"/login" action within the struts-config-user.xml.

However when I run the application I'm getting the following error :-

javax.servlet.jsp.JspException: Cannot retrieve mapping for action /user/login
at org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:810)
at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:506)
at org.apache.jsp.Home_jsp._jspx_meth_html_form_0(org.apache.jsp.Home_jsp:169)
at org.apache.jsp.Home_jsp._jspx_meth_html_html_0(org.apache.jsp.Home_jsp:124)

which seems to imply that the jsp page can not see the action mapping
defined in a different module.

Therefore is it possible to use an action in a different module from
the default module. If not is there any way I could replicate this
functionality by duplicating the form bean?

Any help would be gratefully received.

Thanks

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

You might want to look at the Struts SwitchAction.

Cheers
Steve
[ November 01, 2005: Message edited by: Steve McCann ]
 
Jason Moors
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Steve,

Can I use the SwitchAction from a HTML Form?, all the examples seem to show the SwitchAction as a GlobalForward.

I want to have a HTML form on the homepage which POSTS the login parameters to an action in another module.

I experiemented with the SwitchAction in the past and had a problem with the STRUTS FORM bean not being found.

Thanks

Jason.
 
Steve McCann
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jason

Looking in my trusty Struts Complete Reference book ...
You set up the SwitchAction in the struts-config.xml and specify the module you want to switch to and the page within it as part of your URL:

http://your.site.com/AppName/SwitchModule.do?prefix=/Mod&page=/page

where Mod is the module you want to switch to, and page is the jsp or action you want to go to inside that module.

You should be able to specify the above URL in your form's action parameter.

Steve
[ November 02, 2005: Message edited by: Steve McCann ]
 
Jason Moors
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Steve,

The problem was not in fact the switching of the module, but rather the html:form tag lookup! The FormTag does a lookup for the action and the form bean, and as the action is in a diffent module config file the lookup was failing.

I've changed the form on the login page to use HTML form syntax, instead of the html:form tag, and used the SwitchAction as you described.

Thanks for the help!

Jason.
 
The only thing that kept the leeches off of me was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic