Re: [S1] json and Action execute()
Hi, I haven't used ExtJS., but we i have done is i just writhe the json string to the output stream and from my js i convert it to JSON and used it. i used Dojo Thanks, Nuwan (http://code.google.com/p/struts2-ssl-plugin/) On Jan 23, 2008 12:26 AM, auz <[EMAIL PROTECTED]> wrote: > > this is struts 1.3.9 not 2.x, it can be done over json plugin for struts > 2.x, > or can it? > > jmitchell wrote: > > > > Take a look at this page: > > http://cwiki.apache.org/S2PLUGINS/json-plugin.html > > > > (Specifically "Root Object") > > > > It should match your result type name > > > > > > > > On Jan 22, 2008 4:09 PM, auz <[EMAIL PROTECTED]> wrote: > >> > >> i have a problem with struts action form execute and json. im using ext > >> js as > >> mu ajax lib on client side and i need to retrive some departmentID and > >> name > >> depenting on a combo box, the problem is i dont know how to put > JSonObect > >> so > >> that ext can see it here's my code any help is apritiated > >> > >> on jsp page - this is ext js script > >> > >> var departmentStore = new Ext.data.Store({ > >> reader: new Ext.data.JsonReader({ > >> totalProperty: 'total', > >> root:'list' > >> }, [{name: 'name'}]) > >> }) > >> > >> var departmentCombo = new Ext.form.ComboBox({ > >> store:departmentStore, > >> displayField:'name', > >> valueField: 'name', > >> hiddenName : 'city', > >> typeAhead: true, > >> mode: 'local', > >> triggerAction: 'all', > >> width:150, > >> emptyText:'select a city', > >> applyTo:'department', > >> selectOnFocus:true > >> }); > >> > >> studyProgramCombo.on('select', function () { > >> departmentCombo.reset(); > >> departmentCombo.store.proxy= new > >> Ext.data.HttpProxy({disableCaching:false,url: selfURI + > >> > 'JSONGetDepartment?studyProgram.json={"studyProgram":{"studyProgramID":' > >> + > >> studyProgramCombo.getValue() + '}}'}); > >> searchCityCombo.store.load(); > >> }); > >> > >> //the rest of the jsp code is irelevant NOTE selfURI variable is set to > >> http://SERVERADDRESS/PROJECTNAME/ > >> > >> Struts Action execute code > >> > >> JSONArray list = new JSONArray(); > >> JSONObject obj = new JSONObject(); > >> while(result.next()) { > >> obj.put("uid", result.getInt("departmentID")); > >> obj.put("name", result.getString("name")); > >> list.put(obj); > >> } > >> JSONObject rslt = new JSONObject(); > >> rslt.put ("total", list.length()); > >> rslt.put("list", list); > >> request.setAttribute("", rslt.toString()); //this name is unknown, i > dont > >> know what to put here > >> return null; > >> > >> > >> what did i do wrong/ didnt do? tnx a lot > >> -- > >> View this message in context: > >> > http://www.nabble.com/-S1--json-and-Action-execute%28%29-tp15028395p15028395.html > >> Sent from the Struts - User mailing list archive at Nabble.com. > >> > >> > >> - > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > > > > > > > > -- > > James Mitchell > > > > - > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > -- > View this message in context: > http://www.nabble.com/-S1--json-and-Action-execute%28%29-tp15028395p15028765.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Re: [S1] json and Action execute()
this is struts 1.3.9 not 2.x, it can be done over json plugin for struts 2.x, or can it? jmitchell wrote: > > Take a look at this page: > http://cwiki.apache.org/S2PLUGINS/json-plugin.html > > (Specifically "Root Object") > > It should match your result type name > > > > On Jan 22, 2008 4:09 PM, auz <[EMAIL PROTECTED]> wrote: >> >> i have a problem with struts action form execute and json. im using ext >> js as >> mu ajax lib on client side and i need to retrive some departmentID and >> name >> depenting on a combo box, the problem is i dont know how to put JSonObect >> so >> that ext can see it here's my code any help is apritiated >> >> on jsp page - this is ext js script >> >> var departmentStore = new Ext.data.Store({ >> reader: new Ext.data.JsonReader({ >> totalProperty: 'total', >> root:'list' >> }, [{name: 'name'}]) >> }) >> >> var departmentCombo = new Ext.form.ComboBox({ >> store:departmentStore, >> displayField:'name', >> valueField: 'name', >> hiddenName : 'city', >> typeAhead: true, >> mode: 'local', >> triggerAction: 'all', >> width:150, >> emptyText:'select a city', >> applyTo:'department', >> selectOnFocus:true >> }); >> >> studyProgramCombo.on('select', function () { >> departmentCombo.reset(); >> departmentCombo.store.proxy= new >> Ext.data.HttpProxy({disableCaching:false,url: selfURI + >> 'JSONGetDepartment?studyProgram.json={"studyProgram":{"studyProgramID":' >> + >> studyProgramCombo.getValue() + '}}'}); >> searchCityCombo.store.load(); >> }); >> >> //the rest of the jsp code is irelevant NOTE selfURI variable is set to >> http://SERVERADDRESS/PROJECTNAME/ >> >> Struts Action execute code >> >> JSONArray list = new JSONArray(); >> JSONObject obj = new JSONObject(); >> while(result.next()) { >> obj.put("uid", result.getInt("departmentID")); >> obj.put("name", result.getString("name")); >> list.put(obj); >> } >> JSONObject rslt = new JSONObject(); >> rslt.put ("total", list.length()); >> rslt.put("list", list); >> request.setAttribute("", rslt.toString()); //this name is unknown, i dont >> know what to put here >> return null; >> >> >> what did i do wrong/ didnt do? tnx a lot >> -- >> View this message in context: >> http://www.nabble.com/-S1--json-and-Action-execute%28%29-tp15028395p15028395.html >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> - >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > > -- > James Mitchell > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/-S1--json-and-Action-execute%28%29-tp15028395p15028765.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [struts] [S1] json and Action execute()
Doh! Sorry. On Jan 22, 2008 4:21 PM, Dale Newfield <[EMAIL PROTECTED]> wrote: > James Mitchell wrote: > > Take a look at this page: > > http://cwiki.apache.org/S2PLUGINS/json-plugin.html > > The OP specified struts1 in the subject. > > -Dale > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- James Mitchell - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [struts] [S1] json and Action execute()
James Mitchell wrote: Take a look at this page: http://cwiki.apache.org/S2PLUGINS/json-plugin.html The OP specified struts1 in the subject. -Dale - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S1] json and Action execute()
Setting an attribute on the request object makes it available to JAVA code, i.e., in a JSP, but ExtJS is Javascript running on the client. I believe, without knowing the specifics of what ExtJS expects, that what you really want to do is write to the response stream the serialization of your JSONObject. In other words, the response coming back from the server is text in the form of JSON (which will be present in the XHR object, which I presume ExtJS is using under the covers to make the request). Alternatively, you can do what you're trying to do in the Action, and then forward to a JSP that reads the attribute and outputs the JSON... this is probably a bit more work and overhead than you really need... writing to the response stream in the Action and then returning null for the forward does the trick. Frank -- Frank W. Zammetti Author of "Practical DWR 2 Projects" (2008, Apress, ISBN 1-59059-941-1) and "JavaScript, DOM Scripting and Ajax Projects" (2007, Apress, ISBN 1-59059-816-4) and "Practical Ajax Projects With Java Technology" (2006, Apress, ISBN 1-59059-695-1) Java Web Parts - http://javawebparts.sourceforge.net Supplying the wheel, so you don't have to reinvent it! On Tue, January 22, 2008 4:09 pm, auz wrote: > > i have a problem with struts action form execute and json. im using ext js > as > mu ajax lib on client side and i need to retrive some departmentID and > name > depenting on a combo box, the problem is i dont know how to put JSonObect > so > that ext can see it here's my code any help is apritiated > > on jsp page - this is ext js script > > var departmentStore = new Ext.data.Store({ > reader: new Ext.data.JsonReader({ > totalProperty: 'total', > root:'list' > }, [{name: 'name'}]) > }) > > var departmentCombo = new Ext.form.ComboBox({ > store:departmentStore, > displayField:'name', > valueField: 'name', > hiddenName : 'city', > typeAhead: true, > mode: 'local', > triggerAction: 'all', > width:150, > emptyText:'select a city', > applyTo:'department', > selectOnFocus:true > }); > > studyProgramCombo.on('select', function () { > departmentCombo.reset(); > departmentCombo.store.proxy= new > Ext.data.HttpProxy({disableCaching:false,url: selfURI + > 'JSONGetDepartment?studyProgram.json={"studyProgram":{"studyProgramID":' + > studyProgramCombo.getValue() + '}}'}); > searchCityCombo.store.load(); > }); > > //the rest of the jsp code is irelevant NOTE selfURI variable is set to > http://SERVERADDRESS/PROJECTNAME/ > > Struts Action execute code > > JSONArray list = new JSONArray(); > JSONObject obj = new JSONObject(); > while(result.next()) { > obj.put("uid", result.getInt("departmentID")); > obj.put("name", result.getString("name")); > list.put(obj); > } > JSONObject rslt = new JSONObject(); > rslt.put ("total", list.length()); > rslt.put("list", list); > request.setAttribute("", rslt.toString()); //this name is unknown, i dont > know what to put here > return null; > > > what did i do wrong/ didnt do? tnx a lot > -- > View this message in context: > http://www.nabble.com/-S1--json-and-Action-execute%28%29-tp15028395p15028395.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S1] json and Action execute()
Take a look at this page: http://cwiki.apache.org/S2PLUGINS/json-plugin.html (Specifically "Root Object") It should match your result type name On Jan 22, 2008 4:09 PM, auz <[EMAIL PROTECTED]> wrote: > > i have a problem with struts action form execute and json. im using ext js as > mu ajax lib on client side and i need to retrive some departmentID and name > depenting on a combo box, the problem is i dont know how to put JSonObect so > that ext can see it here's my code any help is apritiated > > on jsp page - this is ext js script > > var departmentStore = new Ext.data.Store({ > reader: new Ext.data.JsonReader({ > totalProperty: 'total', > root:'list' > }, [{name: 'name'}]) > }) > > var departmentCombo = new Ext.form.ComboBox({ > store:departmentStore, > displayField:'name', > valueField: 'name', > hiddenName : 'city', > typeAhead: true, > mode: 'local', > triggerAction: 'all', > width:150, > emptyText:'select a city', > applyTo:'department', > selectOnFocus:true > }); > > studyProgramCombo.on('select', function () { > departmentCombo.reset(); > departmentCombo.store.proxy= new > Ext.data.HttpProxy({disableCaching:false,url: selfURI + > 'JSONGetDepartment?studyProgram.json={"studyProgram":{"studyProgramID":' + > studyProgramCombo.getValue() + '}}'}); > searchCityCombo.store.load(); > }); > > //the rest of the jsp code is irelevant NOTE selfURI variable is set to > http://SERVERADDRESS/PROJECTNAME/ > > Struts Action execute code > > JSONArray list = new JSONArray(); > JSONObject obj = new JSONObject(); > while(result.next()) { > obj.put("uid", result.getInt("departmentID")); > obj.put("name", result.getString("name")); > list.put(obj); > } > JSONObject rslt = new JSONObject(); > rslt.put ("total", list.length()); > rslt.put("list", list); > request.setAttribute("", rslt.toString()); //this name is unknown, i dont > know what to put here > return null; > > > what did i do wrong/ didnt do? tnx a lot > -- > View this message in context: > http://www.nabble.com/-S1--json-and-Action-execute%28%29-tp15028395p15028395.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- James Mitchell - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[S1] json and Action execute()
i have a problem with struts action form execute and json. im using ext js as mu ajax lib on client side and i need to retrive some departmentID and name depenting on a combo box, the problem is i dont know how to put JSonObect so that ext can see it here's my code any help is apritiated on jsp page - this is ext js script var departmentStore = new Ext.data.Store({ reader: new Ext.data.JsonReader({ totalProperty: 'total', root:'list' }, [{name: 'name'}]) }) var departmentCombo = new Ext.form.ComboBox({ store:departmentStore, displayField:'name', valueField: 'name', hiddenName : 'city', typeAhead: true, mode: 'local', triggerAction: 'all', width:150, emptyText:'select a city', applyTo:'department', selectOnFocus:true }); studyProgramCombo.on('select', function () { departmentCombo.reset(); departmentCombo.store.proxy= new Ext.data.HttpProxy({disableCaching:false,url: selfURI + 'JSONGetDepartment?studyProgram.json={"studyProgram":{"studyProgramID":' + studyProgramCombo.getValue() + '}}'}); searchCityCombo.store.load(); }); //the rest of the jsp code is irelevant NOTE selfURI variable is set to http://SERVERADDRESS/PROJECTNAME/ Struts Action execute code JSONArray list = new JSONArray(); JSONObject obj = new JSONObject(); while(result.next()) { obj.put("uid", result.getInt("departmentID")); obj.put("name", result.getString("name")); list.put(obj); } JSONObject rslt = new JSONObject(); rslt.put ("total", list.length()); rslt.put("list", list); request.setAttribute("", rslt.toString()); //this name is unknown, i dont know what to put here return null; what did i do wrong/ didnt do? tnx a lot -- View this message in context: http://www.nabble.com/-S1--json-and-Action-execute%28%29-tp15028395p15028395.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]