h:commandLink在新的浏览器窗口中打开 [英] h:commandLink open in new browser window

查看:109
本文介绍了h:commandLink在新的浏览器窗口中打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在使用<的同时打开一个配置有高度和宽度的新窗口. h:commandLink>

I want to open a new window, configured with height and width, all while using < h:commandLink >

<h:commandLink id="zyzid" value="click me" action="#{test.testDo}"  target="_blank" />

这呈现为:

<a onclick="mojarra.jsfcljs(document.getElementById('myForm'),{'myForm:xyzid':'myForm:xyzid'},'_blank');return false" href="#" id="myForm:xyzid">click me</a>

我看了jsfcljs()函数.它使用target ="_ blank"提交表单,但是我在任何地方都看不到window.open().那么,如何更改此代码以更改新窗口的高度和宽度?

I looked at jsfcljs() function. It submits the form with target="_blank", but i don't see window.open() anywhere. So, how would I be able to alter this code to change new window's height and width?

以供参考:

mojarra.jsfcljs = function jsfcljs(f, pvp, t) {
    mojarra.apf(f, pvp);
    var ft = f.target;
    if (t) {
        f.target = t;
    }
    f.submit();
    f.target = ft;
    mojarra.dpf(f);
};

推荐答案

我发现了一些相关的,我得出了这个解决方案,它似乎对我有用. h:commandLink打开一个新页面,我开始操纵它的宽度和高度.这涉及到稍微修改/覆盖mojarra.jsfcljs函数.它将使用标准window.open()(由onclick触发)打开一个窗口,并将其提交的表单与该窗口相关联.

I found a few relevant links, and this and I arrived at this solution, which seems to work for me. h:commandLink opens a new page, and I get to manipulate it's width and height. This involves slightly modifying/overwriting the mojarra.jsfcljs function. It opens a window with standard window.open() (triggered by onclick) and associates the form it is submitting with that window.

$(window).load(function(){
            mojarra.jsfcljs = function jsfcljs(f, pvp, t) {
                mojarra.apf(f, pvp);
                var ft = f.target;
                if (t) {
                    if (t.indexOf('options') != -1){
                        f.target = '_blank' + new Date().getTime();
                        var options = t.substring(t.indexOf('optionts') + 9);
                        window.open('', f.target, options); 
                    }
                    else{
                        f.target = t;
                    }
                }

                f.submit();
                f.target = ft;
                mojarra.dpf(f);
              };
        });

标记:

< h:commandLink id="viewLink"  action="#{testBean.doTest}" value="h:commandLink"  target="options:height=200, width=300" />

这篇关于h:commandLink在新的浏览器窗口中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