View Full Version : Using JSP
Elijah
8 Mar 2010, 8:31 AM
I am using jsp to write the Ajax response and noticed that I am always getting white space in the response prior to the data. (i.e.)
{"results":3,"success":true,"rows":[{"id":0,"occupation":"0priest","name":"0Bill"}
{"id":1,"occupation":"1priest","name":"1Bill"},{"id":2,"occupation":"2priest","name":"2Bill"}]}
I am assuming this is why my combo-box will not populate with the values being passed back that I can see in Firebug.
Suggestions on removing the white space?
Elijah
8 Mar 2010, 8:54 AM
Okay partly resolved.
changed on the JSP which removed the issue with white space at top of response.
out.print(obj);
out.flush();
to
java.io.PrintWriter pw = response.getWriter();
pw.write(obj.toString());
pw.flush();
Elijah
8 Mar 2010, 9:33 AM
From what I can see in the drop down box for the combo box, it has a lot of empty options rendered but the values are not being set for the display.
What am i missing to populate the combo box displayed value?
// Global reference to the datastore
var dsLocations;
// Time delay of X seconds before checking for new alerts
//var timeDelay = 30 * 1000;
// Time delay of every 60 equals minutes before checking for new tasks
var timeDelay = 1 * 60 * 1000;
// need to rename and make the interval calling generic for multiple stores
// To repeatedly call the function that obtains data for a datastore
var serverInterval = {
run: function(){
// specify the datastore variable and load
dsLocations.load();
},
interval: timeDelay,
scope: this
} // serverInterval
Ext.onReady(function(){
console.info('inside login.js!!!');
Ext.QuickTips.init();
// -------------------
// *** dataStore start
dsLocations = new Ext.data.Store({
url: 'API.jsp?api=test03',
reader: new Ext.data.JsonReader(
{
idProperty: 'id',
root: 'rows',
totalProperty: 'results',
fields: ['id', 'occupation', 'name']
},[
{name: 'location', mapping: 'occupation'}
]
) // reader
}); // dsLocations
// Register a listener for a store to check for new data
dsLocations.on('load', checkForNewRecords);
// Enable the interval calling to check server for new data
if(timeDelay > 0){
Ext.TaskMgr.start(serverInterval);
}else{
// Initial call to load the store with data
dsLocations.load();
} //
// *** dataStore end
// -------------------
// Create a variable to hold our EXT Form Panel.
// Assign various config options as seen.
var loginForm = new Ext.FormPanel({
labelWidth:80,
url:'API.jsp',
frame:true,
title:'my title',
defaultType:'textfield',
monitorValid:true,
// Specific attributes for the text fields for username / password.
// The "name" attribute defines the name of variables sent to the server.
items:[{
xtype:'combo',
name:'myLocation',
fieldLabel:'Location',
mode: 'local',
store: dsLocations,
displayField: 'occupation',
// next line fixes the issue of the options disappearing
triggerAction: 'all',
emptyText:'Select a location',
SelectOnFocus: true
}
]}]
});
Mike Robinson
9 Mar 2010, 7:35 AM
I admit that I have not attempted to do such code as this, where the source of values for a particular control is "constantly refreshing." But I do wonder if there are timing-related issues here, that are not being properly handled.
My cursory look-through of the combo-box code is that the combo-box re-queries the underlying data store. But... it would seem... so are you. You're also using "mode: local" instead of "mode: remote." (See also: lastQuery.)
And so... my educated guess is that there is some kind of timing dipsy-doodling (:| going on here with regard to when and how the data store is being queried, and perhaps of exactly what's therefore in the data-store when the combo tries to prepare its list of values for display.
Powered by vBulletin® Version 4.2.3 Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.