2017-05-11 18 views
0

我想在modal中放置一個outputText,點擊commandButton時會打開modal通過點擊jsf commandButton打開實現模態

我試過這段代碼:

<div class="row section"> 
    <div class="col"> 
    <!-- Modal Trigger --> 
    <h:commandButton value="submit" class="waves-effect waves-light btn modal-trigger" href="#modal1" action="#{someBean.someMethod}" />         
    </div> 
</div> 
<!-- Modal Structure --> 
<div id="modal1" class="modal"> 
    <div class="modal-content"> 
    <h:outputText value="#{someBean.someData}" /> 
    </div> 
    <div class="modal-footer"> 
    <a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">Agree</a> 
    </div> 
</div> 

和JS:

$(document).ready(function(){ 
    // the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered 
    $('.modal-trigger').leanModal(); 
    }); 

然而,這並不工作,我只是用用JSF兌現開始

+0

任何JSF擴展? –

+0

無論JSF擴展如何,**爲什麼**會將'leanModal'應用於commandButton? – Kukeltje

+0

@SubodhJoshi不,我剛剛在pom上導入了javax.faces,並在頭標上實現了 – mhery

回答

0

你可以試試這個使用標籤裝飾。

添加到您的用戶界面:組成的xmlns:JSF = 「http://xmlns.jcp.org/jsf」

後,您使用的是使用HTML的一個標籤

div class="row section"> 
    <div class="col"> 
    <!-- Modal Trigger --> 
    <a href="#modal1" jsf:actionListener="#{someBean.someMethod}"> 
     <i class="material-icons">view_list</i> 
     <p:ajax update="modal1" /> 
    </a>         
    </div> 
</div> 
<!-- Modal Structure --> 
<div id="modal1" class="modal"> 
    <div class="modal-content"> 
    <h:outputText value="#{someBean.someData}" /> 
    </div> 
    <div class="modal-footer"> 
    <a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">Agree</a> 
    </div> 
</div>