aspose file tools*
The moose likes JSF and the fly likes How to Get JSF inputText Value to JavaScript? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to Get JSF inputText Value to JavaScript?" Watch "How to Get JSF inputText Value to JavaScript?" New topic
Author

How to Get JSF inputText Value to JavaScript?

Daniel Gee
Ranch Hand

Joined: Aug 29, 2003
Posts: 202
I have to use JSF to pop up a window from the parent window. In the popup window, I have to pass the value that is entered in a <h:inputText> back to a text field in the parent window.

In order to make sure that I know the way to communicate between the parent window and the popup window, I have tried coding it in HTML. And I have done it successfully.

Then, I try to convert the HTML code to JSF. I have searched the internet and I have tried different specifications myself. I am stuck. This is the line that I have been struggling with:

If textField is in HTML parent window <input name=textField .... /> and the inputField is in HTML popup window <input name=inputField .... />, the JavaScript can recognize (No problem! the datum is passed.):

Now, the dataManagement is the "id" attribute in my JSF parent <h:form> tag. The externalFile is the "id" attribute in my JSF popup <h:form> tag.

The textField is in the JSF parent window as both the "id" attribute and a "property" name (i.e. value="#{dataManagementBean.textField}" )in the <h:inputText> tag.

The inputField is in the JSF popup window as both the "id" attribute and a "property" name (i.e. value="#{accessExternalFileBean.inputField}" ) in the <h:inputText> tag.

No matter how I experiment with different specifications, I cannot get the textField and inputField in the JavaScript. I got that "it is null or not an object" JavaScript error. Please advise if you have done it successfully.
Garann Means
Ranch Hand

Joined: Jan 28, 2002
Posts: 214
If the IDs are as you outlined, this ought to work:



It seems possible that would give you a security or access denied error. If so, you can pass document.getElementById("externalFile:inputField").value into a function in the parent and set the value the same way there.
Daniel Gee
Ranch Hand

Joined: Aug 29, 2003
Posts: 202
Thanks a lot. Your code works. The datum is passed from the popup to the parent window now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Get JSF inputText Value to JavaScript?
 
Similar Threads
javascript in jsf
Communicate from a Popup Window back to the Parent Window
How do javascript refer to Jsf input field ID
javascript with JSF???
Passing a Value from Popup Window back to the Parent Window