0

I have this button in a .xhtml:

    <p:commandButton id="openDialog"
     value="#{msg.CreateMultiple}"
     onclick="PF('dialogLocations').show();" title="View"
     type="button">
     </p:commandButton>

What it is supposed to do, is to open the dialog dialogLocations which has the next code:

<p:dialog header="#{msg.CreateMultiple}" id="dialogLocations"
            widgetVar="dialogLocations" modal="true"closable="true"
            dynamic="true" closeOnEscape="true">
            <h:form>

                        <p:commandButton id="acceptMultiple_button" value="#{msg.Create}"
                            action="#{locationCreateBean.createMultiple(true)}"
                            styleClass="btn-green internal-margin-left" update="@form">
                        </p:commandButton>

                        <p:commandButton id="cancelMultiple_button"
                            styleClass="btn-red internal-margin-left"
                            onclick="PF('dialogLocations').hide();" value="#{msg.Cancel}"
                            title="View" type="button">
                        </p:commandButton>

                    </div>


                </h:panelGroup>

            </h:form>
        </p:dialog>

The dialog has some inputs also to use in the bean.

My problem is that, when I click the button "openDialog" the dialog opens and the method locationBean.createMultiple(true) is being called, which is the action of the button "acceptMultiple_button" .

Shouldn't the action of the button be triggered when I click the button?

Thanks.

adutra
  • 360
  • 5
  • 15
  • Your expectation is correct. Something else is calling `createMultiple`. If you change the `action` to use a different method entirely (even just an empty `createMultiple2`), is it still called when the dialog opens? – DavidS Apr 24 '15 at 20:31
  • Unless a typo, that `` tag is incorrectly formulated. – Tiny Apr 24 '15 at 20:57
  • I´ve tried that, adding createMultiple2 and it still calls createMultiple. But I checked and in the Xhtml it is only called in that button. And in the bean, it is never called. – adutra Apr 24 '15 at 21:02
  • The was a mistake of pasting the code here. sorry – adutra Apr 24 '15 at 21:03
  • Hold it: so you change your `action` to call `createMultiple2` and something is _still_ calling `createMultiple`? You need to find out what that "something" is. There's no real magic here, JSF won't call methods you don't tell it to. – DavidS Apr 24 '15 at 22:27
  • @tt_dev, even if it is updating the entire form, it won't call the action method of the command button. – DavidS Apr 25 '15 at 18:02
  • @DavidS: sorry, it seems i got it wrong. – tt_emrah Apr 25 '15 at 18:08
  • Does the invocation happen *only* on show of the dialog? Do you have any nested `h:form`s? – kolossus Apr 26 '15 at 23:22
  • That's exactly why it's important to read, understand and respect http://stackoverflow.com/help/mcve when asking questions. – BalusC Apr 27 '15 at 15:20

1 Answers1

0

Solved it. It was a comment on the xhtml surrounded by <!-- --> that has the call to the method. I thought that in a comment wouldn't call the function. But it seems sometimes it calls a comment anyway.

Thanks for the comments.

adutra
  • 360
  • 5
  • 15