This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Drag and drop dynamic elements 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 » Engineering » HTML, CSS and JavaScript
Bookmark "Drag and drop dynamic elements" Watch "Drag and drop dynamic elements" New topic
Author

Drag and drop dynamic elements

Stevenson Anderson
Greenhorn

Joined: Jul 09, 2011
Posts: 13
Hi, I am new to coding. I am working for a production of reporting tool. So in a web page the left panel displays all the available tables in the database. The user must drag any one of the tables,then it must display the columns available in the dragged table. I could able to display the tables from database. For drag n drop, I have used jquery. The script code I have used is given below.

This is the java code written in body.

Here '#makeMeDraggable' is the division where the table names are displayed and '#makeMeDroppable' is the division where the user drop the table. tables is an arraylist variable which contains the table names.
The problem here is after all excuting this, I could able to drag only one table name (the top in the list) and the variable 'str' always contains the last table name only.How can i make all the individual table names draggable and 'str' store only the table name which is being dragged.
I am 'sorry' for the lengthy code but i just want to let you know what i am doing.

Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

You can't. str is a server-side JSP scripting variable and doesn't even exist anymore after the page has been sent to the browser.

You should read this article to understand how JSP works and why this is impossible.

P.S. Putting Java code in a JSP has not been an accepted practice for almost 10 years now.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stevenson Anderson
Greenhorn

Joined: Jul 09, 2011
Posts: 13
Thanks Bear!The article was great.
But suggest me the ways how can I make it possible?(Hope you understand what I need to do, from the previous post of mine)

Thanks again.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Actually, sorry. But I do not.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Drag and drop dynamic elements
 
Similar Threads
add values in select option using ajax and servlet
Load Text file and display in table format.
Regading getElementById
Loading xml in Javascript fails
How to drag and drop a string element?