Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

TUTORIALVaadin lets you build secure, UX-first PWAs entirely in Java.
Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Calling javascript synchronously by Enver Haase, 1 month ago
Drag table row to panel
Hi,
I want to realize a drag drop action on my page, drag one table row to another panel in the bottom of the window to display a new personalized component by using the information of this row, but it doesn't work, do you have any idea?
Thanks
resultTable.setDragMode(TableDragMode.ROW);
resultTable.setDropHandler(new DropHandler()
{
@Override
public AcceptCriterion getAcceptCriterion()
{
// TODO Auto-generated method stub
return AcceptAll.get();
}
@Override
public void drop(DragAndDropEvent event)
{
DataBoundTransferable t = (DataBoundTransferable) event
.getTransferable();
if (!(t.getSourceContainer() instanceof Container.Hierarchical)) {
return;
}
Container.Hierarchical source = (Container.Hierarchical) t
.getSourceContainer();
Object sourceItemId = t.getItemId();
// find and convert the item(s) to move
Object parentItemId = source.getParent(sourceItemId);
String filePath = (String) source.getItem(sourceItemId).getItemProperty("Path").getValue();
// move item(s) to the correct location in the table
AbstractSelectTargetDetails dropData = ((AbstractSelectTargetDetails) event
.getTargetDetails());
Object targetItemId = dropData.getItemIdOver();
if(targetItemId != null)
{
File jsonFileTmp = null;
try
{
String jsonStr = FileUtils.readFileToString(new File("D:\\test1.json"), "UTF-8");
jsonFileTmp = File.createTempFile("html", ".txt");
FileUtils.writeStringToFile(jsonFileTmp, jsonStr);
}
catch(IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
if(jsonFileTmp != null)
{
CustomComponent1 p = new CustomComponent1((new File(filePath)).getName(), jsonFileTmp.getName());
panel.setContent(p);
}
}
}
});
Last updated on
any idea? I saw an example using the treetable, but how to do it with a panel?
Last updated on
You cannot reply to this thread.