• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

How to call a method from an action class using Struts 2.

 
Ranch Hand
Posts: 477
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have a situation where I have to call an action class , when there is a change in the values of a dropdown box that im implementing using struts 2 tags , im trying to use javascript for this and need to pass a variable to the function being called > Could anyone please help me with an example .Thanks.
 
Ranch Hand
Posts: 247
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are various option you can use for Ajax Calling .
like dwr ,Json ,jQuery..

but there is one more option to call action without using it.

Call a Javascript method on change event of dropdown and submit your form there.


Best Regards
Mohd Raza
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I intend to use Javascript , could you please provide an example. Thanks
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bounce! Any help would be appreciated.
 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vic Hood wrote:Hi All,
I have a situation where I have to call an action class , when there is a change in the values of a dropdown box that im implementing using struts 2 tags , im trying to use javascript for this and need to pass a variable to the function being called > Could anyone please help me with an example .Thanks.



Try this,
In your javascript method you will have
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im sorry, but i couldnt understand your example.Could you please explain it further?
 
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
post your code Vic .. it will help us help u....
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Robin John wrote:post your code Vic .. it will help us help u....


Thanks for replying Robin. Well Im hoping to load a list on the basis of a parameter passed through the dropdown. The code for the dropdown and the javascript that i have currently written but does not work is as follows



How do i go about writing the Javascript function to acheive what I need? Thanks
 
Robin John
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Vic, sorry for the late reply, was stuck on something else..... look at the below code.. it should work... (I have not tested it.. please test it)



you can use "actionName!methodName.action" in the URL to go to "methodName" method.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I Am working on struts 2 to be deployed on IBM portal server. Need to use ajax. when a textfield is populated an action has to be invoked. based on the result a dropdown has to be enabled or disabled. I have tried the other samples provided in the thread but with no result. Need help asap. Thanks in advance.
reply
    Bookmark Topic Watch Topic
  • New Topic