PDA

View Full Version : how to load combobox from jsp with using Extjs



ramesh.tatipigari
23 Feb 2010, 9:41 PM
Hi All,

I am using struts, after action processing i am forwarding to some jsp(test.jsp).In test.jsp i have converted the arraylist to json String, as below...



in my js file my combo config is..

var dsCompany = new Ext.data.JsonStore({
url:'test.jsp' (http://www.yui-ext.com/forum/'test.jsp'),
root: 'jsonRoot',
fields: ['value', 'key']
});


{
columnWidth:.3,
layout: 'form',
items: [{
xtype:'combo',
fieldLabel: 'Company',
store:dsCompany,
displayField:'value',
valueField:'key',
emptyText:'Select a company...',
name: 'company',
anchor:'95%',
triggerAction: 'all'

}]
}


finally i am unable to loading combo box, please help me any one knows about this..

raj_plays
23 Feb 2010, 10:28 PM
Did you set the content type in the servlet/jsp as
response.setContentType("application/json");

mahlatst
5 May 2010, 4:41 AM
Hi

Did you figure it out? I have the same problem.

wm003
5 May 2010, 5:35 AM
try


autoLoad: true,

at store-config

mahlatst
5 May 2010, 5:39 AM
I am using JSP.

Elijah
5 May 2010, 6:52 AM
I am using for now a JSP file on the backend (no struts) and have the following syntax to output in the response the JSON data.


<%@ page contentType="text/html;charset=UTF-8" language="java" import="org.json.*" %>
<%
JSONObject obj = new JSONObject();
//... set whatever your setting ....
PrintWriter pw = response.getWriter();
pw.write(obj.toString());
pw.flush();
%>


However being that you are using struts and forwarding may not work. Let me know.