4

プロジェクトのフロントエンドにJSFを使用しています。バッキングBeanで新しいウィンドウを開くにはどうすればよいですか?

4

2 に答える 2

6

またはで設定target="_blank"します。<h:commandLink><h:form>

例えば

<h:form>
    <h:commandLink value="Open in new window" action="#{bean.action}" target="_blank" />
</h:form>

また

<h:form target="_blank">
    <h:commandButton value="Open in new window" action="#{bean.action}" />
</h:form>
于 2012-04-18T13:25:57.080 に答える
0

BalusCの回答に加えて。次のような状況での一種のハッキーなソリューション:

  • commandLink は UI で使用できません (ページのスタイルやその他の理由により)
  • フォームのターゲットは変更できません

    <!-- 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>
    
于 2013-09-05T14:01:00.613 に答える