Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript in JSF - "body onload=" vs </redirect> tag
    text
    copied!<p>I am trying to use a javascript on one of my JSF pages. Unfortunately the </p> <pre><code>&lt;h:body onload="init('#{formBean.arrayAsString}')"&gt; </code></pre> <p>Is not called at all. I have discovered that if I add /redirect tag in the navigation case that navigate to the page, the function will load. Unfortunately that causes another problem since with the navigation I also pass important f:param so the formBean can read it. If I use the /redirect tag the param value is no longer available for reading. </p> <p>How can I load the javascript init function without using the redirect tag? Or maybe I can somehow pass the f:param value with redirection but as far as I know this is not possible...</p> <p>I below post the navigation method:</p> <p>first .xhtml page:</p> <pre><code>&lt;h:selectOneMenu id="selectMenu" value="#{indexBean.name_id}"&gt; &lt;f:selectItems value="#{indexBean.myModelValues}" /&gt; &lt;f:ajax event="valueChange" render="button" execute="@this"/&gt; &lt;/h:selectOneMenu&gt; &lt;h:commandButton id="button" value="Go to form Browse" action="form"&gt; &lt;f:param name="name" value="#{indexBean.name_id}" /&gt; &lt;/h:commandButton&gt; </code></pre> <p>Bare in mind that this button is also re-rendered by a ajax event of a h:selectOneMenu to pass the selected value.</p> <p>And the navigation case:</p> <pre><code> &lt;navigation-rule&gt; &lt;from-view-id&gt;/index.xhtml&lt;/from-view-id&gt; &lt;navigation-case&gt; &lt;from-outcome&gt; form &lt;/from-outcome&gt; &lt;to-view-id&gt; /form.xhtml &lt;/to-view-id&gt; &lt;redirect/&gt; &lt;/navigation-case&gt; &lt;/navigation-rule&gt; </code></pre> <p>The redirect tag is a new add-on which enabled the JavaScript init function.</p>
 

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