drag & drop not working with primefaces omega

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
3bu1
Posts: 6
Joined: 30 Dec 2014, 08:31

21 Sep 2016, 11:30

hi all, recently we have moved to primefaces omega theme earlier we have drag and drop functionality. I am trying to implemet in omega theme, but failed. following is my code any help would be great. thank u in advance.

Code: Select all

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	template="/WEB-INF/template.xhtml">

<ui:define name="head">
	<script>
	
			$(document).ready(function() {
				$(".myFavBlock").hide();
				$(".showHideFav button").click(function() {
					$(".myFavBlock").slideToggle();
				});
			});
			function handleDrop(event, ui) {
		        var selectedServices = ui.draggable;
		        selectedServices.fadeOut('fast');
		    }
		</script>
	</ui:define>
	<ui:define name="title">Patient Registration</ui:define>
	
	<ui:define name="implementation">

		
		<div class="ui-fluid">
			<div class="ui-g">
				<div class="ui-g-12">
					<h:form id="form" enctype="multipart/form-data">
						<p:growl id="msgs" showDetail="true" showSummary="false"
							sticky="false" />
						<div class="card">
							<h1>Patient Registration</h1>
								
							
						</div>

						<!-- Available Services Section -->
						<div class="card">
							<div align="right" class="showHideFav">
									Your Favourite List is here
									<p:commandButton icon="ui-icon ui-icon-star" style="width:30px;"></p:commandButton>
							</div>
							
							<p:fieldset legend="Service Selection / Drag and Drop" id="servicesDraggable">
							<div class="favSideHeading">My Favourite Services</div>
									<p:dataTable id="favourite"
											reflow="true" value="#{registrationBean.favouriteServices}"
											var="fav">
											<p:column style="width:20px">
												<h:outputText id="dragIcon"
													styleClass="ui-icon ui-icon-arrow-4" />
												<p:draggable for="dragIcon" revert="true" helper="clone"
													cursor="move" />
											</p:column>
											<p:column headerText="Service name">
												<p:outputLabel value="#{fav.serviceName}" />
											</p:column>
											<p:column headerText="Price">
												<p:outputLabel value="#{fav.servicePrice}" />
											</p:column>
											<p:column style="width: 40px;">
												<p:commandButton icon="ui-icon ui-icon-trash"
													actionListener="#{registrationBean.deleteFavourite}"
													process="@this" update="favourite :form:msgs">
													<f:attribute name="favId" value="#{fav.id}" />
												</p:commandButton>
											</p:column>
										</p:dataTable>	
						
							</p:fieldset>
							
							<p:fieldset id="selecteServices">
							 <p:outputPanel id="dropArea">
							<p:dataTable 
										reflow="true" value="#{registrationBean.selectedServices}"
										var="service" rowIndexVar="rowIndex"
										selection="#{registrationBean.selectedPatientServices}"
										rowKey="#{service.serviceLabData.serviceHeaderData.serviceId}">

										<p:ajax event="rowSelect" update="@parent" />
										<p:ajax event="rowUnselect" update="@parent" />
										<p:ajax event="rowSelectCheckbox" update="@parent" />
										<p:ajax event="rowUnselectCheckbox" update="@parent" />
										<p:ajax event="toggleSelect" update="@parent" />


										<p:column selectionMode="multiple" style="width:15px;" />
										<p:column headerText="#" style="width: 20px">
						   			#{rowIndex+1}
						   		</p:column>
										<p:column headerText="Service Name">
											<p:outputLabel
												value="#{service.serviceLabData.serviceHeaderData.serviceName}" />
										</p:column>
										<p:column headerText="Fav" style="width: 40px;">
											<p:commandButton icon="ui-icon ui-icon-star"
												actionListener="#{registrationBean.addFavourite}"
												process="@this" update=":form:favourite,:form:msgs">
												<f:attribute name="service"
													value="#{service.serviceLabData.serviceId}" />
											</p:commandButton>
										</p:column>
										<p:column headerText="Stat"
											style="width: 20px;; text-align: center;">
											<p:outputLabel value="#{service.status}" />
										</p:column>
										<p:column headerText="Min Amt."
											style="width: 15%; text-align: right">
											<p:outputLabel
												value="Rs. #{service.serviceLabData.serviceHeaderData.minAmount}" />
										</p:column>
										<p:column headerText="Price"
											style="width: 15%; text-align: right">
											<p:outputLabel
												value="Rs. #{service.serviceLabData.serviceHeaderData.charge}" />
										</p:column>
										<p:columnGroup type="footer">
											<p:row>
												<p:column footerText="Total" colspan="4"
													style="text-align:right;" />
												<p:column colspan="2"
													footerText="Rs. #{registrationBean.serviceMinCharge}"
													style="text-align:right;" styleClass="finalPriceMin" />
												<p:column colspan="1"
													footerText="Rs. #{registrationBean.serviceFullAmount}"
													style="text-align:right;" styleClass="finalPriceTotal" />
											</p:row>
										</p:columnGroup>
										<f:facet name="footer">
											<p:commandButton icon="ui-icon-trash" value="Delete"
												styleClass="deleteServiceButton"
												actionListener="#{registrationBean.deleteService}"
												disabled="#{empty registrationBean.selectedPatientServices}"
												onstart="PF('loaderDialog').show()"
												onsuccess="PF('loaderDialog').hide()" process="@this"
												update="@parent :form:paymentDT" />
										</f:facet>
									</p:dataTable>
							</p:outputPanel>
							</p:fieldset>
							
							
							
							<p:droppable for="selecteServices" tolerance="touch"
										activeStyleClass="ui-state-highlight" datasource="favourite"
										onDrop="handleDrop" id="handleDrop">
										<p:ajax listener="#{registrationBean.onSelectedServiceDrop}"
											process="@form"
											update="dropArea , favourite " />
									</p:droppable>
						</div>
	
						<p:spacer height="20" />
						<!--Payment Section -->


						

						<!-- Action Section -->

						<p:spacer height="10" />
						


						

					</h:form>
				</div>
			</div>
		</div>
	</ui:define></ui:composition>

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

