Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use Actions inside Javascript menus???

 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am Converting my old web application to Struts (MVC) based framework. Now problem is that in my older application I have used Javascript file for Menu Display on my WebPage & so the URL of all the pages corresponding to particular menu items were Hard Coded into it like:-"menu1.url=login.jsp". But Now I am using Struts framework & so all the requests are now going through controller. Now there is Login.jsp page in my application & when user clicks on "Home" menu he should be forwarded to "Login.jsp" page. How should I do that? Also my "Login.jsp" page displaying some products from Database. When I am writing in my jsp file as before "menu1.url=Login.jsp" Then it is giving me error like:-
========
javax.servlet.ServletException: Cannot find bean featuredItemsForm in any scopeorg.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848).......
========
Where "featuredItemsForm " is the id of the bean I am using for displaying records on my page through Actionform & action class.
I have another page "Index.jsp" & I am using <html:link> as follows:-
"<html:link action="/featuredItems">show Login Page</html:link>"
Then It gives me expected output. But How same thing I should do with Javascript menus???
Please tell me.
Thanx in advance.
Prash.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Replace the links in your javaScript menu with calls to Struts actions. If you've followed the default mapping for the Struts ActionServlet, you call a Struts action by appending .do to the end of it. So, to link to your featured Items page, the URL is featuredItems.do. If you have an action that prepares the login page, show the login page with the URL prepareLogin.do.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic