Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open new window by POST using h:commandButton

I need to open a JSF page in a new window by POST on click of a <h:commandButton>. I know I can acheive this using the JavaScript. But I would like to achive this using JSF and not JavaScript.

How can I achieve this? I'm using JSF 2.0.

like image 532
vr3w3c9 Avatar asked Jul 23 '12 11:07

vr3w3c9


1 Answers

When you restrict the target only to a single action, maybe you want to get the form in its initial state. With the oncklick action you set the target of the form to a _blan page. After the click, the page is opened in a new tab/page (triggers the action event). At last, the onblur action is triggered and set the form again to its initial state (the rest of the buttons will open in the _self page) With this code, you can restrict to only a h:commandbutton to open in a new page. The rest of the buttons will be opened in the self page:

    <h:commandButton
       onclick="this.form.target='_blank'"
       onblur="this.form.target='_self'"
       id="listadoRebuts"
       action="#{giaquaBusquedaCorte.abrirListadoRebuts}"
       value="#{msg.seqVisorbtnRecibos}">
    </h:commandButton>
like image 186
goojoob Avatar answered Nov 03 '22 00:11

goojoob