• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Beginner needs help please

 
Michael Norman
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all.

I have the following problem. I have the following code:



This works fine. BUT... Now I want to change the javascript call from
to something like:

So I want to call "changeName" with the name of the part I just iterated over. The above dosn't work... But what is the correct code for this?

Thanks in advanced for your help

greetings

Norman
 
Eric Fletcher
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try


HTH,
E
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to remember that your code is in a scriptlet, which means that you need to use java syntax, rather than struts tag syntax.

The following should work:

onChange='<%= "changeName(" + part.getPartName() + ")" %>'
 
Eric Fletcher
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops, merrill is right, missed the getter. Should look like this:



Sorry about that!
[ June 10, 2005: Message edited by: Eric Fletcher ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple more things on this:

  • I just noticed that in order for my suggestion to work, you will also have to add type="<<fully qualified name for the Part class>>" to the logic:iterate tag. Otherwise, the part variable will be of type Object, and you will have to cast it before using its getPartName() method
  • Struts tags have an "all or nothing" policy toward scriptlets, which means that if you substitute an attribute value with a scriptlet, either all of it has to be in a scriptlet, or no part of it should be a scriptlet. Given this policy, I don't think Eric's suggestion will work in this situation.


  • I hope this helps.
    [ June 10, 2005: Message edited by: Merrill Higginson ]
     
    Michael Norman
    Greenhorn
    Posts: 7
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hey Merrill and Eric.

    Thanks for your help, it works now. I had to use the type-attribute of the iterate-tag and the syntax Merrill posted!

    Greetings,

    Norman
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic