JSP Button Selection

I am trying to find out which of two radio buttons has been selected in the accurevSettings.jsp file.
I have provided a code snippet in the attached file.

The two radio buttons are defined as follows:

<props:radioButtonProperty id="radioButton_promoteSeparately"  name="radioButton_promoteType"  value="PromoteSeparately" />
<props:radioButtonProperty id="radioButton_promoteTogether"     name="radioButton_promoteType"  value="promoteTogether" />



The problems is that the following if statement always evaluates to true.

<c:set var="onclick">

 <c:if test="${propertiesBean.properties['radioButton_promoteSeparately'] == this.checked}">

$('textbox1').disabled = !this.checked;

</c:if>
</c:set>



The line ${propertiesBean.properties['radioButton_promoteSeparately'] == this.checked always evaluates to true.
To make matters worst it is the only thing that evaluates to true. All other test return false.

How do I check which of the two radio buttons has been selected?
Also how do I change the selection programmatically.

Attachment(s):
jspButtonSelection.jsp.zip
3 comments

Abraham,

Seems you are a bit messing server-side and client-side. The code you provided is evaluated on the server-side by JSP engine and is rendered to the browser as
$('textbox1').disabled = !this.checked;
text inside onclick event (where you use "onclick" JSP variable).

You can probably try this:

<c:set var="onclick">

 if ($('radioButton_promoteSeparately').checked){

$('textbox1').disabled = !this.checked;

}
</c:set>

Note that the entire text within <c:set> tag will be set into onclick event handler and will be run inside the browser. This text is JavaScript, not JSP tags as in your example.

0

Thank you for your suggestion but unfortunately it did not work.

<c:set var="onclick">

 $('radioButton_promoteSeparately').disabled = !this.checked;

 $('radioButton_promoteTogether').disabled   = !this.checked;

 

 if ($('radioButton_promoteSeparately').checked)

 {

 $('textbox1').disabled = !this.checked;

 }
 
 </c:set>



The line ($('radioButton_promoteSeparately').checked) evaluates to false.

I have attached the definition of the radioButtonProperty to this post.
on my machine It is located at C:\TeamCity\webapps\ROOT\WEB-INF\tags\props\radioButtonProperty.tag
Perhaps that will help.

Thank you.

Attachment(s):
radioButtonProperty.tag.zip
0

Abraham,

You can try to debug the JavaScript on the page to see what is wrong.

Not sure this is related to TeamCity as this is JavaScript and browser DOM issues rather then rendering and server communicaitons.

0

Please sign in to leave a comment.