1 2 Previous Next 24 Replies Latest reply on Apr 23, 2012 1:54 PM by bwilly

    RichFaces 4.1: dropListener is not working at drag and drop.

    afuentes

      Hi,

      first of all, I am using Richfaces 4.1.

       

      I am trying to use the Drag and Drop component, and everything is fine except I can not make the droplistener invoked. I know there were been some problems related this one with old version of RichFaces, but I can't find anything about this component is not working.

       

      I don't write the whole code since is nearly the same you can get on demo pages.

       

      The Drag and Drop code is like below:

       

      <rich:panel>

          <f:facet name="header">

              <h:outputText value="Role List" />

          </f:facet>

          <rich:dataGrid id="allRolesTableID" columns="1" value="#{fillComponent.roleList}" var="item">

              <a4j:outputPanel>

                  <rich:dragSource type="ppp" dragValue="#{item}" dragIndicator="ind" />

                  <h:outputText value="#{item.name}"></h:outputText>

              </a4j:outputPanel>

          </rich:dataGrid>

      </rich:panel>

       

      <rich:panel>

          <f:facet name="header">

              <h:outputText value="Access Roles" />

          </f:facet>

          <rich:dropTarget acceptedTypes="@all" dropValue="access" dropListener="#{roleManager.processAccessDrop}"

              render="accessRolesTableID"/>

       

          <rich:dataGrid id="accessRolesTableID" columns="1"

              value="#{roleManager.appManager.accessRoles}" var="item">

              <h:outputText value="#{item.name}"></h:outputText>

          </rich:dataGrid>

      </rich:panel>

                                             

      With this code, the function roleManager.processAccessDrop is never called

      If someone has been able to make it work, please tell me. Anyway, whatever idea someone can suggest will be appreciated!!!

       

      Regards.

      /Alberto

        • 1. Re: RichFaces 4.1: dropListener is not working at drag and drop.
          bleathem

          I cant' tell from the above code snippet - but you do have this embeded in a h:from, right?

          • 2. Re: RichFaces 4.1: dropListener is not working at drag and drop.
            afuentes

            Brian, thanks for the reply!

             

            Yes, the code above is inside a h:form. I have just tested without the rich:tabPanel, since the code is inside rich:tab, but the dropListener function is not called either.

            • 3. Re: RichFaces 4.1: dropListener is not working at drag and drop.
              ppitonak

              Hi,

               

              it works fine for me with RichFaces 4.1.1-SNAPSHOT. Could you please provide more info about your environment? Please submit also your listener's signature.

               

              Regards,

              Palo

              • 4. Re: RichFaces 4.1: dropListener is not working at drag and drop.
                afuentes

                Hi Pavol,

                I am using RichFaces 4.1 Final with Mojarra JSF API (javax.faces/2.1) 2.1.2 (20110613-FCS).

                 

                I am not able to find RichFaces 4.1.1-SNAPSHOT to check it!

                 

                The dropListener signature is:

                public void processAccessDrop(DropEvent event)

                {

                     ........

                }

                 

                Thanks for your interest!

                /Alberto

                • 5. Re: RichFaces 4.1: dropListener is not working at drag and drop.
                  ppitonak

                  Hi, copied your use-case into my app and it works fine in following environment:

                  • RichFaces 4.1.0.Final
                  • JBoss AS 7.1.0.CR1 (with bundled Mojarra 2.1.5)
                  • OpenJDK Runtime Environment 1.6.0_22-b22 @ Linux
                  • Chrome 16.0.912.75 @ Linux i686
                  • 6. Re: RichFaces 4.1: dropListener is not working at drag and drop.
                    afuentes

                    Hi Pavol,

                    I have just updated the JSF to mojarra 2.1.6, and I have tested with Firefox 9.0.1 and Chrome, but the results remains the same.

                     

                    My application server is Tomcat 7.0.21 instead of JBoss and the java version is 1.6.0.26 from Sun,and well, I'm under windows. But this should not affect the application behaviour.

                     

                    The code, removing headers, footers and leaving only the Drag and Drop functionality is....

                     

                    <h:form id="formID">

                                       

                                                    <h:outputStylesheet>

                                                        .valign { vertical-align:top; }

                                                        .rf-ind-drag.default{

                                                            padding-left:30px;

                                                            background-image: url("#{facesContext.externalContext.requestContextPath}/images/dnd/default.gif");

                                                            background-position: 5px;

                                                            background-repeat: no-repeat;

                                                        }

                                                        .rf-ind-drag.accept{

                                                            background-image: url("#{facesContext.externalContext.requestContextPath}/images/dnd/accept.gif");

                                                            background-position: 5px;

                                                            background-repeat: no-repeat;

                                                            border:2px solid green

                                                        }

                                                        .rf-ind-drag.reject{

                                                            border:2px solid red;

                                                            background-image: url("#{facesContext.externalContext.requestContextPath}/images/dnd/reject.gif");

                                                            background-position: 5px;

                                                            background-repeat: no-repeat;

                                                        }

                                                    </h:outputStylesheet>

                                                    <rich:dragIndicator id="ind" acceptClass="accept" rejectClass="reject" draggingClass="default">

                                                        Suelta el elemento en el area apropiada...

                                                    </rich:dragIndicator>

                                                    <h:panelGrid columns="3" width="100%" columnClasses="valign, valign, valign">

                                                        <rich:panel>

                                                            <f:facet name="header">

                                                                <h:outputText value="Role List" />

                                                            </f:facet>

                                                            <rich:dataGrid id="allRolesTableID" columns="1" value="#{fillComponent.roleList}" var="item">

                                                                <a4j:outputPanel>

                                                                    <rich:dragSource type="ppp" dragValue="#{item}" dragIndicator="ind" />

                                                                    <h:outputText value="#{item.name}"></h:outputText>

                                                                </a4j:outputPanel>

                                                            </rich:dataGrid>

                                                        </rich:panel>

                                            

                                                        <rich:panel>

                                                            <f:facet name="header">

                                                                <h:outputText value="Access Roles" />

                                                            </f:facet>

                                                            <rich:dropTarget acceptedTypes="@all" dropValue="access" dropListener="#{roleManager.processAccessDrop}"

                                                                render="accessRolesTableID"/>

                                            

                                                            <rich:dataGrid id="accessRolesTableID" columns="1"

                                                                value="#{roleManager.appManager.accessRoles}" var="item">

                                                                <h:outputText value="#{item.name}"></h:outputText>

                                                            </rich:dataGrid>

                                                        </rich:panel>

                                            

                                                        <rich:panel>

                                                            <f:facet name="header">

                                                                <h:outputText value="Admin Roles" />

                                                            </f:facet>

                                                            <rich:dropTarget acceptedTypes="@all" dropValue="admin" dropListener="#{roleManager.processAdminnnDrop}"

                                                                render="adminRolesTableID"/>

                                            

                                                            <rich:dataGrid id="adminRolesTableID" columns="1"

                                                                value="#{roleManager.appManager.adminRoles}" var="item">

                                                                <h:outputText value="#{item.name}"></h:outputText>

                                                            </rich:dataGrid>

                                                        </rich:panel>

                                                       </h:panelGrid>

                                                   

                                                    <a4j:commandButton value="#{msgs['general.Accept']}" actionListener="#{roleManager.saveApplicationListener}" render="treeID"/>

                                    </h:form>

                     

                    Regards.

                    /Alberto

                    • 7. Re: RichFaces 4.1: dropListener is not working at drag and drop.
                      ppitonak

                      Alberto,

                       

                      I tried my application on Tomcat 7 and with Mojarra 2.1.6. I tried both Chrome and Firefox and it works fine. Can you check that you have <h:head> on your page? Also please have a look into Firebug or Chrome's console to check that there are no JavaScript errors and that all resources are correctly loaded.

                       

                      Regards,

                      Palo

                      • 8. Re: RichFaces 4.1: dropListener is not working at drag and drop.
                        afuentes

                        Hi Pavol,

                        I used facelets and the h:head is at the template, so, it should work, and the page apparently is correctly rendered.

                        <script type="text/javascript" src="/EEAD2/javax.faces.resource/jsf.js.jsf?ln=javax.faces"></script>

                        <script type="text/javascript" src="/EEAD2/javax.faces.resource/jquery.js.jsf"></script>

                        <script type="text/javascript" src="/EEAD2/javax.faces.resource/richfaces.js.jsf">

                        </script><script type="text/javascript" src="/EEAD2/javax.faces.resource/richfaces-queue.js.jsf"></script>

                        <script type="text/javascript" src="/EEAD2/javax.faces.resource/richfaces-base-component.js.jsf"></script>

                        <script type="text/javascript" src="/EEAD2/javax.faces.resource/status.js.jsf?ln=org.richfaces"></script>

                        <script type="text/javascript" src="/EEAD2/javax.faces.resource/dnd-indicator.js.jsf?ln=org.richfaces"></script>

                        <link type="text/css" rel="stylesheet" href="/EEAD2/rfRes/indicator.ecss.jsf?db=eAE78Y1hMgAGmQJS&amp;ln=org.richfaces" />

                        <link type="text/css" rel="stylesheet" href="/EEAD2/rfRes/panel.ecss.jsf?db=eAE78Y1hMgAGmQJS&amp;ln=org.richfaces" />

                        <script type="text/javascript" src="/EEAD2/javax.faces.resource/richfaces-event.js.jsf"></script>

                        <link type="text/css" rel="stylesheet" href="/EEAD2/rfRes/datagrid.ecss.jsf?db=eAE78Y1hMgAGmQJS&amp;ln=org.richfaces" />

                        <script type="text/javascript" src="/EEAD2/javax.faces.resource/jquery.position.js.jsf"></script>

                        <script type="text/javascript" src="/EEAD2/javax.faces.resource/jquery-ui-core.js.jsf?ln=org.richfaces"></script>

                        <script type="text/javascript" src="/EEAD2/javax.faces.resource/jquery-dnd.js.jsf?ln=org.richfaces"></script>

                        <script type="text/javascript" src="/EEAD2/javax.faces.resource/dnd-draggable.js.jsf?ln=org.richfaces"></script>

                        <script type="text/javascript" src="/EEAD2/javax.faces.resource/dnd-droppable.js.jsf?ln=org.richfaces"></script>

                         

                        I can't tell if it is something left.

                         

                        The javascript reports a Null Exception

                        <?xml version='1.0' encoding='UTF-8'?> <partial-response><error><error-name>class java.lang.NullPointerException</error-name><error-message><![CDATA[]]></error-message></error></partial-response>

                        from http://localhost/EEAD2/javax.faces.resource/jsf.js.jsf?ln=javax.faces line 1, but I am not able to interpret what it's going wrong.

                        • 9. Re: RichFaces 4.1: dropListener is not working at drag and drop.
                          ppitonak

                          Please check that there is no NullPointerException inside your drop listener method.

                          • 10. Re: RichFaces 4.1: dropListener is not working at drag and drop.
                            afuentes

                            Hi Pavol,

                            that is the problem, it doesn't matter what I put inside the dropListener method, since it is never called!!!

                             

                            public void processAccessDrop(DropEvent event)

                            {

                                    System.out.println(" - processAccessDrop!!");

                            }

                             

                            public void processAdminDrop(DropEvent event)

                            {

                                    System.out.println(" - processAdminDrop!!");

                            }

                             

                            The code inside the methods is never executed.

                             

                            Regards.

                            /Alberto

                            • 11. Re: RichFaces 4.1: dropListener is not working at drag and drop.
                              goravuee

                              I am also facing the same issue.DropListener is not being invoked.

                              I am using mojara, rich faces 4.1.0.Final, tomcat 6.0.32

                              There are no javascript error, no nullpointer exception.

                               

                              Sample page:-

                              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

                              <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:a4j="http://richfaces.org/a4j"

                                  xmlns:rich="http://richfaces.org/rich">

                                  <f:view>

                                  <h:head>

                                  </h:head>

                                  <h:form id="form">

                                   <h:outputStylesheet>        

                                      .panelc { width:25%; }        

                                      .valign { vertical-align:top; }        

                                      .dropTargetPanel { width: 90%; }        

                                      .footerClass {            

                                          text-align: center;            

                                          padding-top: 5px;        

                                  }

                                  .rf-ind-drag{            

                                  font-size:11px;            

                                  cursor:pointer;            

                                  width:100px;            

                                  border:1px solid blue;            

                                  padding:2px        

                                  }

                                  .rf-ind-acpt{border:2px solid green}        

                                  .rf-ind-rejt{border:2px solid red}    

                              </h:outputStylesheet>

                                 

                                      <h:panelGrid columnClasses="panelc valign, valign, valign, valign"

                                          columns="4" width="100%">

                                          <rich:panel style="width:133px">

                                              <f:facet name="header">

                                                  <h:outputText value="Source List" />

                                              </f:facet>

                                              <h:dataTable id="src" columns="1" value="#{dragDropBean.source}"

                                                  var="fm" footerClass="footerClass">

                                                  <h:column>

                                                      <a4j:outputPanel layout="block" styleClass="rf-ind-drag">

                                                       <rich:dragIndicator id="ind" acceptClass="rf-ind-acpt" rejectClass="rf-ind-rejt" draggingClass="default">

                                                     

                                                                                          <h:outputText value="#{fm.family}"  />

                                                     

                                                        </rich:dragIndicator>

                                                     

                               

                                                          <rich:dragSource type="#{fm.family}" dragValue="#{fm}"  dragIndicator="ind"/>

                                                          <h:outputText value="#{fm.name}"></h:outputText>

                                                     

                                                  </h:column>

                                                  <f:facet name="footer">

                                                      <a4j:commandButton action="#{dragDropBean.reset}"

                                                          value="Start Over" render="src,phptable,cftable,dnettable" />

                                                  </f:facet>

                                              </h:dataTable>

                                          </rich:panel>

                                          <rich:panel styleClass="dropTargetPanel">

                                              <f:facet name="header">

                                                  <h:outputText value="PHP Frameworks" />

                                              </f:facet>

                                             

                                              <rich:dropTarget acceptedTypes="@all" dropValue="php"

                                                  dropListener="#{DragDropEventBean.processDrop}"

                                                  render="phptable, src" />

                                             

                                              <h:dataTable id="phptable" columns="1"

                                                  value="#{dragDropBean.targetPHP}" var="fm">

                                                  <h:column>

                                                      <h:outputText value="#{fm.name}"></h:outputText>

                                                  </h:column>

                                              </h:dataTable>

                                          </rich:panel>

                                          <rich:panel styleClass="dropTargetPanel">

                                              <f:facet name="header">

                                                  <h:outputText value=".NET Frameworks" />

                                              </f:facet>

                                              <rich:dropTarget acceptedTypes="dotNet" dropValue="dotNet"

                                                  dropListener="#{DragDropEventBean.processDrop}"

                                                  render="dnettable, src" />

                                              <h:dataTable id="dnettable" columns="1"

                                                  value="#{dragDropBean.targetDotNet}" var="fm">

                                                  <h:column>

                                                      <h:outputText value="#{fm.name}"></h:outputText>

                                                  </h:column>

                                              </h:dataTable>

                                          </rich:panel>

                                          <rich:panel styleClass="dropTargetPanel">

                                              <f:facet name="header">

                                                  <h:outputText value="ColdFusion Frameworks" />

                                              </f:facet>

                                              <rich:dropTarget acceptedTypes="cf" dropValue="cf"

                                                  dropListener="#{DragDropEventBean.processDrop}"

                                                  render="cftable, src" />

                                              <h:dataTable id="cftable" columns="1"

                                                  value="#{dragDropBean.targetCF}" var="fm">

                                                  <h:column>

                                                      <h:outputText value="#{fm.name}"></h:outputText>

                                                  </h:column>

                                              </h:dataTable>

                                          </rich:panel>

                                      </h:panelGrid>

                                  </h:form>

                                  <a4j:outputPanel ajaxRendered="true">

                                      <h:messages></h:messages>

                                  </a4j:outputPanel>

                                   </f:view>

                              </ui:composition>

                              • 12. Re: RichFaces 4.1: dropListener is not working at drag and drop.
                                ppitonak

                                Hi,

                                 

                                since I was not able to reproduce drop listener error, could you provide a simpe Maven project with which I could reproduce the bug? Thanks.

                                 

                                Regards,

                                Palo

                                • 13. Re: RichFaces 4.1: dropListener is not working at drag and drop.
                                  afuentes

                                  Hi Pavol,

                                  I'm not using maven, but eclipse, I'm sorry!

                                   

                                  But I can write you the web.xml, faces-config.xml, libraries or whatever you need....just ask what you need and I'll try to send you!!

                                   

                                  Regards.

                                  /Alberto

                                  • 14. Re: RichFaces 4.1: dropListener is not working at drag and drop.
                                    ppitonak

                                    Even zipped Eclipse project would help.

                                    1 2 Previous Next