aspose file tools*
The moose likes Struts and the fly likes Including Actions in various pages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Including Actions in various pages" Watch "Including Actions in various pages" New topic
Author

Including Actions in various pages

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

My app has a few pages that don't require a login. But I want to show the login options on each of those pages.

If I had a form that contained fields for logging in a user, and I want to include that on any page when the user is not logged in, how would I go about defining the input parameters in the struts-config.xml file because after I have included that loginblock.jsp on welcome.jsp, the input would be "welcome.jsp" however, if I included it on bla.jsp wouldn't the input parameter change?


GenRocket - Experts at Building Test Data
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

One possible solution:
Make it so the loginblock is not its own form but a part of each page's form. I assume this jsp(f) is a static include.

You would then need a parent to the ActionForms to handle the new fields and a parent class to the Actions to hold a method that does the login functionality. The only other thing needed is a check in each Action to see which button was clicked - if it was the Login button then call the parent Action's method.


A good workman is known by his tools.
Sunil Manheri
Ranch Hand

Joined: Jul 07, 2004
Posts: 32
The best solution for your problem is "using tiles". Create a page with the login form and include in whatever pages you needed. So on clicking the login button will call the login action.
Hope this will solve your problem.


TechMindViews - Technical Notes
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Including Actions in various pages