• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSTL tag c:if

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to write a code where based on a value of a parameter, the buttons in the page should be enabled or disabled.

For this I am using jstl tag

<c:if test="${vaf.evd_type=='MC' || vaf.evd_type=='MO'}">
</c:if >

If the condition is true, i would like to execute a javascript.

Is the correct way? if yes then how should i pass control to javascript, if not then how should i do it? ( I am using struts tag in other places)
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>Is the correct way?
Well it could work...

>if yes then how should i pass control to javascript
You don't exactly pass control to javascript.
You generate javascript code to be run later.

The process of things
1 - The JSP runs on the server and generates an HTML page with javascript
2 - The html/javascript runs in the browser.

So the question isn't how do you pass control to javascript.
It should be "Where is the best place to generate javascript code to do this"
The a function called by the onLoad event is a good place...

<script>
function runOnLoad(){
<c:if test="${randomTest == true}>
document.forms[0].description.value = 'This javascript is only generated if the test condition is true';
</c:if>
}
</script>
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic