Posted by viking boat
on 04.07.2007 07:10
hi,

   I want to know if there is any method or pattern followed for setting 
form data in the html after getting the response from a servlet.

For example i have 3 text boxes, 1 textarea, 3 select list.

 So everytime to set value in the text boxes for example i have to 
create the
 response xml as follows

StringBuffer sb;
sb.append("<?xml version=\"1.0\"   encoding=\"iso-8859-1\" ?>")
  .append("<ajax-response>");
  if(rs != null){
    while(rs.next())
    {
		for (int i = 0; i < arrKey.length; i++) {
			sb.append("<response type=\"element\" id=\"div"+arrKey[i]+"\">");
			if(arrKey[i].equals("dob")){
				sb.append("<input type=\"text\" size=\"15\" name=\""+arrKey[i]+"\" 
value=\""+rs.getString(arrKey[i])+"\" 
onblur=\"validateDate(this.value,this.name)\">");
			}else{
				sb.append("<input type=\"text\" size=\"15\" name=\""+arrKey[i]+"\" 
value=\""+rs.getString(arrKey[i])+"\" >");
			}
	 	        sb.append("</response>") ;
		}
	}
  }
 sb.append("</ajax-response>");

arrKey is array with column names.

Is there is anyway i can create the Response xml and register the 
elements in a more simpler way .This is like Hard Coding names everyway 
i.e. in the servlet as well in the javascript for registering.