View Full Version : Using JSP

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.)

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?

8 Mar 2010, 8:54 AM
Okay partly resolved.

changed on the JSP which removed the issue with white space at top of response.



java.io.PrintWriter pw = response.getWriter();

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
interval: timeDelay,
scope: this
} // serverInterval

console.info('inside login.js!!!');

// -------------------
// *** 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){
// Initial call to load the store with data
} //
// *** dataStore end
// -------------------

// Create a variable to hold our EXT Form Panel.
// Assign various config options as seen.
var loginForm = new Ext.FormPanel({
title:'my title',
// Specific attributes for the text fields for username / password.
// The "name" attribute defines the name of variables sent to the server.
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.