Forums Register Login

passing java-script value to java-bean-property

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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?
+Pie Number of slices to send: Send
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.
So I left, I came home, and I ate some pie. And then I read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 21022 times.
Similar Threads
Spring-Hibernate transaction management
how to convert byte [] to String?
calling javascript function through onclick present on checkbox
passing parameters between JSF(or JSP) and java script
problem with the popup
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 07:02:28.