Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>JSF runs in webserver and produces HTML which get sent to webbrowser. JS runs in webbrowser and has only access to HTML DOM tree. It knows <em>nothing</em> about the JSF source code. </p> <p>When writing JS code for JSF web applications and you can't tell from top of head what HTML code exactly JSF would generate, then you should open the JSF page in webbrowser and do a rightclick and <em>View Source</em>. You'll see something like this</p> <pre><code>&lt;form id="j_idt42" ...&gt; &lt;input type="hidden" id="j_idt42:dataURL" ... /&gt; </code></pre> <p>That explains why <code>document.getElementById("dataURL")</code> didn't give you anything. If you have paid close attention to the JS console in browser's webdeveloper toolset (press F12 in Chrome/IE9/Firebug), then you should have noticed it.</p> <p>You basically need to do <code>document.getElementById("j_idt42:dataURL")</code> instead, but you should rather give the JSF <code>NamingContainer</code> components (such as <code>&lt;h:form&gt;</code>) a fixed ID, so that JSF won't autogenerate one and then you don't need to change your scripts everytime you add/remove components from the view, causing the autogenerated ID to change. E.g.</p> <pre><code>&lt;h:form id="form"&gt; &lt;h:inputHidden id="dataURL" ... /&gt; </code></pre> <p>This will generate</p> <pre><code>&lt;form id="form" ...&gt; &lt;input type="hidden" id="form:dataURL" ... /&gt; </code></pre> <p>and then you'll be able to get it by</p> <pre><code>var hidden = document.getElementById("form:dataURL"); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload