rich:dropSupport not working
salmankhalid Jul 13, 2010 12:37 PMHi, 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());
}