Reputation: 615
I am using JSF for my project front end. How I can I open a new window with backing bean?
Upvotes: 4
Views: 10814
Reputation: 3173
In addition to BalusC answer. Kind of hacky solution in situation when:
target of the form cannot be changed
<!-- Group and render them together.-->
<h:panelGroup rendered="#{mybean.showButton}">
<!-- Visible and clickable commandButton. No action, just onclick js event.-->
<h:commandButton value="My Commandbutton"
onclick="document.getElementById('myForm.realTargetBlankLink').click();"/>
<!-- Invisible link. Action, target _blank.-->
<h:commandLink id="realTargetBlankLink" action="#{myBean.myDesiredAction}"
target="_blank"/>
</h:panelGroup>
Upvotes: 0
Reputation: 1108642
Set target="_blank"
on the <h:commandLink>
or <h:form>
.
E.g.
<h:form>
<h:commandLink value="Open in new window" action="#{bean.action}" target="_blank" />
</h:form>
or
<h:form target="_blank">
<h:commandButton value="Open in new window" action="#{bean.action}" />
</h:form>
Upvotes: 6