This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Including Actions in various pages

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sunil Manheri
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic