aspose file tools*
The moose likes Struts and the fly likes How to use Actions inside Javascript menus??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to use Actions inside Javascript menus???" Watch "How to use Actions inside Javascript menus???" New topic
Author

How to use Actions inside Javascript menus???

Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
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.


********Deserve Before You Desire********
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to use Actions inside Javascript menus???