This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
 
Don't get me started about those stupid light bulbs.
 
subject: How to use Actions inside Javascript menus???
 
Similar Threads
Attempted a bean operation on a null object.
Problem with html:link forward="" tag
howto make html:link dynamic select item of map ?
Problem forwarding to another page using struts.
<html:link/> not working with inbuilt ForwardAction class