Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your current attempt merely interprets the given EL expression as a value expression and just prints its result immediately during producing the HTML output with the JS code embedded. It's like as if you're using <code>&lt;h:outputText&gt;</code>. This is indeed not going to work.</p> <p>The functional requirement is however understood. The standard JSF API does not offer a ready-to-use solution for this. If you want to stick to standard JSF API, your best bet is to create a hidden form with a hidden command link which you trigger using JavaScript. </p> <p>Basically,</p> <pre><code>&lt;h:form id="form" style="display:none"&gt; &lt;h:inputHidden id="id" value="#{notificationBean.notificationID}" /&gt; &lt;h:commandLink id="command" action="#{notificationBean.set0ToGrowlToShow}"&gt; &lt;f:ajax execute="@form" /&gt; &lt;/h:commandLink&gt; &lt;/h:form&gt; </code></pre> <p>with</p> <pre><code>$("[id='form:id']").val(#{p.notificationID}); $("[id='form:command']").click(); </code></pre> <p>However, this is pretty clumsy. Consider looking for a 3rd party JSF component or even utility library to achieve the requirement anyway. The JSF utility library <a href="http://omnifaces.org" rel="nofollow noreferrer">OmniFaces</a> has the <a href="http://omnifaces.org/docs/vdldoc/current/o/commandScript.html" rel="nofollow noreferrer"><code>&lt;o:commandScript&gt;</code></a> component for this. See also its <a href="http://showcase.omnifaces.org/components/commandScript" rel="nofollow noreferrer">showcase page</a>. </p> <pre><code>&lt;h:form&gt; &lt;o:commandScript name="set0ToGrowlToShow" action="#{notificationBean.set0ToGrowlToShow}" /&gt; &lt;/h:form&gt; </code></pre> <p>with</p> <pre><code>set0ToGrowlToShow(#{p.notificationID}); </code></pre> <p><em>(please note that this is set as HTTP request parameter, not as action method argument)</em></p> <p>The JSF component library <a href="http://primefaces.org" rel="nofollow noreferrer">PrimeFaces</a> has the <a href="http://www.primefaces.org/docs/vdl/3.5/primefaces-p/remoteCommand.html" rel="nofollow noreferrer"><code>&lt;p:remoteCommand&gt;</code></a> for this which is much similar to <code>&lt;o:commandScript&gt;</code>. See also its <a href="http://www.primefaces.org/showcase/ui/remoteCommand.jsf" rel="nofollow noreferrer">showcase page</a>. Even more, PrimeFaces has a ready-to-use <a href="http://www.primefaces.org/docs/vdl/3.5/primefaces-p/growl.html" rel="nofollow noreferrer"><code>&lt;p:growl&gt;</code></a> component which does essentially the same as your jQuery plugin! See also its <a href="http://www.primefaces.org/showcase/ui/growl.jsf" rel="nofollow noreferrer">showcase page</a>. Instead of your whole jQuery thing you can just do:</p> <pre><code>&lt;p:growl globalOnly="true" autoUpdate="true" /&gt; </code></pre> <p>and feed it with messages by</p> <pre><code>facesContext.addMessage(null, message); </code></pre> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/questions/16588327/how-to-invoke-a-jsf-managed-bean-on-a-html-dom-event-using-native-javascript/">How to invoke a JSF managed bean on a HTML DOM event using native JavaScript?</a></li> <li><a href="https://stackoverflow.com/questions/28591301/how-to-pass-javascript-variables-as-parameters-to-jsf-action-method">How to pass JavaScript variables as parameters to JSF action method?</a></li> </ul>
    singulars
    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.
    3. VO
      singulars
      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