wood burning stoves 2.0*
The moose likes JSP and the fly likes Calling java script function in. js file from JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Calling java script function in. js file from JSP" Watch "Calling java script function in. js file from JSP" New topic
Author

Calling java script function in. js file from JSP

Muhammad Imad Qureshi
Ranch Hand

Joined: Sep 13, 2005
Posts: 238
Hi

In my jsp I am calling a function in.js file and passing it an integer which I recieve in my jsp.

here are the two lines
<html:hidden name="addressMaintenanceForm" property="location.locationId" />
on--click="loadLocationLocatorSequence('<bean:write name="addressMaintenanceForm" property="location.locationId" />');"

now instead of location.locationId (where locationId is primitive integer) I want to send location.locationKey (where locationKey is an object). Is there a way that I can send this objects String form like using toString (). I have a well written toString() method.
Thanks
Imad
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

That's entirely up to how the <bean:write> tag works. Most facilities that emit an object to the JSP output stream will automatically call toString() on the object.

Have you just tried it?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

By the way, yours was sme of the most unreadable code I've seen posted in this forum. You'll generally find that people are more willing to help if you take the time to make sure that your code is well-formatted and readable.
Muhammad Imad Qureshi
Ranch Hand

Joined: Sep 13, 2005
Posts: 238
Thanks for your help. I am sorry when I was posting the code it dint let me post because of onClick and also askedme to change all < by <. Thats why it was too unreadable. But thanks for your advice. I will definitely check if bean:write automatically calls its tostring method.
Thanks again
Imad
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

If it turns out that <bean:write> doesn't do what you want, there are alternatives, so check back if it doesn't work for you.

Thats why it was too unreadable.


Even within the limitiations imposed by the forum, it's possible to enter readable code. Observe:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling java script function in. js file from JSP