2 Replies Latest reply on Jul 15, 2010 10:23 AM by salmankhalid

    rich:dropSupport not working

    salmankhalid

      Hi, I am using JSF+SPRING for my web application. In JSF, i am using richfaces for component development. I am using drag and drop component for implementing one of my requirement. But rich:dropsupport is not all working on my project. Infact rich:dropsupport dropListener didn't work, and its processDrop method didn't even call in backed bean.

       

      here is my source code. I will appreciate your help in this regard.

       

       

      <rich:dragIndicator id="indicator" />                                                                
                  <rich:panel style="width:133px">
                    <f:facet name="header">
                        <h:outputText value="Source List" />                       
                    </f:facet>
                    <h:dataTable id="src"  value="#{knowledgeBean.questionChoices}" var="row" footerClass="footerClass">
                    <h:column>                                  
                            <a4j:outputPanel style="width:100px;border:1px solid gray;padding:2px" layout="block">
                                <rich:dragSupport dragIndicator=":indicator" dragType="text" dragValue="#{row}"  >
                                  
                                     <rich:dndParam value="#{row.description}" name="label"/>
                                </rich:dragSupport>
                                <h:outputText value="#{row.description}"></h:outputText>
                            </a4j:outputPanel>
                        </h:column>
                     
                    </h:dataTable>
                </rich:panel>

       

                <rich:panel styleClass="dropTargetPanel">
                    <f:facet name="header">
                        <h:outputText value="Selected Values" />        
                    </f:facet>
                    <rich:dropSupport id="dragChoices" acceptedTypes="text"  dropListener="#{knowledgeBean.processDrop}"          
                        reRender="dragChoicetable,src">
                      
                    </rich:dropSupport>                                                           
                                                         
                    <h:dataTable id="dragChoicetable"  value="#{knowledgeBean.draggedItems}" var="fm1">
                        <h:column>                             
                            <h:outputText value="#{fm1.description}"></h:outputText>
                         
                        </h:column>            </h:dataTable>            
                                                
                                                        
                </rich:panel>        

       

       

      My managed Bean:

       

                /**
         * @return the questionChoices
         */
        public List<JcmQuestionChoice> getQuestionChoices() {
          questionChoices = knowledgeAssessService.getAll("JcmQuestionChoice", "jcmQuestion.questionId",
              this.questionId);
      this.initList();
          return questionChoices;
        }

       

        /**
         * @param questionChoices the questionChoices to set
         */
        public void setQuestionChoices(List<JcmQuestionChoice> questionChoices) {
          this.questionChoices = questionChoices;
        }              

       

       

       

      /**
         * @return the knowledgeAssessService
         */
        public KnowledgeAssessService getKnowledgeAssessService() {
          return knowledgeAssessService;
        }

       

        /**
         * @param knowledgeAssessService the knowledgeAssessService to set
         */
        public void setKnowledgeAssessService(KnowledgeAssessService knowledgeAssessService) {
          this.knowledgeAssessService = knowledgeAssessService;
        }

       

       

      /**
         * @return the draggedItems
         */
        public ArrayList getDraggedItems() {
          
            return draggedItems;
        }

       

        /**
         * @param draggedItems the draggedItems to set
         */
        public void setDraggedItems(ArrayList draggedItems) {
            this.draggedItems = draggedItems;
        }
        
        private void initList()
        {
            draggedItems = new ArrayList();
       
       
        }
        public void moveChoice(Object fm, Object family)
        {
       
        if(draggedItems != null)
        {
        int ind = questionChoices.indexOf(fm);
        if(ind > -1)
        {
            draggedItems.add(questionChoices.get(ind));
            questionChoices.remove(ind);
        }
        }
        }
        public void processDrop(org.richfaces.event.DropEvent dropEvent)
        {
        System.out.println("---- processDrop");
        Dropzone dropzone = (Dropzone)dropEvent.getComponent();
        this.moveChoice(dropEvent.getDragValue(), dropzone.getDropValue());
        }

        • 1. Re: rich:dropSupport not working
          salmankhalid

          Also i am using Spring for JSF managed beans, using the following piece of code in my faces-config file.

           

           

          <application>
            <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
          </application>

           

          and also i am using richfaces 3.3.3 and JSF 1.2 with JBoss 4 as my application server.

          • 2. Re: rich:dropSupport not working
            salmankhalid

            I have figured out the problem. There should be a  seperate event bean for drop listener + the main bean scope should be  set to "session" not "request".

            here is my code:

            <bean id="knowledgeBean"  scope="session">
                    <property name="knowledgeAssessService" ref="knowledgeServiceImpl"/>
                </bean>
                <bean id="eventBean"  scope="request">
                    <property name = "dndBean">
                        <ref bean = "knowledgeBean"/>
                      
                    </property>

             

                </bean>

             


            Thanks....