23 Sep 2016, 09:20

I couldn't replicate this issue. Can you please try it without omega theme? Also, this link can help to you; http://www.primefaces.org/showcase/ui/d ... able.xhtml
My test code in Omege Theme & Layout;

Code: Select all

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="/WEB-INF/template.xhtml">

    <ui:define name="head">
        <script>

            $(document).ready(function () {
                $(".myFavBlock").hide();
                $(".showHideFav button").click(function () {
                    $(".myFavBlock").slideToggle();
                });
            });
            function handleDrop(event, ui) {
                var selectedServices = ui.draggable;
                selectedServices.fadeOut('fast');
            }
        </script>
    </ui:define>
    <ui:define name="title">Patient Registration</ui:define>

    <ui:define name="content">


        <div class="ui-fluid">
            <div class="ui-g">
                <div class="ui-g-12">
                    <h:form id="form" enctype="multipart/form-data">
                        <p:growl id="msgs" showDetail="true" showSummary="false"
                                 sticky="false" />
                        <div class="card">
                            <h1>Patient Registration</h1>


                        </div>

                        <!-- Available Services Section -->
                        <div class="card">
                            <div align="right" class="showHideFav">
                                Your Favourite List is here
                                <p:commandButton icon="ui-icon ui-icon-star" style="width:30px;"></p:commandButton>
                            </div>

                            <p:fieldset id="availableCarsField" legend="Available Cars">
                                <p:dataTable id="availableCars" var="car" value="#{dndCarsView.cars}">
                                    <p:column style="width:20px">
                                        <h:outputText id="dragIcon" styleClass="ui-icon ui-icon-arrow-4" />
                                        <p:draggable for="dragIcon" revert="true" helper="clone"/>
                                    </p:column>

                                    <p:column headerText="Id">
                                        <h:outputText value="#{car.id}" />
                                    </p:column>

                                    <p:column headerText="Year">
                                        <h:outputText value="#{car.year}" />
                                    </p:column>

                                    <p:column headerText="Brand">
                                        <h:outputText value="#{car.brand}" />
                                    </p:column>

                                    <p:column headerText="Color">
                                        <h:outputText value="#{car.color}" />
                                    </p:column>
                                </p:dataTable>
                            </p:fieldset>

                            <p:fieldset id="selectedCars" legend="Selected Cars" style="margin-top:20px">
                                <p:outputPanel id="dropArea">
                                    <h:outputText value="!!!Drop here!!!" rendered="#{empty dndCarsView.droppedCars}" style="font-size:24px;" />
                                    <p:dataTable id="selectedCarsTable" var="car" value="#{dndCarsView.droppedCars}" rendered="#{not empty dndCarsView.droppedCars}">
                                        <p:column headerText="Id">
                                            <h:outputText value="#{car.id}" />
                                        </p:column>

                                        <p:column headerText="Year">
                                            <h:outputText value="#{car.year}" />
                                        </p:column>

                                        <p:column headerText="Brand">
                                            <h:outputText value="#{car.brand}" />
                                        </p:column>

                                        <p:column headerText="Color">
                                            <h:outputText value="#{car.color}" />
                                        </p:column>
                                    </p:dataTable>
                                </p:outputPanel>
                            </p:fieldset>

                            <p:droppable for="selectedCars" tolerance="touch" activeStyleClass="ui-state-highlight" datasource="availableCars" onDrop="handleDrop">
                                <p:ajax listener="#{dndCarsView.onCarDrop}" update="dropArea availableCars" />
                            </p:droppable>
                        </div>

                        <p:spacer height="20" />
                        <!--Payment Section -->


                        <!-- Action Section -->

                        <p:spacer height="10" />


                    </h:form>
                </div>
            </div>
        </div>
    </ui:define>
</ui:composition>

3bu1
Posts: 6
Joined: 30 Dec 2014, 08:31

26 Sep 2016, 14:42

issue got solved. there was another form tag in template. When removed it got it. Thanks for response.

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

29 Sep 2016, 16:25

Glad to hear, thanks!

Post Reply

Return to “Omega - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests