• 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

passing java-script value to java-bean-property

 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how can I transfer the ivalue of a java-script to a java-bean-property?

This java-script returns me a ivalue:

alert(myJsValue);

I need to pass the value of myJsValue to a java-bean-property. How can I do that?
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

To set a javascript property with a java bean property:



To set a java bean property with a javascript property you can try this:

In your JSP you have to following line:


Then set with javascript your myJsValue:


I hope it will work.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to add more on it ..
You can send any value form JavaScrip to Java or vice versa using DWR. Direct Web Remoting a easy AJAX for java.
:-)

Regards
PP.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bertjan Underhill wrote:Hello,

To set a javascript property with a java bean property:



To set a java bean property with a javascript property you can try this:

In your JSP you have to following line:


Then set with javascript your myJsValue:


I hope it will work.






this is not working for me... any suggestions y?
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The only way JavaScript can set a backing bean property is by making a request to the server, since that's where the backing bean lives. That means that the client must make an HTTP URL request to the server. The brute-force way of doing that would be to set a form control property (you can use a hidden text control) and pass the value in when the form is submitted.

A more elegant approach that avoids the need to submit and re-render the entire page is to do an AJAX request. That can be done in a number of ways, including:

1. brute-force javascript
2. Using an AJAX support javascript library like dojo or jQuery
3. Using the JSF2 AJAX support features
4. Using third-party JSF AJAX support packages such as RichFaces or IceFaces.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic