开发者

JSF 1.2: How to open a new window and catch the fact that user tried it

开发者 https://www.devze.com 2023-03-28 20:16 出处:网络
I\'d like to open a new browser window, with everything hidden. Also I\'d like to know that the user has initiated the action and record in the backend using JSF.

I'd like to open a new browser window, with everything hidden. Also I'd like to know that the user has initiated the action and record in the backend using JSF.

From reading internet, it looks like I can use window.open but then JSF is totally bypassed. Also I'd like to pass a value of a bean into the javascript as well.

Is this a pipe dream ? Can I do开发者_开发知识库 it with JSF 1.2 ? Thanks


You could just pass it as a request parameter on the URL.

<h:outputLink value="#" onclick="window.open('popup.jsf?foo=#{bean.foo}');">
    popup
</h:outputLink>

You could make foo parameter a managed property of the bean associated with the popup page.

E.g.

<managed-property>
    <property-name>foo</property-name>
    <value>#{param.foo}</value>
</managed-property>

with

public class PopupBean {

    private String foo;

    @PostConstruct
    public void init() throws IOException {
        doSomethingWith(foo);
        youCouldLogHereAsWellThatPopupIsBeenOpened();
        FacesContext.getCurrentInstance().getExternalContext().redirect("http://other.com/report");
    }

    // ...
}

(the @PostConstruct method is invoked after bean's construction and managed propery injection)

0

精彩评论

暂无评论...
验证码 换一张
取 消