Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to refresh a table in Struts

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have used table-tag to draw a table in my application using struts framework. I am displaying all the records in the table ,using an iterator . I want to refresh only this table after certain interval (as I have multiple tables in this particular JSP i just want one table to be refershed).
i.e., after refreshing the table the records must be present in the form, as I want to pass the form values to the next request.



The table code is as below.



<table>

<logic:iterate id="running" name="vehiclesRunning">

<tr>

<td width="16%"><bean:message key="asl.vehicleRegNo"/></td>

<td width="11%"><bean:message key="asl.date"/></td>

<?tr>

</logic:iterate>

</table>



I was able to refresh a textbox using Ajax, but unable to refresh a table content.

Can someone help me how to refresh a table either using Ajax/datagrid.


Thanks in Advance
 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I fear refreshing a textbox is perhaps one of the simplest things you can achieve using AJAX. If I'm correct you are dealing with String values when refreshing the textbox value.
However, in case of a table/data-grid, you would have to employ a more complex form of communication, namely, the XML. By 'complex' I am in no way referring to the difficulty of actually implementing it, I simply meant XML is more complex as compared to a String.
What you'll need to do is: Create an XML string at your server capturing the new data to be populated in the table. Once the server sends back the string, you'll have to write a JavaScript snippet, which will parse this XML and create a new table HTML structure. Thereof, substitute the previous table's HTML by this new HTML. For this, place the HTML code of the table within a <DIV> and then you set the 'innerHTML' property of this DIV.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to create a xml string in the server side?can you please let me know.

Thank you in advance.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Sindhu CR",
Please check your private messages regarding an important administrative matter.
-Ben
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bellow is the code to create xml file on server side.
I hope this helps you.

response.setContentType("text/xml");
PrintWriter out=response.getWriter();
out.write("<?xml version='1.0' encoding='ISO-8859-1'?>");
out.write("<main>");
out.write("<?xml version='1.0' encoding='ISO-8859-1'?>");
out.write("<main>");
out.write("<company>");
// out.write("<link>"+""+"</link>");
out.write("<compname>"+"GE1"+ "</compname>");
out.write("<contname>"+"Kanchan"+"</contname>");
out.write("<address>"+"BN"+"</address>");
out.write("<city>"+"Pune"+"</city>");
out.write("</company>");
out.write("<company>");
out.write("<compname>"+"GE2"+ "</compname>");
out.write("<contname>"+"Kanchan"+"</contname>");
out.write("<address>"+"BN"+"</address>");
out.write("<city>"+"Pune"+"</city>");
out.write("</company>");

out.write("<SupplierID>");
out.write("<id>"+"1"+ "</id>");
out.write("<id>"+"2"+ "</id>");
out.write("</SupplierID>");

out.write("</main>");

out.flush();
out.close();
 
Slideshow boring ... losing consciousness ... just gonna take a quick nap on this tiny ad ...
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic