• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to invoke method based on radio button select

 
sahithi mohan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

In JSP , two radio buttons are there. In action class have two methods .if select first radio button ,then submit it, it has to execute first method. if select second radio button ,it has to execute second method.

I wrote code in JSP,


how to write in strut.xml and action class in strut 2
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't know what you are doing in the method's as per my understanding here we can solve it in two ways
1) Identify which radio button is selected in your action call and do process appropriately.
2) write two action classes and Identify which action to be called depending on radio button using javascript.
 
sahithi mohan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Consider First one, By using java script I can identify the which radio button i selected.suppose i selected save radio button.In java script ,using get value of that button.hence how to proceed . how do i call method

 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
sahithi mohan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thax Mohan Rao. I knew that way .I need to use single action class ,it contains two method . it has call based on radio selected. how do i implement.
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, you are calling same action class whatever the radio button was selected then you must know that is the which radio button was selected in the action class. Based on the condition call the appropriate action. I hope this helps.
 
sahithi mohan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mohan Rao.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic