74 users online (1 members and 73 guests)  


  Results 1 to 7 of 7

Related

  1. parsing string    Forum: CGI Perl Forum
    Replies: 1
  2. Replies: 5
  3. Replies: 2
  4. unusual string    Forum: Javascript Forum
    Replies: 2
  1. #1
    wcipolli's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Jun 2009
    Posts
    28

    importing java string into javascript

    I have a .java file in a folder that contains a method getPdfSearchParameter()which returns a string. I would like to take that string and add it to the global url defined in the js method stored in another folder.

    Is there a way to call that method or string value into the java script file?

  2. #2
    wcipolli's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Jun 2009
    Posts
    28

    Re: importing java string into javascript

    Code:
    <h:inputHidden id="hiddenAllWord" value="#{pc_SearchForms.searchFormsDataBean.searchCriteria.allWords}"/>
    I know I had to do this to make it accessable but

    Code:
    var searchP = document.getElementById("form1:allWords").value;
    doesn't work

  3. #3
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: importing java string into javascript

    I don't see how your two posts are related. Could you perhaps go into more detail?

  4. #4
    wcipolli's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Jun 2009
    Posts
    28

    Re: importing java string into javascript

    sorry for not clarifying. Instead of going through java i decided to go through a jsp page.

    so I have pc.js and fsr.jsp


    Code:
    <h:inputHidden id="hiddenAllWord" value="#{pc_SearchForms.searchFormsDataBean.searchCriteria.allWords}"/>
    i put this into the jsp code as a hidden variable and passed it into the js of the page with
    Code:
    var searchP = document.getElementById("form1:hiddenAllWords").value;
    I threw an alert in the js
    Code:
    alert(hiddenAllWords);
    and it prints (object) into the js window, I would like it to print out the string that hiddenallwords should be holding.

  5. #5
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: importing java string into javascript

    Have you tried
    Code:
    alert(searchP)
    yet?

  6. #6
    wcipolli's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Jun 2009
    Posts
    28

    Re: importing java string into javascript

    Yes, that didn't work either. I tried changing var to String thinking maybe since it wasn't officially declared a string before and that didnt work either

  7. #7
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: importing java string into javascript

    Change the following line
    Code:
    var searchP = document.getElementById("form1:hiddenAllWords").value;
    to
    Code:
    var searchP = document.getElementById("hiddenAllWords").value;
    and use the alert I gave you previously.



Tags for this Thread