Drag and Drop rows between tables in JSP

I have to convert a swing application into a web project. One of the screens in my swing application uses drag and drop of records between two tables. The key is that when one of the rows is picked and dropped in the other table values get allocated to each column accordingly. I need to bring this functionality into a JSP. There is no constraint on using Javascripts. Please help me asap.
Regards,
KK

Yes it is possible, but not so easy. If you'll be at OOW this year, you can come to my session (S301752, Monday 13:00-14:00) - I will show something similar there. If you're not so lucky, you can read the excellent blogpost of my colleague at [http://rutgerderuiter.blogspot.com/2008/07/drag-planboard.html]
Cheers
Roel

Similar Messages

  • Drag and drop row within same table.

    Version 12.1.2
    I am trying to implement drag and drop row within same table, and I am trying to follow this sample from Frank:
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/106-reorder-table-rows-1921121.pdf
    But, I am getting this cast exception. The code I have in my dropEvent bean is identical to whats on the sample.
    oracle.jbo.server.ViewRowImpl cannot be cast to oracle.jbo.uicli.binding.JUCtrlHierNodeBinding
    ADF_FACES-60097:For more information, please see the server's error log for an entry beginning with: ADF_FACES-60096:Server Exception during PPR, #1
    Not sure if anything has changed on 12c release, or if I am missing anything.
    Here is my complete code:
    public DnDAction doDnD(DropEvent dropEvent) {
    RichTable table = (RichTable) dropEvent.getDragComponent();
    List dropRowKey = (List) dropEvent.getDropSite();
    if (dropRowKey == null) {
    return DnDAction.NONE;
    Transferable t = dropEvent.getTransferable();
    DataFlavor<RowKeySet> df = DataFlavor.getDataFlavor(RowKeySet.class, "rowmove");
    RowKeySet rks = t.getData(df);
    Iterator iter = rks.iterator();
    List draggedRowKey = (List) iter.next();
    JUCtrlHierNodeBinding draggeRowNode = (JUCtrlHierNodeBinding) table.getRowData(draggedRowKey);
    Row dragRow = draggeRowNode.getRow();
    JUCtrlHierNodeBinding dropRowObject = (JUCtrlHierNodeBinding) table.getRowData(dropRowKey);
    Row dropRow = dropRowObject.getRow();
    //get the table's ADF JUCtrlHierBinding
    CollectionModel collectionModel = (CollectionModel) table.getValue();
    JUCtrlHierBinding treeBinding = (JUCtrlHierBinding) collectionModel.getWrappedData();
    DCIteratorBinding objectsIterator = treeBinding.getDCIteratorBinding();
    RowSetIterator rsi = objectsIterator.getRowSetIterator();
    int indexOfDropRow = rsi.getRangeIndexOf(dropRow);
    dragRow.removeAndRetain();
    rsi.insertRowAtRangeIndex(indexOfDropRow, dragRow);
    objectsIterator.setCurrentRowIndexInRange(indexOfDropRow);
    AdfFacesContext adfctx = AdfFacesContext.getCurrentInstance();
    adfctx.addPartialTarget(table.getParent());
    return DnDAction.MOVE;
    It does not seem to like this line of code:
    JUCtrlHierNodeBinding draggeRowNode = (JUCtrlHierNodeBinding) table.getRowData(draggedRowKey);
    I would greatly appreciate any help.
    Thanks.

    Well there has bee a changes somehow. using 12c
    table.getRowData(draggedRowKey);
    returns a ViewRowImpl and no longer anything which can be convertet to JUCtrlHierNodeBinding. Anyway, the fix is easy:
        public DnDAction onDepartmentsRowDrop(DropEvent dropEvent) {
            //get the table instance. This information is later used
            //to determine the tree binding and the iterator binding
            RichTable table = (RichTable) dropEvent.getDragComponent();
            List dropRowKey = (List) dropEvent.getDropSite();
            //if no dropsite then drop area was not a data area
            if (dropRowKey == null) {
                return DnDAction.NONE;
            //The transferable is the payload that contains the dragged row's
            //row key that we use to access the dragged row handle in the ADF
            //iterator binding
            Transferable t = dropEvent.getTransferable();
            //get the row key set of the dragged row. The "rowmove" string is the
            //discriminant defined on the drag source and the collectionDrop target.
            DataFlavor<RowKeySet> df = DataFlavor.getDataFlavor(RowKeySet.class, "rowmove");
            RowKeySet rks = t.getData(df);
            Iterator iter = rks.iterator();
            //for this use case the re-order of rows is one-by-one, which means that the rowKeySet
            //should only contain a single entry. If it contains more then still we only look at a
            //singe (first) row key entry
            List draggedRowKey = (List) iter.next();
            //get access to the oracle.jbo.Row instance represneting this table row
            Object objdragg = table.getRowData(draggedRowKey);
            Row dragRow = (Row) objdragg;
            Object objdrop = table.getRowData(dropRowKey);
            Row dropRow = (Row) objdrop;
            //get the table's ADF JUCtrlHierBinding
            CollectionModel collectionModel = (CollectionModel) table.getValue();
            JUCtrlHierBinding treeBinding = (JUCtrlHierBinding) collectionModel.getWrappedData();
            //get access to the ADF iterator binding used by the table and the underlying RowSetIterator.
            //The RowSetIterator allows us to remove and re-instert the dragged row
            DCIteratorBinding departmentsIterator = treeBinding.getDCIteratorBinding();
            RowSetIterator rsi = departmentsIterator.getRowSetIterator();
            int indexOfDropRow = rsi.getRangeIndexOf(dropRow);
            //remove dragged row from collection so it can be added back
            dragRow.removeAndRetain();
            rsi.insertRowAtRangeIndex(indexOfDropRow, dragRow);
            //make row current in ADF iterator.
            departmentsIterator.setCurrentRowIndexInRange(indexOfDropRow);
            //ppr the table
            AdfFacesContext adfctx = AdfFacesContext.getCurrentInstance();
            //note that the refresh of the table didn't work when refreshing the table
            //so I needed to refresh the container component (af:panelStretchLayout).
            adfctx.addPartialTarget(table.getParent());
            return DnDAction.MOVE;
    does the trick. I changed the line to
    //get access to the oracle.jbo.Row instance represneting this table row
            Object objdragg = table.getRowData(draggedRowKey);
            Row dragRow = (Row) objdragg;
    so you don't need the detour through the JUCtrlHierNodeBinding any longer.
    Timo

  • Drag and drop icons between regions

    I have two regions in a page. Each of the regions show employers available in different departments and each employer is represented with icons. is it possible to drag and drop employees between these two regions (departments) and finally save the latest changes made to the employes/deparments into the table?. any ideas are appreciated.
    thanks,
    Surya

    Yes it is possible, but not so easy. If you'll be at OOW this year, you can come to my session (S301752, Monday 13:00-14:00) - I will show something similar there. If you're not so lucky, you can read the excellent blogpost of my colleague at [http://rutgerderuiter.blogspot.com/2008/07/drag-planboard.html]
    Cheers
    Roel

  • RE : Drag and Drop operations between two outlinefields

    Hi,
    Has any one tried the drag and drop operations between two Outline widgets ina
    window.Any help appreciated.
    Thanks
    balsubHi Balsub,
    Here are some lines which can help you :
    First of all, your 2 OutLineFields must be in a draggable state.
    In the event loop of your window, you have to listen to the event
    ObjectDrop
    on the 2 OutLineFields :
    When Self.<MyOutLine1>.ObjectDrop(SourceX = SourceX,
    SourceY = SourceY,
    SourceField = SourceField,
    TargetX = TargetX,
    TargetY = TargetY,
    TargetField = TargetField) do
    When Self.<MyOutLine2>.ObjectDrop(SourceX = SourceX,
    SourceY = SourceY,
    SourceField = SourceField,
    TargetX = TargetX,
    TargetY = TargetY,
    TargetField = TargetField) do
    Then, when you receive this event, the LocateNode() method will give you
    the DisplayNode which is beeing dragged :
    (assume that your OutLineFields are mapped to the class named :
    ClassOutLine,
    and Col is an Integer which is not important here)
    TheSourceLine : ClassOutLine;
    Col : Integer;
    TheSourceLine = (ClassOutLine)((OutLineField)(SourceField).LocateNode(X
    = SourceX,
    Y = SourceY,
    Column = Col));
    If you want to remove this line from the Source OutLineField :
    TheSourceLine.Parent = Nil;
    TheSourceLine.UpdateFieldFromData();
    If you want to insert this line at the end of the Target OutLineField :
    TheSourceLine.Parent = (OutLineField)(TargetField);
    TheSourceLine.UpdateFieldFromData();
    And if you want to insert this line before or after the Target line of
    the Target OutLineField :
    TheTargetLine : ClassOutLine;
    TheTargetLine = (ClassOutLine)((OutLineField)(TargetField).LocateNode(X
    = TargetX,
    Y = TargetY,
    Column = Col));
    TheTargetLine.PrevSibling = TheSourceLine; // Insert the source line
    before the target line
    or
    TheTargetLine.NextSibling = TheSourceLine; // Insert the source line
    after the target line
    TheTargetLine.UpdateFieldFromData();
    I hope this help you !
    - Manuel -
    Manuel Deveaux
    Forte Developer
    Mutuelle Pr&eacute;viade
    FRANCE
    E-Mail : [email protected]
    -----------------------------------------

    There is no configuration for it. It should work.
    Can you try it in a different user account. If it works in a different account, then it is likely something in your current user account that is messed up. If it doesn't work in another user account, then it is likely something with Mail, itself. 
    You could try downloading and installing the 10.6.7 combo update. That may repair what is wrong.

  • How to drag and drop button between two toolbar?

    Hi,everybody :)
    i hava a problem :
    if i have two toolbar in a frame , and there are some button in each, how can i use dnd package to drag and drop button between two toolbar,such as drag one button in a toolbar to the other toolbar ,i write some sample code ,but find some difficult to finish
    can anyone give me some example code?
    Thanks!

    hi:)
    i have done it ,but there is another problem ,after i finish drag the button and drop it into the toolbar,if my mouse across the dragged button ,it will change the color ,can i setup any mathod to disappear the side_effect?
    thank u
    click open to show the other frame
    and the code is as follows:
    import java.awt.*;
    import java.awt.datatransfer.*;
    import java.awt.dnd.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    public class buttondrag implements DragGestureListener, DragSourceListener,
    DropTargetListener, Transferable{
    static JFrame source = new JFrame("Source Frame");
    static JFrame target = new JFrame("Target Frame");
    static final DataFlavor[] supportedFlavors = { null };
    static {
    try {
         supportedFlavors[0] = new DataFlavor(DataFlavor.javaJVMLocalObjectMimeType);
    catch (Exception ex) {
         ex.printStackTrace();
    } Object object; // Transferable methods.
    public Object getTransferData(DataFlavor flavor) {
    if (flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType)) return object;
    else{
    return null;
    public DataFlavor[] getTransferDataFlavors() {
         return supportedFlavors;
    public boolean isDataFlavorSupported(DataFlavor flavor) {
         return flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType);
    } // DragGestureListener method.
    public void dragGestureRecognized(DragGestureEvent ev) {
    ev.startDrag(null, this, this);
    } // DragSourceListener methods.
    public void dragDropEnd(DragSourceDropEvent ev) { }
    public void dragEnter(DragSourceDragEvent ev) { }
    public void dragExit(DragSourceEvent ev) { }
    public void dragOver(DragSourceDragEvent ev) {
         object = ev.getSource();
    public void dropActionChanged(DragSourceDragEvent ev) { } // DropTargetListener methods.
    public void dragEnter(DropTargetDragEvent ev) { }
    public void dragExit(DropTargetEvent ev) { }
    public void dragOver(DropTargetDragEvent ev) { dropTargetDrag(ev); }
    public void dropActionChanged(DropTargetDragEvent ev) { dropTargetDrag(ev); }
    void dropTargetDrag(DropTargetDragEvent ev) { ev.acceptDrag(ev.getDropAction()); }
    public void drop(DropTargetDropEvent ev) {
         ev.acceptDrop(ev.getDropAction());
         try {
         Object target = ev.getSource();
         Object source = ev.getTransferable().getTransferData(supportedFlavors[0]);
         Component component = ((DragSourceContext) source).getComponent();
         Container oldContainer = component.getParent();
         Container container = (Container) ((DropTarget) target).getComponent();
         container.add(component);
         oldContainer.validate();
         oldContainer.repaint();
         container.validate();
         container.repaint();
         catch (Exception ex) {
              ex.printStackTrace();
              ev.dropComplete(true);
    public static void main(String[] arg) {
    JButton button = new JButton("Drag this button");
    JToolBar sbar = new JToolBar();
    JToolBar dbar = new JToolBar();
    JButton open_button = new JButton("Open");
    source.getContentPane().setLayout(null);
    source.setSize(new Dimension(400, 300));
    sbar.add(button);
    sbar.setBounds(new Rectangle(0, 0, 400, 31));
    sbar.add(open_button);
    open_button.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    target.setVisible(true);
    source.getContentPane() .add(sbar);
    target.getContentPane().setLayout(null);
    target.setSize(new Dimension(400, 300));
    target.getContentPane().add(dbar);
    dbar.setBounds(new Rectangle(0, 0, 400, 31));
    dbar.add(new JButton("button1"));
    buttondrag dndListener = new buttondrag();
    DragSource dragSource = new DragSource();
    DropTarget dropTarget1 = new DropTarget(sbar, DnDConstants.ACTION_MOVE, dndListener);
    DropTarget dropTarget2 = new DropTarget(dbar, DnDConstants.ACTION_MOVE, dndListener);
    DragGestureRecognizer dragRecognizer1 = dragSource.createDefaultDragGestureRecognizer(button, DnDConstants.ACTION_MOVE, dndListener);
    source.setBounds(0, 200, 200, 200);
    target.setVisible(false);
    target.setBounds(220, 200, 200, 200);
    source.show();
    }

  • How to drag and drop files between two JFileChooser

    Sir i want to drag and drop files between two JFileChooser i don't know how to do that. So is there any reference code for that so that i can able to do it. I have enabled setDragEnabled(true) for both the jfilechooser now i don't now how to drop files in them means drag file from one jfilechooser and drop it to another JFileChooser,.
    Plz help me this is the requirement in my project.

    Note: This thread was originally posted in the [New To Java|http://forums.sun.com/forum.jspa?forumID=54] forum, but moved to this forum for closer topic alignment.

  • Drag and Drop images between two listviews

    I need a help for listview drag n drop opretion on winform. where  listview1 hold the images and i want to drag images from listview1 to listview2
    and then when i click any button i want all paths of Images which is in the listview2. and also i want to set the image size on listview2. Please help me.

    Hi Ajay Kumar,
    According to your description, you'd like to drag and drop listviewitems between two listviews.
    Here is my example for dropping items between listviews. You could add one imageList control to your form.
    public Form1()
    InitializeComponent();
    this.listView2.AllowDrop = true;
    this.listView1.AllowDrop = true;
    this.listView2.View = System.Windows.Forms.View.LargeIcon;
    this.listView2.DragDrop += new System.Windows.Forms.DragEventHandler(this.OnDragDrop);
    this.listView2.DragEnter += new System.Windows.Forms.DragEventHandler(this.OnDragEnter);
    this.listView1.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.OnItemDrag);
    private void Form1_Load(object sender, EventArgs e)
    DirectoryInfo dir = new DirectoryInfo(@"D:\Material\Emoticons");
    foreach (FileInfo file in dir.GetFiles())
    try
    this.imageList1.Images.Add(Image.FromFile(file.FullName));
    catch
    Console.WriteLine("This is not an image file");
    this.listView1.View = View.LargeIcon;
    this.imageList1.ImageSize = new Size(32, 32);
    this.listView1.LargeImageList = this.imageList1;
    this.listView2.LargeImageList = this.imageList1;
    //or
    //this.listView1.View = View.SmallIcon;
    //this.listView1.SmallImageList = this.imageList1;
    for (int j = 0; j < this.imageList1.Images.Count; j++)
    ListViewItem item = new ListViewItem();
    item.ImageIndex = j;
    this.listView1.Items.Add(item);
    private void OnItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
    DoDragDrop(e.Item, DragDropEffects.Move);
    private void OnDragEnter(object sender,
    System.Windows.Forms.DragEventArgs e)
    if (!e.Data.GetDataPresent(typeof(ListViewItem)))
    e.Effect = DragDropEffects.None;
    return;
    var items = (ListViewItem)e.Data.GetData(typeof(ListViewItem));
    if (items == null)
    e.Effect = DragDropEffects.None;
    else
    e.Effect = DragDropEffects.Move;
    private void OnDragDrop(object sender, System.Windows.Forms.DragEventArgs e)
    ListViewItem items = (ListViewItem)e.Data.GetData(typeof(ListViewItem));
    if (items != null)
    this.listView2.Items.Add((ListViewItem)items.Clone());
    Results:
    If you have any other concern regarding this issue, please feel free to let me know.
    Best regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Drag and drop attachments between two email windows

    Hi together,
    my problem is easy. i cannot drag and drop attachements between two email windows using Apple Mail. On my old MBAir it was no problem. I do not know which configuration i have to change. To drag and drop to the desktob is no problem. Now i have to drop an attachement on the desktop to attach it to a new mail. This cannot be the solution :-)  Please help me.Thank you.
    Noobie :-)

    There is no configuration for it. It should work.
    Can you try it in a different user account. If it works in a different account, then it is likely something in your current user account that is messed up. If it doesn't work in another user account, then it is likely something with Mail, itself. 
    You could try downloading and installing the 10.6.7 combo update. That may repair what is wrong.

  • Regarding - Drag and Drop operations between two outlinefields

    Hi,
    Has any one tried the drag and drop operations between two Outline widgets in a window.Any help appreciated.
    Thanks
    balsub

    There is no configuration for it. It should work.
    Can you try it in a different user account. If it works in a different account, then it is likely something in your current user account that is messed up. If it doesn't work in another user account, then it is likely something with Mail, itself. 
    You could try downloading and installing the 10.6.7 combo update. That may repair what is wrong.

  • New JNDI name created for each drag and drop of database table into table

    Hi All,
    I'm using Netbeans 5.5 with Visual Web Pack with Mysql as backend. Whenever I drag and drop a database table into table component it creates new JNDI (data source) name for each table. I want to use single JNDI name for all tables. If I change the JNDI name to default name then the design disappears and shows error . Is there any option to set the JNDI name unique for all tables?
    Thanks in advance.

    Hi again,
    Well I've tried using the MouseListener / MouseMotionListener approach but it doesn't quite seem to work, although it does get the events correctly. I think the reason is that it doesn't interact correctly with the Java DnD machinery which is something that V.V hinted at. It's something that I may need to look into if / when I have more time available.
    I have to say though that I haven't had any problems with scrollbars - we're making fairly heavy use of large tables and if you drag over a table with a scroll bar and move to the top or bottom then it scrolls as you would expect and allows you to drop the data where you like. For this situation I've used pretty much the same approach as for the toy example above except that I've implemented separate source and destination TransferHandlers (the source table is read-only, and it really doesn't make sense to allow people to drag from the destination table so I've essentially split the functionality of the example handler down the middle).
    I'm not actually particularly in favour of messing too much with the mechanics of DnD, more because of lack of time than anything else. Guess I'll just have to put up with this for the moment. Doesn't help that DnD is so poorly documented by Sun.
    Thanks for all your help.
    Bart

  • How do I drag and drop files between computers when using Home Sharing in ITunes?

    How can I drag music files between computers while using Home Sharing? An older version of ITunes had a Home Sharing icon in the column browser near the playlist so it was easy to drag and drop.

    Hello cacalenni,
    Thanks for using the Apple Support Communities. I understand that you wish to learn how to import songs using Home Sharing in the new iTunes. The following resource should assist you in doing so:
    iTunes 12 for Mac: Use Home Sharing to import items from another iTunes library
    http://support.apple.com/kb/PH19614
    Cheers,
    Matt M.

  • NamedViewCriteria not working when drag and dropped as filtered table.

    Using JDev 11.1.2.1.0.
    I'm attempting to use NamedViewCriteria more and more because, well ... I keep reading it's the way to go. But I'm encountering an aggravating problem. I can't get them to work when I drag and drop as a filtered table onto a page. They work when I apply them in a managed bean, but simply dragging and dropping will not trigger the NamedViewCriteria to display the filtered items correctly.
    Creating a where clause manually works fine.
    Manual Where Clause & drag and drop ViewObject from data control
    (:pBpKey is null or upper(BP_KEY) like '%' || upper(:pBpKey) || '%') AND CinderBusinessPartners.BP_TYPE = 'C'NamedViewCriteria & drag and drop from ViewObject's NamedViewCriteria from data control
    ( ( (CinderBusinessPartners.BP_KEY LIKE ('%' || :pBpKey || '%') ) AND (CinderBusinessPartners.BP_TYPE = 'C' ) ) )There are three problems:
    1) The query pulls back all items. It doesn't retrieve only where BP_TYPE = 'C'.
    2) It is case sensitive. i.e. Enter in A will not pull back the customer Wal-Mart because Wal-mart contains lowercase a's.
    3) If I set the table's "Show Filter" attribute to true, the filter has the text "\*pBpKey\*" filled in by default. uhhh What?
    In the NamedViewCriteria's "UI Hints" tab, I have the "Query Automatically" checkbox selected.
    Any ideas why the NamedViewCriteria isn't "just working"?
    I'll be back with pictures after the break.
    Will

    I've rolled this into a bug post as seen here: BUG: NamedViewCriteria drag and drop as table SNAFU
    Pictures:
    Here is the NVC query
    http://www.williverstravels.com/JDev/Forums/Threads/2381120/Nvc1.jpg
    Here's that dang extra bind variable!
    http://www.williverstravels.com/JDev/Forums/Threads/2381120/Nvc3.jpg
    And just because I like awesome Paint.Net art.
    http://www.williverstravels.com/JDev/Forums/Threads/2381120/Nvc2.jpg
    Hope this helps someone down the road.
    Edited by: LovettWB on Apr 26, 2012 1:59 PM

  • Drag and drop ALV to table control

    Hi all,
    Does anyone know if it is possible to program the drag-and-drop functionality from an ALV list to a table control? I would like to have this feature to let the user enter data on 1 screen. On the left part the user sees an ALV list and on the right the user sees the online transaction. I would like the user to enter data simply by drag and drop instead of having to enter the data.
    Does someone has a sample program for this?
    Regards,
    Kris

    Hi Kris
    I can download the programs and send them to you, but you should give me your e-mail.
    Anyway you can use Drag and Drop if you build your table control by ALV, i.e. ALV GRID.
    But I'm using 4.7 and I don't know how class CL_GUI_ALV_GRID is in your release, I believe the release 4.6B is one of first release whit this class.
    Max

  • I can't seem to drag and drop files between my hardrives?

    They are both formatted MS-DOS (FAT), I can only drag and drop from the hardrives to the desktop not the other way around or between the two? Thanks

    blake1993 wrote:
    Thankyou, I go between a microsoft and mac and was told that this format would work for that, what format would you suggest?
    This depends on what you mean, can you provide more detail when you say, "I go between a microsoft and mac"? Please be descriptive so I can't leave anything up to assumption.

  • How to Drag and Drop in between Stacks?

    I have a folder with various stacks and single images that I would like to sort manually. It seems impossible to drag and drop an image in between two stacks. It always ends up stacked with one or the other. I am being very careful to be sure that neither stack shows a border around it or is lighter than the other. But it makes no difference. Even if I expand both stacks, I can't drop an image in between. I have to completely UNSTACK the images, drag and then RE-STACK. Am I missing something??(running LR 2.4 on OSX 10.5.8)

    Yeah, it's a bit tricky, messing with stacks and drag-and-drop.
    Try going the other way round: drag and drop your stack (by selecting all images of the stack) instead of your single image, sometimes it helps (depending on the situation). The Remove from Stack command also helps to extract a single image from a stack without breaking and re-stacking.

Maybe you are looking for