reference to p:confirmDialog from many buttons

UI Components for JSF
Post Reply
landbo
Posts: 4
Joined: 04 Nov 2010, 23:55

19 Jan 2011, 01:57

When I have one button that use .show() on a confirmDialog all is fine.

When I dynamically add more buttons that use same dialog and click either it shows multiple popups and one big popup with many confirm buttons:
Image


What ca be causing that. I have tried both 2.2.RC2 and SNAPSHOT.

landbo
Posts: 4
Joined: 04 Nov 2010, 23:55

19 Jan 2011, 17:56

This is the code that generates the screenshot from previous post:

A commandlink (inside an ui:repeat)

Code: Select all

<p:commandLink id="accountDeleteButton"
			value="[Delete]"
			onclick="accountDeleteConfirmation.show()"
			update="accountDeleteConfirmationDialog" style="text-decoration: none; float:left; padding-top: 5px; ">
	<f:setPropertyActionListener value="#{account}" target="#{configurationController.currentObjectForDelete}" />
</p:commandLink>  
ConfirmDialog (outside the ui:repeat):

Code: Select all

		<p:confirmDialog id="accountDeleteConfirmationDialog" appendToBody="true"
			message="Are you sure you want to delete the account?"
			header="Please confirm" severity="alert"
			widgetVar="accountDeleteConfirmation">
			<p:commandLink value="[Yes]" update="top,center"
				oncomplete="accountDeleteConfirmation.hide()"
				actionListener="#{configurationController.deleteAccount}"/>
			<p:commandLink value="[No]"
				onclick="accountDeleteConfirmation.hide()" />
		</p:confirmDialog>
Once the the list behind ui:repeat is expanded dynamically with another ajax request. - clicking delete will show many and faulty confirmdialogs.

shuta
Posts: 15
Joined: 25 Dec 2010, 19:20

19 Jan 2011, 20:11

I think the problem is not the ui:repeat, but the fact that you are trying to update (re-render) the confirm dialog using AJAX:

Code: Select all

update="accountDeleteConfirmationDialog"
I had a similar problem a few weeks ago and I was told that updating a confirm dialog is not supported. Your dialog seems to be static, so I guess you could just remove that update tag... otherwise, if you for example want to customize the message before showing the dialog, put the message into a f:facet with the name "message", and only update that facet instead of the entire dialog.

(For normal dialogs, updating the entire dialog seems to work fine though... I only encountered these issues with the ConfirmDialog so far...)

landbo
Posts: 4
Joined: 04 Nov 2010, 23:55

19 Jan 2011, 20:35

You are absolute right - thanks.

In fact it turns out the p:confirmDialog cannot be any part of any element that is updated via ajax. I had to move the confirmDialog away from panel that was ajax updated on some other buttons.

landbo
Posts: 4
Joined: 04 Nov 2010, 23:55

19 Jan 2011, 23:07

Is is not a bug that p:confirmDialog cannot be any part of any element that is updated via ajax ???

It is really annoying as I have to them in parts of pages where they do not otherwise belong.

shuta
Posts: 15
Joined: 25 Dec 2010, 19:20

19 Jan 2011, 23:42

Yep, I also do not like this and it has cost me a lot of time figuring this out :(. But this seems to be a "feature" rather than a "bug"...

emre
Posts: 22
Joined: 25 Jan 2011, 12:30

10 Feb 2011, 17:41

Hi all,

I had a similar issue when I try to update an element using the <p:commandLink> within ui:repeat tag (also using AJAX).
Since form prependId attribute is set to true by default, when you post the form, javax.faces.partial.rendered property should include the
prepended id in front of the updated element's id. (Which is not the case). Solution is setting the prependId to false. Then you can update the elements
using commandLink and Ajax.

Here my test case, (it does not work if prependId is set to true)

Code: Select all

  <h:form prependId="false" id="form">
        <p:panel id="panel" header="Panel">
            <h:outputText id="output" value="#{loginBean.userName}"/>
        </p:panel>
        <p:panel header="User Names">
            <h:panelGrid columns="1">
                <ui:repeat value="#{loginBean.names}" var="name">

                    <p:commandLink ajax="true" update="output">
                        <f:setPropertyActionListener value="#{name}" target="#{loginBean.userName}"/>
                        <h:outputText value="#{name}"/><br/>
                    </p:commandLink>
                </ui:repeat>
            </h:panelGrid>
        </p:panel>
    </h:form>
I hope this helps 8-) ...

Emre

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

10 Feb 2011, 17:46

I think you can now update a dialog itself with ajax, we have beaten that limitation with 2.2.

confirmDialog doesn't have it now, you can create a feature request. Same solution shall apply.

emre
Posts: 22
Joined: 25 Jan 2011, 12:30

10 Feb 2011, 18:16

Hi Cagatay,

In my case I was trying to update content of the dialog using the command links created in ui:repeat tags. I have primefaces-2.2.RC2. (I tried to upgrade to v.2.2 but then started getting some "Unexpected error restoring state for component with id j_idt3. Cause: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0." error. Then reverted to v.2.2 RC2)
The dialog to be updated:

Code: Select all

   <p:dialog id="editDialog" closable="true" widgetVar="dialog">
                        <ui:insert name="lineEdit">
                            <ui:include src="/components/#{bean.editedLine}.xhtml"/>
                        </ui:insert>
             </p:dialog>
The command links updating the dialog:

Code: Select all

  <p:panel header="Composition">
                    <h:panelGrid columns="1" bgcolor="yellow">
                        <ui:repeat value="#{bean.lines}" var="line">
                            <p:commandLink ajax="true" update="editDialog" oncomplete="dialog.show()">
                                <f:setPropertyActionListener value="#{line}" target="#{bean.editedLine}"/>
                                <h:outputText value="#{line}"/><br/>
                            </p:commandLink>
                      </ui:repeat>
                    </h:panelGrid>
                </p:panel>
Without setting prependId to false, it does not update dialog. When I checked the post parameters, I see it is passing javax.faces.partial.render=editDialog (I think the form id should be prepended to this id)
I am wondering whether this issue has been beaten with 2.2? Do you think this is a feature or a bug?
Regards
Emre

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 7 guests