Ajax Database query:updating my javascript array from request attribute
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, June 19, 2006 12:40 AM

I am facing a problem in updating my java script array which is 2-Dimensional. I use a AJAX call through which I call a structs action servlet which gets the value from the DB. It updates this value in my request attribute of the servlet. Here in this java script function I have used java Scriplets to retrive the values & place it in global array function onStatusChange() { updateArray( ) } This is a function which I call in refresh method function updateArray( ) { <% ArrayList objects = (ArrayList) request.getSession().getAttribute( "OEContent"); SetResult set=null; Iterator itr = objects.iterator(); %> Glob   More>>

I am facing a problem in updating my java script array which is 2-Dimensional. I use a AJAX call through which I call a structs action servlet which gets the value from the DB. It updates this value in my request attribute of the servlet. Here in this java script function I have used java Scriplets to retrive the values & place it in global array

function onStatusChange()
{
updateArray( )
}

This is a function which I call in refresh method

function updateArray( )
{

<%
ArrayList objects = (ArrayList) request.getSession().getAttribute(
"OEContent");
SetResult set=null;
Iterator itr = objects.iterator();

%>
Globalarray= new Array( <%=objects.size()%>);

<%
int i=0;
while (itr.hasNext())
{
set=(SetResult) itr.next();
%>

tempArray = new Array( <%=4%>);
tempArray[0] =' <%=set.getType()%>';
tempArray[1] = ' <%=set.getName()%>';
tempArray[2] =' <%= set.getXpos()%>';
tempArray[3] = ' <%=set.getYpos()%>';
Globalarray[ <%=i%>] = tempArray;
<%
i++;
}
%>
}


Now the problem in this I have used java scriplet which only runs only once when the page loads. But I want when i say refresh in the menu & the whole function should get executed as I am querying the database through my servlet & stored the values in my request attribute.

So is there is any alternative to get & store the values into my java Script array from the request attribute..

   <<Less
About | Sitemap | Contact