• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trigger action on combo change

 
kiran chirravuru
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello please help me how to trigger action method in action class on combo change
event in struts 2.0


Regards
Kiran
 
Ankit Garg
Sheriff
Posts: 9528
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you want to make an AJAX request or post back the page when the combo box's value is changed?? Both can be achieved easily with the onchange event of the s:select tag. Try to find a simple tutorial on google...
 
kiran chirravuru
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to perform some operations in the method and post back again to the same page.
How can we do that without using ajax or with using ajax
 
Ankit Garg
Sheriff
Posts: 9528
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's easy to do, in the onchange event of your combo box, you can write this javascript

This will submit the form to the server (of course for this to work, the action attribute of your form must point to the current action)...
 
kiran chirravuru
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit thanks for your response

But actually i need to trigger different action method in the Action class on combo click and trigger different action
method in the Action class when the form is submit


Regards
Kiran
 
Ankit Garg
Sheriff
Posts: 9528
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still not sure whether you want to post back your page or not. If you want to use AJAX to do this, its a completely different thing, if you want to post back the page, its a completely different thing. Basically what exactly do you want to do?? I'll give you two scenarios

1. I have a site which is customized as per regions (like Nokia's site). I have a combo box of region on my site. On the basis of the region selected by the user, I want to send the user to a specific page. I'll post back the page in this case.

2. I have a site which sells products. I have a combo box for countries for the shipping address. On the basis of the country selected by the user, I want to show the total shipping cost of the product. Since in this case all that I want is just a simple calculation, I would use AJAX and not post back the page.

So what exactly do you want?? Your question is too ambiguous if you ask me. Its very tough to help if the goal is not clear...
 
kiran chirravuru
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want actually the first scenario how can i achieve this
 
Ankit Garg
Sheriff
Posts: 9528
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's very simple to do. Suppose on the change of the combo box, you want to submit to a URL like change.action and send the combo box value as a request parameter like comboVal, then you can do this on the onclick event of the combo box
 
kiran chirravuru
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello ankit can you give me your mobile number
 
Ankit Garg
Sheriff
Posts: 9528
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kiran chirravuru wrote:hello ankit can you give me your mobile number

And why would you want that for?? If you have any questions, you can ask it here
 
kiran chirravuru
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ankit
Here is the detailed scenario of my problem

I using struts 2.0 for my web application development . I have two methods in my action class .

From my jsp i want to trigger particular action method in the action class on combo change and different action method in the same
action class when my form is submitted and then i again i want to come back again to same jsp page.

But in the struts-config.xml in the action mapping we can define only one action class and one action method
at a time . So how can i achieve this scenario.

Regards
kiran


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic