aspose file tools*
The moose likes Struts and the fly likes Beginner needs help please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Beginner needs help please" Watch "Beginner needs help please" New topic
Author

Beginner needs help please

Michael Norman
Greenhorn

Joined: Apr 29, 2005
Posts: 7
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

Joined: Oct 26, 2000
Posts: 188
Try


HTH,
E


My theory of evolution is that Darwin was adopted. - Steven Wright
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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() + ")" %>'


Merrill
Consultant, Sima Solutions
Eric Fletcher
Ranch Hand

Joined: Oct 26, 2000
Posts: 188
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

Joined: Feb 15, 2005
Posts: 4864
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

    Joined: Apr 29, 2005
    Posts: 7
    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
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Beginner needs help please