Pass parameter to dialog in the same page

前端 未结 2 1756
别那么骄傲
别那么骄傲 2020-12-18 22:06

I have a page contains a form and other form nested in a dialog. I need to pass parameter to dialog when button clicked in the main form


相关标签:
2条回答
  • 2020-12-18 22:30

    Assuming that the bean is in the view scope, just set it as a bean property direclty in the action method of the command button in the datatable column.

    <h:form>
      <p:dataTable var="form" value="#{myBean.formList}">
        <p:column>
          <p:commandButton id="selectProduct" 
                           action="#{myBean.setCurrentForm(form)}"
                           update="selectProductForm" oncomplete="selectProductDlg.show()" 
                           image="ui-icon-"> 
          </p:commandButton>
        </p:column>
      </p:dataTable>
    </h:form>
    
    <p:dialog>
      <h:form>
        <p:commandButton action="#{myBean.setSelected}"
                         update="main_form"
                         oncomplete="if(#{myBean.errorText == 'SUCCESS'}){ selectProductDlg.hide();}"
                         value="Sec">
        </p:commandButton>
      </h:form>
    </p:dialog>
    

    If you have a cancel button in the dialog, you need to let its action method set it to null.

    There's no need to fiddle around with raw HTTP request parameters in POST requests. The <f:param> should as much as possible be used in GET requests only (e.g. <h:link>, <h:button>, etc).

    0 讨论(0)
  • 2020-12-18 22:38

    I have simply called the PDataTables's datamodel as shown below.

    1. IN the Java Bean I am refreshing the data from the backend receivedFdnsController.refreshData method.
      1. To refresh the data in the form I am calling datamodel refreshing as #{receivedFdnsController.newReceivedFdnsDataModel} after hiding the dialog. More details shown below.

    Regards Khaleel

    0 讨论(0)
提交回复
热议问题