リンクが欲しいのですが、ユーザーがリンクをクリックすると、次のようになります。
- キーをセッションに保存する
- 別のJSFページで新しいウィンドウを開く
- 現在のページをリロードしないでください
問題を解決する方法がわかりません。
キーを保存して新しいウィンドウを開くと、キーは空です。
キーを保存するプロセスが遅すぎるのではないでしょうか。
そして、ページがリロードされないようにする方法は?
これは私の現在のコードです:
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
保存
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);
}
ロード
FacesContext context = FacesContext.getCurrentInstance();
immoId = context.getExternalContext().getSessionMap().get("id").toString();