Richfaces drag and drop not working
sridhar89 Jan 28, 2013 2:31 AMHi
I'm working on Rich faces 4. I am trying to use richfaces drag and drop component.
I am using
WELD,
JSF 2.0 as specifications.
when i am trying to use the Example program in my environment the dropListener is not working.
The code snippets this is not working
xhtml:
<rich:panel style="width:133px">
<f:facet name="header">
<h:outputText value="Source List" />
</f:facet>
<a4j:outputPanel layout="block">
<h:dataTable id="src" columns="1" value="#{dragDropBean.source}"
var="fm" footerClass="footerClass">
<h:column>
<a4j:outputPanel layout="block" styleClass="rf-ind-drag">
<rich:dragSource type="#{fm.family}" dragValue="#{fm}" />
<h:outputText value="#{fm.name}"></h:outputText>
</a4j:outputPanel>
</h:column>
<f:facet name="footer">
<a4j:commandButton action="#{dragDropBean.reset}"
value="Start Over" render="src,phptable,cftable,dnettable" />
</f:facet>
</h:dataTable>
</a4j:outputPanel>
</rich:panel>
<rich:panel style="width:133px">
<f:facet name="header">
<h:outputText value="Target List" />
</f:facet>
<a4j:outputPanel layout="block">
<a4j:outputPanel layout="block"
style="width:100px;height:100px; border: 1px solid;">
<rich:dropTarget acceptedTypes="@all" dropValue="PHP"
immediate="true" dropListener="#{dragDropEventBean.processDrop}"
render="phptable, src" />
<h:dataTable id="ssss" columns="1"
value="#{dragDropBean.targetPHP}" var="fm">
<h:column>
<h:outputText value="#{fm.name}"></h:outputText>
</h:column>
</h:dataTable>
</a4j:outputPanel>
</a4j:outputPanel>
</rich:panel>
DragDropEventBean.java
@Named
@ViewScoped
public class DragDropEventBean implements DropListener, Serializable {
/**
*
*/
private static final long serialVersionUID = 7396109085314436722L;
@ManagedProperty(value = "#{dragDropBean}")
private DragDropBean dragDropBean;
public void setDragDropBean(DragDropBean dragDropBean) {
this.dragDropBean = dragDropBean;
}
public void processDrop(DropEvent event) {
dragDropBean.moveFramework((Framework) event.getDragValue());
}
}
but when i am putting the target in the same datatable it is atleast calling the drop listner but still that is throwing the null pointer exception that is :
xhtml :
<rich:panel style="width:133px">
<f:facet name="header">
<h:outputText value="Source List" />
</f:facet>
<a4j:outputPanel layout="block">
<h:dataTable id="src" columns="1" value="#{dragDropBean.source}"
var="fm" footerClass="footerClass">
<h:column>
<a4j:outputPanel layout="block" styleClass="rf-ind-drag">
<rich:dragSource type="#{fm.family}" dragValue="#{fm}" />
<h:outputText value="#{fm.name}"></h:outputText>
</a4j:outputPanel>
</h:column>
<h:column>
<a4j:outputPanel layout="block"
style="width:100px;height:100px;border: 1px solid;">
<rich:dropTarget acceptedTypes="@all" dropValue="PHP"
immediate="true"
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>
</a4j:outputPanel>
</h:column>
<h:column>
<a4j:outputPanel layout="block"
style="width:100px;height:100px; border: 1px solid;">
<rich:dropTarget acceptedTypes="@all" dropValue="PHP"
immediate="true"
dropListener="#{dragDropEventBean.processDrop}"
render="phptable, src" />
<h:dataTable id="ssss" columns="1"
value="#{dragDropBean.targetPHP}" var="fm">
<h:column>
<h:outputText value="#{fm.name}"></h:outputText>
</h:column>
</h:dataTable>
</a4j:outputPanel>
</h:column>
<f:facet name="footer">
<a4j:commandButton action="#{dragDropBean.reset}"
value="Start Over" render="src,phptable,cftable,dnettable" />
</f:facet>
</h:dataTable>
</a4j:outputPanel>
</rich:panel>
I don know why it is not calling when the target is diff panel then why it is dragDropBean is null in second case . Please help ?