• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

rich:dropSupport not working

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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());
}


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>

i am using richfaces 3.3.3 and JSF 1.2 with JBoss 4 as my application server.
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have a form on your page?
 
salman khalid
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes i have a4j:form.

the following is my code:

<a4j:form id="knowledgeAssessment" ajaxSubmit="true" >


<%if (operation.equalsIgnoreCase("edit")) {%>

<h:inputHidden id="questionId" />
<%}%>

<div id="contentDiv">

<strong>Question</strong>

<h:outputText id="tagQuestion" value="#{knowledgeBean.questionBody}" escape="false" />
<span class="subheading"> <strong>Choice(s)</strong></span> <h:panelGroup rendered="#{knowledgeBean.componentStatus}"> <h:dataTable value="#{knowledgeBean.questionChoices}" var="row" > <h:column> <h:inputText id="choiceList" value="#{knowledgeBean.choiceText[knowledgeBean.row]}" styleClass="input" tabindex="2" readonly="false" size="30" /> </h:column> </h:dataTable> </h:panelGroup> <h:panelGroup rendered="#{knowledgeBean.multipleChoiceStatus}"> <h:selectManyCheckbox id="multipleChoices" layout="pageDirection" value="#{knowledgeBean.multipleChoices}" styleClass="input" tabindex="2"> <f:selectItems value="#{knowledgeBean.allQuestChoices}"/> </h:selectManyCheckbox> </h:panelGroup> <h:panelGroup rendered="#{knowledgeBean.dragDropStatus}"> <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> </h:panelGroup> </div>
<strong> </strong>
<h:commandButton id="submit1" action="#{knowledgeBean.nextQuestion}" styleClass="button" style="width:60px" value="Next" tabindex="6" onclick="hideDiv({duration:0.7});return true;" />  <h:commandButton id="unknown" action="#{knowledgeBean.skipQuestion}" styleClass="button" style="width:100px" value="I don't know" tabindex="6" onclick="hideDiv({duration:0.7});return true;" />  <h:commandButton id="finish" action="#" styleClass="button" style="width:60px" value="Finish" tabindex="6" onclick="javascript:resetTheForm();"/>


</a4j:form>
 
Max Katz
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have a number of panels which are conditionally rendered, for example:

<h:panelGroup rendered="#{knowledgeBean.dragDropStatus}">

During submit, if #{knowledgeBean.dragDropStatus}" evaluates to false, then none of the components inside this panel will be processed and no actions will be called. I would try to run the drag and drop without the rendered on panels.
 
salman khalid
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Max Katz ,
i have removed all the panel groups with rendered attribute. but still the method
public void processDrop(DropEvent dropEvent)
{
System.out.println("---- processDrop");
Dropzone dropzone = (Dropzone)dropEvent.getComponent();
this.moveChoice(dropEvent.getDragValue(), dropzone.getDropValue());
}

is not at all called.

In the working example from richfaces, they have created a separate eventBean for this dropListener. But that shouldn't be a problem.


 
salman khalid
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yesterday, i have spent more than 8 hours on this problem, but still i couldn't understand the problem. you know there is no exception or java script error occurs, when an item is dragged and placed on the drop zone. The indicator is showing the item is correct. But the program didn't come inside the processdrop method.
 
Max Katz
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know what the problem is without running it.. see if you can run the live demo example and see what might be different. You can also post this on RichFaces forum.
 
salman khalid
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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" class="uk.ed.inf.module.bean.KnowledgeAssessBean" scope="session">
<property name="knowledgeAssessService" ref="knowledgeServiceImpl"/>
</bean>
<bean id="eventBean" class="uk.ed.inf.module.bean.EventBean" scope="request">
<property name = "dndBean">
<ref bean = "knowledgeBean"/>

</property>

</bean>

Thanks....
 
reply
    Bookmark Topic Watch Topic
  • New Topic