Note that there are some explanatory texts on larger screens.

plurals
  1. POValue saving in session
    text
    copied!<p>I want to have a Link and when the user clicks on it it should do the following:</p> <ul> <li>Saving the a key into the session</li> <li>Open a new Window with another JSF page</li> <li>It should NOT reload the current page</li> </ul> <p>I don't know how to solve the problem.<br/> When I save the key and open the new Window, the key is empty. <br/> Maybe the process of saving the key is too slow?<br/> And how to prevent the page from reloading?<br/> <br/> This is my current code:</p> <p><strong>JavaScript</strong></p> <pre><code>function openWin2(url) { var w = 800; var h = window.innerHeight - 100; var left = ((screen.width-w)/2); var top = ((screen.height-h)/2); window.open(url, 'Tax', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left); } </code></pre> <p><strong>xhtml</strong></p> <pre><code>&lt;ui:repeat value="#{main.list}" var="items"&gt; &lt;h:commandLink action="#{main.setClickedId(items.itemId)}"&gt; &lt;table onclick="openWin2('immobilie.xhtml')"&gt;&lt;tr&gt;&lt;td&gt;Hello&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; &lt;/h:commandLink&gt; &lt;/ui:repeat&gt; </code></pre> <p><strong>ManagedBean</strong><br/> <em>Save</em></p> <pre><code>public void setClickedId(String clickedId) { this.clickedId = clickedId; FacesContext context = FacesContext.getCurrentInstance(); Map&lt;String, Object&gt; map = context.getExternalContext().getSessionMap(); if(map.containsKey("id")){map.remove("id");} map.put("id", clickedId); } </code></pre> <p><em>Load</em></p> <pre><code>FacesContext context = FacesContext.getCurrentInstance(); immoId = context.getExternalContext().getSessionMap().get("id").toString(); </code></pre>
 

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