• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calling java script function in. js file from JSP

 
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic