aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes updating a table on jsp using jquery complex scenario Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "updating a table on jsp using jquery complex scenario" Watch "updating a table on jsp using jquery complex scenario" New topic
Author

updating a table on jsp using jquery complex scenario

Rajesh Khan
Ranch Hand

Joined: Oct 16, 2011
Posts: 230
Hi initially i thought that i could update a whole table in a jsp using jquery.My original approach was as follows

in my jsp i had somethig like this



I was receiving the asynch response asynchronously and then replacing the html of the div section that the table was in. Using the following way



Now the problem is the code would definitely work for a raw HTML code like this passed from a servlet



but what should i do if the table that i was intending to replace in the jsp was originaly built up with a lot of loop JSTL and EL which actually got translated to HTML by the jasper translator.
What I am trying to say is that my servlet has the same object which it could pass to the jsp so that it could generate the table again (saving me the trouble of writing raw html) but the problem is this time its an asynchronous call an I''ll have to do with the raw html which would be too tedious and aggravating for me to write. I waned to know is there any way in which I could actually get the translated code and then out it to the jsp. Something like this




Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

You mention jQuery and then proceed to use no jQuery at all in your code. What's up with that?

Unless I miss what you are trying to do, your problem is solved with a single use of the jQuery .load() method:


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rajesh Khan
Ranch Hand

Joined: Oct 16, 2011
Posts: 230
I am sorry I think i didnt explain it properly .. here is what i wanted

Step1:PageA.jsp(does an asynch call to servletA passing certain parameters)------------------------------>Step2: ServletA(processes the parameters received,creates an object and sets it in the attribute then it calls another jsp page to generate a table on basis of that object. The servlet extracts the html from that jsp page , stores it in a string and writes it back to PageA.jsp)

Your solution
$('#elementContainingTable').load('/url/that/generates/table');
I believe just loads a portion of a particular page into a specific section.Which is not what i am looking for


Let me recap , the servletA first receives the parameters asynchronously from pageA.jsp on the basis of which it generates an object and calls the next jsp page.The next jsp page will construct a table on the basis of the object received from the servlet. In your method the page will be called however since it does not have the object necessary to generate the table.The table will be empty. I hope all that i said makes some sense.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

Rajesh Khan wrote:In your method the page will be called however since it does not have the object necessary to generate the table.The table will be empty.

Not at all. The URL that the Ajax call hits would be the servlet that preps the data and then forwards to the JSP for formatting. I don't see what the problem is -- I do this all the time.
Rajesh Khan
Ranch Hand

Joined: Oct 16, 2011
Posts: 230
Tried it again and it worked. Looks like i was passing invalid parameters the first time.Thanks again
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: updating a table on jsp using jquery complex scenario