View Full Version : Combo Box Loading Issue

22 Mar 2011, 1:59 PM
I'm new to extJs and loading my first combox box. I'm using RPC service which is working and returning the following when called. Here is my extjs setup as well, anyone see where my issue is because the browser isnt telling me much even in javascript debug.

Don N.

returned JSON data:
{"result":[{"stateName":"Alabama","stateCode":"AL"},{"stateName":"Alaska","stateCode":"AK"},{"stateName":"Arkansas","stateCode":"AR"},{"stateName":"Arizona","stateCode":"AZ"},{"stateName":"California","stateCode":"CA"},{"stateName":"Colorado","stateCode":"CO"},{"stateName":"Connecticut","stateCode":"CT"},{"stateName":"Delaware","stateCode":"DE"},{"stateName":"District of Columbia","stateCode":"DC"},{"stateName":"Florida","stateCode":"FL"},{"stateName":"Georgia","stateCode":"GA"},{"stateName":"Hawaii","stateCode":"HI"},{"stateName":"Idaho","stateCode":"ID"},{"stateName":"Illinois","stateCode":"IL"},{"stateName":"Indiana","stateCode":"IN"},{"stateName":"Iowa","stateCode":"IA"},{"stateName":"Kentucky","stateCode":"KS"},{"stateName":"Louisiana","stateCode":"LA"},{"stateName":"Main","stateCode":"ME"},{"stateName":"Maryland","stateCode":"MD"},{"stateName":"Massachusetts","stateCode":"MA"},{"stateName":"Michigan","stateCode":"MI"},{"stateName":"Minnesota","stateCode":"MN"},{"stateName":"Mississippi","stateCode":"MS"},{"stateName":"Missouri","stateCode":"MO"},{"stateName":"Montana","stateCode":"MT"},{"stateName":"Nebraska","stateCode":"NE"},{"stateName":"Nevada","stateCode":"NV"},{"stateName":"New Hampshire","stateCode":"NH"},{"stateName":"New Jersey","stateCode":"NJ"},{"stateName":"New Mexico","stateCode":"NM"},{"stateName":"New York","stateCode":"NY"},{"stateName":"North Carolina","stateCode":"NC"},{"stateName":"North Dakota","stateCode":"ND"},{"stateName":"Ohio","stateCode":"OH"},{"stateName":"Oklahoma","stateCode":"OK"},{"stateName":"Oregon","stateCode":"OR"},{"stateName":"Pennsylvania","stateCode":"PA"},{"stateName":"Rhode Island","stateCode":"RI"},{"stateName":"South Carolina","stateCode":"SC"},{"stateName":"South Dakota","stateCode":"SD"},{"stateName":"Tennessee","stateCode":"TN"},{"stateName":"Texas","stateCode":"TX"},{"stateName":"Utah","stateCode":"UT"},{"stateName":"Vermont","stateCode":"VT"},{"stateName":"Virginia","stateCode":"VA"},{"stateName":"Washington","stateCode":"WA"},{"stateName":"West Virgina","stateCode":"WV"},{"stateName":"Wisconsin","stateCode":"WI"},{"stateName":"Wyoming","stateCode":"WY"}]}

extJS loading code code:

// combo box loading

var states = new Ext.data.DirectStore({
reader: new Ext.data.JsonReader({
successProperty: 'success',
fields: ['stateName', 'stateCode'],
root: 'result'

proxy: new Ext.data.HttpProxy ({
url: '/csc/RPCAdapter/httprpc/CustomerInformationRetrieval/BuildStateList'

control create:

xtype :'combo',
fieldLabel :'State',
name :'stateName',
anchor :'25%',
mode :'remote',
store : states,
valueField : 'stateCode',
allowBlank : false,
tabIndex : 8

22 Mar 2011, 3:01 PM
Why are you using a DirectStore with a HttpProxy (instead of the preconfigured DirectProxy), and not a JsonStore (http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.JsonStore)?

Also, why mode: 'remote' on your combo?

If you just copied this from some example, I'd recommend taking a look at what the different config options mean in the docs (http://dev.sencha.com/deploy/dev/docs/#Ext.form.ComboBox-configs).

Try something like:

var states = new Ext.data.JsonStore({

url: '/csc/RPCAdapter/httprpc/CustomerInformationRetrieval/BuildStateList',
autoLoad: true,
root: 'result',
fields: ['stateName', 'stateCode']

// ...

xtype: 'combo',
fieldLabel: 'State',
name: 'stateName',
anchor: '25%',
mode: 'local',
triggerAction: 'all',
store: states,
valueField : 'stateCode',
displayField: 'stateName',
allowBlank: false,
// ...

23 Mar 2011, 9:57 AM
I did use an example from the Extjs book which was based on PHP SQL statement (duh). Hard to find any examples for java and RPC. I changed the 'local' to remote in pure desperation:)

While Fay's fix did help (thanks for that) I still don't get data loaded and after debugging the java method running server side find that its not being called at all. It does get called and works when I test run the service from Rational and also gets called when I paste the service URL into the page link after the port once the load fails. This same setup worked with a Dojo test I did in the past so I have to assume my URL is good I suppose. I'm at a loss and don't know what I'm missing. If I debug the script it processes the states.load(); but nothing happens and I don't know where else to catch the logic since no errors are returned to extjs.

23 Mar 2011, 10:03 AM
What is Firebug telling you? For development/debugging, I'd recommend using ext-all-debug.js + Firefox + Firebug and see what's been sent to and returned from the server. If all's okay on the way out, and you're getting nowt in return then this is more than likely a server issue. Use Firebug's Net and Console tabs to check for error codes from your server. (Sorry, I've no experience with Java/RPC).