1

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" />

this renders into:

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

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?

for reference:

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);
};
Elijah
  • 1,252
  • 3
  • 21
  • 32
  • 2
    Any reason you don't use a (modal) dialog like `` or `` (your question history confirms that you're familiar with RichFaces) or perhaps a homebrewed one based on jQuery? This is after all also much friendlier to the enduser, webbrowser and popupblocker and therefore less likely to cause annoyances and/or trouble. – BalusC Sep 30 '13 at 20:06
  • From navigation point of view - we want the user to open multiple windows and be able to toggle between master and detail. But from technical side - this page has a 3rd party component with latest jquery and jquery-ui. I am also using extJs component on that page that wants to take over the window in order to manage its layout. So it kind of makes sense to keep it on separate view all together. I also mix a little jsf on the same page with this 3rd party component, and as long as RichFaces components aren't referenced, it does not load RF4's jquery. btw, balusC, I love your jsf/rf responses!!! – Elijah Oct 01 '13 at 02:09
  • jQuery that the 3rd party component uses is not compatible with RF4. Rf4.2.0.Final is on 1.7.1 and they are on 1.9.1. I went as far once to upgrade RF4's jquery and tried re-adding deprecated/removed functions. But there are too many in 1.9.1. The design was given to me to make a browser tab from beginning, but now folks are asking me to see if i can break it out of the browser and set width/height. Sounds trivial, but not once I got myself into this corner with – Elijah Oct 01 '13 at 02:16

1 Answers1

0

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);
              };
        });

markup:

< h:commandLink id="viewLink"  action="#{testBean.doTest}" value="h:commandLink"  target="options:height=200, width=300" />
Community
  • 1
  • 1
Elijah
  • 1,252
  • 3
  • 21
  • 32