2017-05-16 36 views
-1

我想彈出ajax調用對話框,我嘗試了很多方法,但我找不到解決方案。有人能幫助我,謝謝。p:關於ajax的oncomplete屬性沒有顯示對話框

的XHTML代碼如下

<h:body> 
    <h:form> 
     <p:selectOneRadio style="margin-left:10px" value="#{newSubBean.selectedEvent}" 
       required="true" layout="pageDirection"> 
      <f:selectItems value="#{newSubBean.events}" var="item" 
        itemValue="#{item.eventId}" itemLabel="#{item.title}" /> 
      <p:ajax event="change" update="dt" oncomplete="PF('sub').show()"> 
      </p:ajax> 
     </p:selectOneRadio> 

     <p:dialog visible="true" id="dialog" widgetVar="sub" 
       header="Previous Subscriptions" showEffect="explode" hideEffect="bounce"> 
      <p:dataTable id="dt" style="width:800px" 
        value="#{newSubBean.subscribedEventList}" var="rows"> 
       <f:facet name="header"> 
        <p:outputLabel value="Previous Subscriptions"> 
        </p:outputLabel> 
        <br/> 
        <p:outputLabel styleClass="preformatted" 
          value="#{newSubBean.eventName}"> 
        </p:outputLabel> 
       </f:facet> 
       <p:column headerText="Subscribed Notification"> 
        <p:outputLabel value="#{rows.notificationType.title}"> 
        </p:outputLabel> 
       </p:column> 
       <p:column headerText="Subscribed Template"> 
        <p:outputLabel value="#{rows.notificationTemplateDetail.title}"> 
        </p:outputLabel> 
       </p:column> 
       <p:column headerText="Subscription Time"> 
        <p:outputLabel 
          value="#{rows.insertionTimeStamp.getTime().toLocaleString()}"> 
        </p:outputLabel> 
       </p:column> 
      </p:dataTable> 
      <p:commandButton value="Close" onclick="PF('sub').hide();"> 
      </p:commandButton> 
     </p:dialog> 
    </h:form> 
</h:body> 
+0

使對話框表單中。並且將數據表插入表單中,當您嘗試更新時更新dataTable表單。 –

+1

@yagamiLight:爲什麼?我認爲沒有任何需要 – Kukeltje

回答

0

給出的AJAX事件=「變化」不是用於繳費的單選按鈕。

你需要的是點擊事件,因爲click事件是單選按鈕,你並不需要在所有指定事件的默認事件:

<p:ajax update="dt" oncomplete="PF('sub').show()"/> 
+0

onChange屬性可用於p:selectOneRadio,爲什麼它不支持「onChange」事件? – Truthira

+1

http://stackoverflow.com/questions/21286545/pselectoneradio-not-updating-model-in-event-change-with-pajax http://stackoverflow.com/questions/13221089/primefaces-selectoneradio-ajax – lastresort