Primefaces dialog + commandButton

前端 未结 2 1479
一整个雨季
一整个雨季 2020-12-03 19:05

I\'m trying to use primefaces combined with . In my .xhtml page I have a picklist and commandButton which i

相关标签:
2条回答
  • 2020-12-03 19:16
    <p:commandButton  value="Cancel" oncomplete="PF('yourDialogWidgedVarName').hide();" process="@this"  />
    

    Make sure to use ' when u call the widgetVar name. You can also use immediate="true" or process="@this".

    0 讨论(0)
  • 2020-12-03 19:33

    You can try either of the following , I vote number one, it's a cleaner design IMO

    1. Bring the <p:dialog/> outside of the general <h:form/> and put an <h:form/> inside it instead

        <p:dialog id="dlg" header="#{messages.chooseSkillLevel}" widgetVar="dlg" modal="true" dynamic="true">
            <h:form>
                  <h:dataTable value="#{editSkills.skillsAndLevels}" var="skillslevel">
                      <h:column>
                          #{skillslevel.skill.umiejetnosc}
                      </h:column>
                      <h:column>
                          <p:selectOneMenu value="#{skillslevel.level}" >
                              <f:selectItems value="#{editSkills.levels}" var="level" itemLabel="#{level.stopien}" itemValue="#{level.id}" />
                          </p:selectOneMenu>
                      </h:column>
                  </h:dataTable>
                  <p:commandButton value="#{messages.confirm}" action="#{editSkills.showSkillsAndLevels}" oncomplete="dlg.hide();" />   THIS BUTTON IS NOT FIRED
                  <p:commandButton value="#{messages.cancel}" onclick="dlg.hide()"/>
                 </h:form>
              </p:dialog>
      
    2. Add appendToBody="false" to the <p:dialog/> to ensure the dialog is rendered within the html form in the DOM instead of being auto-relocated to end of HTML body. But this may cause inconsistent rendering in various browsers.

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