This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Struts and the fly likes Passing bean property as parameter of a javascript function 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 "Passing bean property as parameter of a javascript function" Watch "Passing bean property as parameter of a javascript function" New topic
Author

Passing bean property as parameter of a javascript function

Dolfino Proteus
Greenhorn

Joined: Jan 12, 2010
Posts: 3
Hi all!

First post on JavaRanch
(but I know and use this site since I've started to program)

Here's the problem...

I've got an iterate tag as:

inside the iterate block there is a link associated with a javascript function, passing some bean property as parameter of the function like:

It is all working correctly, but if the name property (a string object from the server-side) contains an apex (a single quote like ' ) then a js-error occurs. I can understand easily why this happens (after all is a simple syntax error) but I can't figure out how to solve the problem Does someone know a good way?

Thank you all in advance,
Dolfino
Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
Dolfino Proteus wrote:
First post on JavaRanch


Welcome!

Dolfino Proteus wrote:
but I can't figure out how to solve the problem


If filter="true" doesn't help in the bean:write tag, you could escape the apexes in your action.


OCJP 6 (93%)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing bean property as parameter of a javascript function