我想打开一个新的浏览器窗口,隐藏所有内容。我还想知道用户是否已使用 JSF 在后端启动操作和记录。
从互联网上看,我似乎可以使用 window.open 但 JSF 被完全绕过。我也想将一个 bean 的值传递给 javascript。
这是白日梦吗?我可以用 JSF 1.2 来做吗?谢谢
最佳答案
您可以将它作为 URL 上的请求参数传递。
<h:outputLink value="#" onclick="window.open('popup.jsf?foo=#{bean.foo}');">
popup
</h:outputLink>
您可以使 foo
参数成为与弹出页面关联的 bean 的托管属性。
例如
<managed-property>
<property-name>foo</property-name>
<value>#{param.foo}</value>
</managed-property>
与
public class PopupBean {
private String foo;
@PostConstruct
public void init() throws IOException {
doSomethingWith(foo);
youCouldLogHereAsWellThatPopupIsBeenOpened();
FacesContext.getCurrentInstance().getExternalContext().redirect("http://other.com/report");
}
// ...
}
(@PostConstruct
方法在 bean 的构造和托管属性注入(inject)之后被调用)
关于javascript - JSF 1.2 : How to open a new window and catch the fact that user tried it,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7071988/