I want to have a Link and when the user clicks on it it should do the following:
- Saving the a key into the session
- Open a new Window with another JSF page
- It should NOT reload the current page
I don't know how to solve the problem.
When I save the key and open the new Window, the key is empty.
Maybe the process of saving the key is too slow?
And how to prevent the page from reloading?
This is my current code:
JavaScript
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);
}
xhtml
<ui:repeat value="#{main.list}" var="items">
<h:commandLink action="#{main.setClickedId(items.itemId)}">
<table onclick="openWin2('immobilie.xhtml')"><tr><td>Hello</td></tr></table>
</h:commandLink>
</ui:repeat>
ManagedBean
Save
public void setClickedId(String clickedId) {
this.clickedId = clickedId;
FacesContext context = FacesContext.getCurrentInstance();
Map<String, Object> map = context.getExternalContext().getSessionMap();
if(map.containsKey("id")){map.remove("id");}
map.put("id", clickedId);
}
Load
FacesContext context = FacesContext.getCurrentInstance();
immoId = context.getExternalContext().getSessionMap().get("id").toString();