Note that there are some explanatory texts on larger screens.

plurals
  1. POPass a value from h:outputLink to JSF after onclick event
    primarykey
    data
    text
    <p>I need to pass an integer to a JSF backing bean after <code>onclick</code> event on <code>h:outputLink</code>. </p> <p><strong>Important :</strong> I cannot use f:param to pass value as request parameters to the naviagating page as I am preventing default onclick behaviour of h:outputlink. <em>The control instead of navigating to page defined by href attribute, goes to a javascript function</em>.</p> <p>Using Primefaces 3.0M3 snapshot with JSF 2.0</p> <hr> <p>My code follows:</p> <pre><code>&lt;h:outputLink id="#{item.id}" value="/itemDetails.xhtml" class="itemLink" &gt; #{item.name} &lt;/h:outputLink&gt; &lt;script&gt; $(".itemLink").click(function(event) { showDetailsInDialog();// show the item details in dialog event.preventDefault();// prevent the behaviour provided by href }); &lt;/script&gt; &lt;h:form&gt; &lt;p:remoteCommand name="showDetailsInDialog" update="itemDetailsPanel" oncomplete="itemDetailsDialog.show()"&gt; &lt;f:setPropertyActionListener value="....id of the item...." target="#{itemsList.selectedItem}"/&gt; &lt;/p:remoteCommand&gt; &lt;/h:form&gt; </code></pre> <p>I have a reusable <code>dialog</code> that displays the details of item selected from a itemslist. For this when the <code>h:outputLink</code> for an element is clicked the id of that item needs to be passed to JSF to render appropriate content in <code>dialog</code>.</p> <p>As shown above If I can get the id of item in <code>remotecommand</code>, I can pass it to appropriate backing bean through <code>setPropertyActionListener</code> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    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