wood burning stoves 2.0*
The moose likes JSF and the fly likes rich:dropSupport not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "rich:dropSupport not working" Watch "rich:dropSupport not working" New topic
Author

rich:dropSupport not working

salman khalid
Greenhorn

Joined: Jun 05, 2005
Posts: 9
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.
Max Katz
Ranch Hand

Joined: Aug 03, 2009
Posts: 72
Do you have a form on your page?
salman khalid
Greenhorn

Joined: Jun 05, 2005
Posts: 9
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

Joined: Aug 03, 2009
Posts: 72
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

Joined: Jun 05, 2005
Posts: 9
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

Joined: Jun 05, 2005
Posts: 9
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

Joined: Aug 03, 2009
Posts: 72
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

Joined: Jun 05, 2005
Posts: 9
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....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: rich:dropSupport not working
 
Similar Threads
how to set and get h:selectBooleanCheckbox value in h:datatabel
Array of Object in DataTable
Problem in using rich:tree in IE6.0
Input row select on data table does not get called
How to Write jQuery into RichFaces?