0

I want a dialog to show up after I click a commandButton, but it doesn't show up at all. I think the button is submitting the form instead of showing up a dialog. What's more I've tried to make a 'Cancel' commandButton and it is also not working as it should - it works only if I click it first (if I click commandButton which is suppoused to open a dialog first, the cancel button won't work anymore).

Here's my .xhtml:

<ui:define name="content">
     <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();" />
         <p:commandButton value="#{messages.cancel}" onclick="dlg.hide()"/>
       </h:form>
     </p:dialog>
     <h:form>
        <p:messages/>
          <p:pickList value="#{editSkills.skills}" var="skill" effect="none"  converter="#{picklistConverter}"
                itemValue="#{skill.id}" itemLabel="#{skill.umiejetnosc}"  
                showSourceFilter="true" showTargetFilter="true" filterMatchMode="contains" 
                addLabel="#{messages.add}" removeLabel="#{messages.remove}" removeAllLabel="#{messages.removeAll}" >  
                <f:facet name="sourceCaption">#{messages.skillsList}</f:facet>  
                <f:facet name="targetCaption">#{messages.yourSkills}</f:facet>
                <p:ajax event="transfer" listener="#{editSkills.onTransfer}" /> 
                <p:column style="width:100%;">  
                    #{skill.umiejetnosc}  
                </p:column> 
          </p:pickList>      
          <p:commandButton value="#{messages.confirm}" actionListener="#{editSkills.afterSubmit}" update=":dlg" oncomplete="dlg.show();" />  THIS IS THE MENTIONED BUTTON  
          <p:commandButton value="#{messages.cancel}" action="profile" immediate="true"/>  THIS IS THE CANCEL BUTTON
     </h:form>
</ui:define>

What should I do to make it working well?

gadzix90
  • 744
  • 2
  • 13
  • 28
  • Why are you [re-posting](http://stackoverflow.com/q/14381602/1317692) ? – Fallup Jan 19 '13 at 00:45
  • @Fallup, not a repost. There are different concerns in both Qs – kolossus Jan 19 '13 at 03:19
  • @kolossus They are not different they are pretty much connected. The first solution caused this problem, i.e. it broke what was working. Btw I don't know how the OP could tell that first solution concerning the button inside the dialog is working fine when he is now not able to open dialog at all. He shouldn't accept it if he couldn't verify that it is working. – Fallup Jan 19 '13 at 09:38
  • @Fallup Just because the code is the same it doesn't mean that problem is the same too. Previous question was about the commandButton which didn't fire at all. This question is about the dialog. And it may be strange but the dialog was showing up earlier when picklist wasn't submitted. Now everything works fine! – gadzix90 Jan 19 '13 at 09:43
  • @AjMeen I'm not saying this because code is the same. I'm saying this beacause first you had problem with the button not working **IN** dialog. After accepting the solution to that you have problem with the button **OUTSIDE** of the dialog which actually opens the dialog itself. How could you possibly verify the first solution when you were not being able to open the dialog ? I'm really confused – Fallup Jan 19 '13 at 09:51
  • @Fallup I understand your confusion. It's quite complicated: First solution showed me that I have to put the dialog outside the form and put a separate form inside it. When I did that, it turned out that my commandButton outside wasn't working well despite showing up the dialog. There was a conversion problem. When I fixed the problem with commandButton, problem with not showing dialog came up, but I was sure that there is no problem with action of commandbutton any longer. That's why I asked another question. – gadzix90 Jan 19 '13 at 10:13
  • @AjMeen I understand it now. I was missing the part with the conversion problem. Thank you for clarification and sorry for bothering. – Fallup Jan 19 '13 at 10:33
  • @AjMeen, just out of curiosity, how did you resolve that `PropertyNotFoundException` on the selectOneMenu? – kolossus Jan 22 '13 at 04:20
  • @kolossus, I resolved that by implementing a proper converter. – gadzix90 Jan 22 '13 at 08:23

1 Answers1

1

Your code seems fine to me :). However, 1 thing you need to note is that the id and widgetVar attributes of the <p:dialog> must not have the same value. Try something like the following:

<p:dialog id="levelDlg" widgetVar="levelDialog">
Mr.J4mes
  • 9,168
  • 9
  • 48
  • 90