This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes How to Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to "enable/disable" radio button in struts2 on click of check box" Watch "How to "enable/disable" radio button in struts2 on click of check box" New topic
Author

How to "enable/disable" radio button in struts2 on click of check box

Jyothsna Panchagnula
Ranch Hand

Joined: Jul 11, 2005
Posts: 113
Hi all,

I have the following code in my jsp.


My java script code


When the page is executed the radio button is not disabled as it contains a list.
I also tried writing a sample html page and created check box and radio button.
I could disable radio button uponclick of checkbox.But I am not able to ahcieve
the same using <s:radio> tag in struts2.
As <s:radio >tag containst list , we cant disable the radio button ?

any inputs on this will be highly appreciated.

thanks,
Jyothsna


David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Examining the HTML emitted by the S2 tags would be a good idea...

I mean, wouldn't that be the *first* thing you'd want to do when some JavaScript doesn't appear to be working the way you'd expect?
Jyothsna Panchagnula
Ranch Hand

Joined: Jul 11, 2005
Posts: 113
Hi David,

when I checked the generated html in the view page source ,
The code

is changed to


Since this is a list I guess that there is no way to call the java script funciton
But how do I disable the radio button depending on the checkbox check in struts2

-Jyothsna
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You can *call* a JavaScript function, you just need to implement it in such a way that it works.

There are a number of alternatives, including modifying/extending the theme. I'd probably explore an approach that creates the list on the server side so its values can be used both in the S2 tag and by JavaScript.
Jyothsna Panchagnula
Ranch Hand

Joined: Jul 11, 2005
Posts: 113
Hi David,

I agree with you. In some of the pages I am following the same approach as you have mentioned.
But here I need to first select the checkbox , once selected then I need to display the radio button , then depending on the selection of radio button I need to display the data populated from the database.

Also I am new to ajax , I am wondering how I have to implement using ajax in struts2.


thanks
Jyothsna
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'd probably start by reading the S2 Ajax documentation, but be aware that the Dojo tags have been deprecated. It may be easiest to just use whichever JavaScript library/framework you're most comfortable with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to "enable/disable" radio button in struts2 on click of check box
 
Similar Threads
unable to do validation for select in struts2
Struts2 variable inside javascript
Problem with Struts2 validation
I want to implement editable autocompleter in struts2 using jquery.
Struts2 <s:form> includes empty <td>