Confirmation dialog for dataList ajax swipe event?

UI Components for JSF
Post Reply
User avatar
edvinsyse
Posts: 9
Joined: 26 May 2014, 17:04
Location: Norway
Contact:

21 Jul 2014, 14:40

Is it possible to show a confirmation dialog before executing a swipe event on a dataList? I have the following working code that I would like to add a confirmation step to:

Code: Select all

<p:dataList value="#{userModel.users}" var="user">
    <h:outputText value="#{user.name}"/>
    <p:ajax event="swipeleft" listener="#{userModel.delete}"/>
</p:dataList>
Ideally I would like to combine it with a p:confirmDialog, but it seems confirmDialog is not supported for mobile?
Edvin Syse
_________________________________________
PrimeFaces 5.1 | Wildfly 8.2.0-Final | Mojarra 2.2.8
Mac OS X 10.10.1, Chrome 40.0.2214.45

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

21 Jul 2014, 19:29

Use the swipe event without a listener and just open a normal dialog on the complete. In that dialog you can do whatever you want

User avatar
edvinsyse
Posts: 9
Joined: 26 May 2014, 17:04
Location: Norway
Contact:

21 Jul 2014, 21:53

Thanks for the reply. It seems like confirm dialog is not supported in PFM, could you show me how you would open a dialog on the swipe event, and retain a reference to the user that was swiped so I could issue the delete when the user clicks the confirm-button?
Edvin Syse
_________________________________________
PrimeFaces 5.1 | Wildfly 8.2.0-Final | Mojarra 2.2.8
Mac OS X 10.10.1, Chrome 40.0.2214.45

User avatar
edvinsyse
Posts: 9
Joined: 26 May 2014, 17:04
Location: Norway
Contact:

21 Jul 2014, 22:21

I got it working with the following code:

Code: Select all

<h:form>
    <p:dataList value="#{userModel.users}" var="user" styleClass="ui-listview-inset ui-corner-all">
        <h:outputText value="#{user.name}"/>
        <p:ajax event="swipeleft" oncomplete="PF('confirmDialog').show()"
                listener="#{userModel.onSwipe}" update="@form:dialog:desc"/>
    </p:dataList>

    <p:dialog id="dialog" header="Confirm delete" widgetVar="confirmDialog" style="min-width: 300px">
        Do you really want to delete <h:outputText id="desc" value="#{userModel.user.name}"/>?
        <p:commandButton value="Delete" icon="ui-icon-delete" actionListener="#{userModel.delete}"
                         oncomplete="PF('confirmDialog').hide()"/>
    </p:dialog>
</h:form>
To show the user's name in the confirmation dialog, I had to spesifically update the h:outputText via p:ajax's update="@form:dialog:desc". Can someone explain why it wasn't enough to update the dialog via update="@form:dialog" - shouldn't that have included the h:outputText for update?

Sorry, this is my first day of PFM :)
Edvin Syse
_________________________________________
PrimeFaces 5.1 | Wildfly 8.2.0-Final | Mojarra 2.2.8
Mac OS X 10.10.1, Chrome 40.0.2214.45

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 48 guests