• 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

Problem with html:select

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings,
I'm having a problem with setting server side values as a parameter to a javascript function that I am calling during an "onchange" event of an html:select that I have.
The line in my jsp is something like this:

<html:select name="stList" property="attempt.attainmentLevel" onchange="javascript:trackChanges( <%=value%>);" indexed='true'>

The problem with the above line is that when I view source code after my page is rendered is that the dynamic value is not replaced but I see the <%=value%> as it is!

Now as I was debugging, I replaced this with the regular <select> html tag.

<select name="stList" property="attempt.attainmentLevel" onchange="javascript:trackChanges( <%=value%>);" indexed='true'>

In this case, I am able to see the processed server side value for <%=value%>.

It is important for me to use html:select and if I do that what do I have to do so that I can pass the dynamic server side value to my javascript function?

I hope I have been articulate enough to explain my problem - please let me know if you need further information.

Thanks in advance
RS
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You cannot use a scriptlet expression as just part of an attribute of a custom action. It must compose the entire attribute value.

No such restructions exists with the EL in JSP 2.0.
[ March 30, 2007: Message edited by: Bear Bibeault ]
 
Raghu Nathan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the prompt reply ...

I have couple of questions:
- I do pass scriptlet values to custon tag libraries and they are able to read the,. Why should the tag library for tags-html be any different?

-Is there a work around to this one?

Thanks
RS
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Raghu Nathan:

- I do pass scriptlet values to custon tag libraries



Only as the complete attribute:



 
Raghu Nathan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for that tip - I created a server side string variable that would call the javascript function. I used this in my onchange event

<%
String funcCall = "javascript:function funA(" + var1 + ");";
%>
onchange=<%=funcCall%>

Just gave a sample so that others could benefit if they come across a similar problem.

Thanks again, your tip helped me.
RS
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad to have helped. I would urge you to begin thinking about adopting JSP 2.0 and removing scriptlets and scriplet expressions from your JSPs.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear Bibeault & Raghu for this post ....
 
ganesh musa
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bear Bibeault,
What do you mean by using JSP2.0? how can I get rid of jsp scriptlets in the above condition. I tried using struts <bean:write> & <bean:define> stuff but i endup with same problem...
Pls share if any suggestions. Many Thanks
Ganesh
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
or you can do something like the following. Had the same issue and resolved it. Thought of putting it here so that it might help someone.

<select name="stList" property="attempt.attainmentLevel" onchange='<%= "javascript:trackChanges(" + value + ");" %>' indexed='true'>

Thanks.
-S
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Java Rider", please check your private messages for an important administrative matter.
 
reply
    Bookmark Topic Watch Topic
  • New Topic