Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
    Bookmark Topic Watch Topic
  • New Topic

Problem with html:select

 
Raghu Nathan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • 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.

(If this belongs to the JSP forums, then please let me know so that I can move it there.)

Thanks in advance
RS
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Report post to moderator
It's usually OK to use a scriptlet in an attribute of a Struts tag, but the policy is "all or nothing". By this, I mean that either the entire attribute must be represented by a scriptlet, or else no part of it can be a scriptlet. So, for example, the following would work:

If your Web application is a Servlet version 2.4 application, Struts does support EL expressions as part of an attribute, so the following would work:

In this case, though, "value" must be a scoped variable(page, request, session, etc.), and not just a Java variable.
 
Raghu Nathan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks for the help
I used the first method and was able to get the function call.

RS
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64852
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place.
 
    Bookmark Topic Watch Topic
  • New Topic