This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to pass form bean value to javascript function

 
preethi venkatarangan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a textfield created using html:text.
html:text name="nameform" property="formbean.name"
now on blur i want to send this formbean value dynamically to a javascript function to validate and set that validated value to another formbean.how do i do that. it would be nice if someone could provide me with a simple example

Thanks in advance
[ February 09, 2008: Message edited by: preethi venkatarangan ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64858
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by preethi venkatarangan:
it wud be nice if someone could provide me with a simple example

Please use real words when posting to the forums. Abbreviations such as "wud" in place of "would" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64858
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear in mind that your form bean exists on the server and the page exists on the client. If this is a new concept, please take a look at this article.

Once the page is sent to the client (browser), the form bean is gone. You can use JavaScript to read the value that the form bean placed in the text field, but it's not directly accessing the form bean.

Likewise, to send the value back to the server to place in another bean, you need to submit a form with the value, or use Ajax.
 
preethi venkatarangan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about that.But we could pass the form bean value to the javascript right.I just wanted to know how to pass the formbean value to the javascript function.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64858
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by preethi venkatarangan:
Sorry about that.But we could pass the form bean value to the javascript right.I just wanted to know how to pass the formbean value to the javascript function.

No, you cannot pass the value to the JavaScript. By the time the JavaScript executes on the client, chances are the form bean, which is on the server anyways, is long gone.

What you can do is to use the power of JSP to write the value of the bean into the JavaScript itself.


But this cannot be construed as "passing" the value. You will merely be generating JavaScript that has the value hard-coded into it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic