• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling java script function in. js file from JSP

 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic