This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to use beans in java script?  RSS feed

 
Balaji Kadam
Ranch Hand
Posts: 31
Hibernate Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all.

I want to use java beans properties in java script. It it possible?
scenario is :

one when i click on a combo box i call servlet using ajax block and set values in that bean. when ajax returns response i want to use that bean values. Is this correct way?
or how should i handle this scenario.

-Balaji
 
S Jothimani
Greenhorn
Posts: 9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Balaji,

You can get the HttpResponse, once the control returned back to the calling part of Javascript, from servlet.

This response contains text i.e strings. You can append more values in it (by using delimiter) from the servlet to the calling part of javascript.
From that response you can get the bean value back if you append it
 
Balaji Kadam
Ranch Hand
Posts: 31
Hibernate Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks jothimani for reply

can you please tell more detail on this?

This response contains text i.e strings.
You can append more values in it (by using delimiter) from the servlet to the calling part of javascript.
From that response you can get the bean value back if you append it




Thanks


 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66208
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The short answer is no, you cannot ue beans in JavaScript.

The response returned in Ajax is text like any other HTTP response. What was being alluded to was that that text can contain any data that you need to get from the bean. In fact, using JSON you could probably re-create the bean properties almost exactly.

And, there is no such thing as a "combo box" in HTML. Please read: HtmlHasNoComboBox.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!