• 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

How to Get JSF inputText Value to JavaScript?

 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot. Your code works. The datum is passed from the popup to the parent window now.
 
reply
    Bookmark Topic Watch Topic
  • New Topic