Re: Using json in Struts 2.1.8.1
On 4/19/10 2:14 PM, sharath karnati wrote: Can you please send me sample example using AJAX in struts 2.1.8, where action method returns json list to a page. Trying to catch up from being out of town all weekend (and Monday), so I'm just going to throw some results of searching google at you: http://www.codeweblog.com/struts-2-in-the-use-of-json-ajax-support/ http://www.gmjjavadesigns.com/gmjd/entry/struts_2_x_and_json -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Using json in Struts 2.1.8.1
Hi All, Added below lines in struts.xml file package name=admin extends=struts-default,json-default result-types result-type name=json class=org.apache.struts2.json.JSONResult / /result-types action name=Autocomplete!* class=gov.admin.action.ManageAction method={1} result type=jsonparam name=rootjson/param/result /action /package Added following lines .jsp file bSearch JSON:nbsp;/b s:url id=url action=Autocomplete method=getNames / sx:autocompleter href=%{url} loadOnTextChange=true loadMinimumCount=3 / even included %@ taglib prefix=sx uri=/struts-dojo-tags% and head sx:head / /head When it builds the page it is showing below lines input dojoType=struts:ComboBox dataUrl=/admin/Autocomplete!getNames.action id=manageForm_ keyName=nullKey loadOnType=true loadMinimum=3 visibleDownArrow=true / script language=JavaScript type=text/javascriptdjConfig.searchIds.push(manageForm_);/script after entering 3 or more characters it supposed to invoke 'getNames' method but it is not even starting invocation of this method Can anyone please let me know where I'm wrong. Thanks in advance. Regards, Sharath. --- On Fri, 4/16/10, Dale Newfield d...@newfield.org wrote: From: Dale Newfield d...@newfield.org Subject: Re: Using json in Struts 2.1.8.1 To: Struts Users Mailing List user@struts.apache.org Date: Friday, April 16, 2010, 10:39 AM package name=package_name extends=struts-default namespace=/namespace_name result-types result-type name=json class=com.googlecode.jsonplugin.JSONResult / /result-types Or just package name=package-name extends=json-default -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Using json in Struts 2.1.8.1
hi all just want to share can we make Struts2 become like a SOA Middlerware, using JSON, so we can use like mule, the plugins become transfport is it possible? -- Frans Thamura Meruvian. Experiential Tempation of Java and Enterprise OpenSource Meruvian jTechnopreneur Program (S1) telah hadir, Dapatkan benefit bagi SMK yang melakukan mapping SKKD, dg program beasiswa dari Gunadarma Mobile: +6287885901958 Blog Profile: http://frans.thamura.info We provide services to migrate your apps to Java (web), in amazing fast and reliable. On Tue, Apr 20, 2010 at 10:34 PM, sharath karnati karna...@yahoo.comwrote: Hi All, Added below lines in struts.xml file package name=admin extends=struts-default,json-default result-types result-type name=json class=org.apache.struts2.json.JSONResult / /result-types action name=Autocomplete!* class=gov.admin.action.ManageAction method={1} result type=jsonparam name=rootjson/param/result /action /package Added following lines .jsp file bSearch JSON: /b s:url id=url action=Autocomplete method=getNames / sx:autocompleter href=%{url} loadOnTextChange=true loadMinimumCount=3 / even included %@ taglib prefix=sx uri=/struts-dojo-tags% and head sx:head / /head When it builds the page it is showing below lines input dojoType=struts:ComboBox dataUrl=/admin/Autocomplete!getNames.action id=manageForm_ keyName=nullKey loadOnType=true loadMinimum=3 visibleDownArrow=true / script language=JavaScript type=text/javascriptdjConfig.searchIds.push(manageForm_);/script after entering 3 or more characters it supposed to invoke 'getNames' method but it is not even starting invocation of this method Can anyone please let me know where I'm wrong. Thanks in advance. Regards, Sharath. --- On Fri, 4/16/10, Dale Newfield d...@newfield.org wrote: From: Dale Newfield d...@newfield.org Subject: Re: Using json in Struts 2.1.8.1 To: Struts Users Mailing List user@struts.apache.org Date: Friday, April 16, 2010, 10:39 AM package name=package_name extends=struts-default namespace=/namespace_name result-types result-type name=json class=com.googlecode.jsonplugin.JSONResult / /result-types Or just package name=package-name extends=json-default -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Using json in Struts 2.1.8.1
On 4/20/10 11:34 AM, sharath karnati wrote: package name=admin extends=struts-default,json-default result-types result-type name=json class=org.apache.struts2.json.JSONResult / /result-types json-default extends struts-default, so no reason do list both (and I don't even know if that works). json-default defines the result type json, so no reason to redefine it again. action name=Autocomplete!* class=gov.admin.action.ManageAction method={1} result type=jsonparam name=rootjson/param/result /action I don't know if action names can include !. Do you have struts.enable.DynamicMethodInvocation set to false and you're trying to emulate that behavior here? input dojoType=struts:ComboBox dataUrl=/admin/Autocomplete!getNames.action id=manageForm_ keyName=nullKey loadOnType=true loadMinimum=3 visibleDownArrow=true / script language=JavaScript type=text/javascriptdjConfig.searchIds.push(manageForm_);/script after entering 3 or more characters it supposed to invoke 'getNames' method but it is not even starting invocation of this method Sounds like you're having problems not with json but with dojo. Note, the dojo plugin is old and deprecated. I cannot help there. Javascript errors on your page might be preventing other javascript from running. For debugging js I'd suggest the firebug plugin to firefox. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Using json in Struts 2.1.8.1
Hi Dale, Tried all the changes which you mentioned like keeping only 'json-default' and removing 'json' from result type but facing same problem... In struts.properties file having below line struts.enable.DynamicMethodInvocation = true I'm using 'struts2-dojo-plugin-2.1.8.1.jar' plugin for doing AJAX, and you mentioned that dojo is deprecated. Can you please tell me how to do AJAX in struts2.1.8?? what components(similar to dojo) we need to use to get AJAX functionality. Thanks for your help. Regards, Sharath. --- On Tue, 4/20/10, Dale Newfield d...@newfield.org wrote: From: Dale Newfield d...@newfield.org Subject: Re: Using json in Struts 2.1.8.1 To: Struts Users Mailing List user@struts.apache.org Date: Tuesday, April 20, 2010, 12:28 PM On 4/20/10 11:34 AM, sharath karnati wrote: package name=admin extends=struts-default,json-default result-types result-type name=json class=org.apache.struts2.json.JSONResult / /result-types json-default extends struts-default, so no reason do list both (and I don't even know if that works). json-default defines the result type json, so no reason to redefine it again. action name=Autocomplete!* class=gov.admin.action.ManageAction method={1} result type=jsonparam name=rootjson/param/result /action I don't know if action names can include !. Do you have struts.enable.DynamicMethodInvocation set to false and you're trying to emulate that behavior here? input dojoType=struts:ComboBox dataUrl=/admin/Autocomplete!getNames.action id=manageForm_ keyName=nullKey loadOnType=true loadMinimum=3 visibleDownArrow=true / script language=JavaScript type=text/javascriptdjConfig.searchIds.push(manageForm_);/script after entering 3 or more characters it supposed to invoke 'getNames' method but it is not even starting invocation of this method Sounds like you're having problems not with json but with dojo. Note, the dojo plugin is old and deprecated. I cannot help there. Javascript errors on your page might be preventing other javascript from running. For debugging js I'd suggest the firebug plugin to firefox. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Using json in Struts 2.1.8.1
On 4/20/10 2:11 PM, sharath karnati wrote: but facing same problem... Because your problem doesn't appear to be a server-side one, but rather what's going on inside the browser. In struts.properties file having below line *struts.enable.DynamicMethodInvocation = **true* If that's true, then your action configuration including the ! character may or may not work as you intend, as dynamic method invocation effectively does the same thing as your wildcarding there. I'm using 'struts2-dojo-plugin-2.1.8.1.jar' plugin for doing AJAX, and you mentioned that dojo is deprecated. Can you please tell me how to do AJAX in struts2.1.8?? what components(similar to dojo) we need to use to get AJAX functionality. AJAX libraries run in the browser. Struts2 runs on the server. They're really orthogonal. I'd advise picking a javascript library that you can get your head around and learning to use it separately from struts, then understanding the few small areas where requests sent/results parsed to understand how that'll work with a struts-based server. DOJO (at least the ancient version in the struts plugin) is dog slow in the browser, so I'd avoid it if possible. My current project is based on the prototype/scriptaculous libraries, but I've heard/seen good things regarding jquery. Assuming that has components that do asynchronous requests, I'd look at jquery. http://www.zulutown.com/blog/2009/07/12/ajax-dynamic-content-with-struts2-jquery-and-json-plugin/ details one example of doing this with jquery directly. If that's all too much for you to figure out, I believe there is an effort at a jquery plugin (basically a sj taglib) that might be able to help you. I had thought there was an effort to put that in the sandbox or even support it as part of the normal struts distribution, but I don't recall. It appears that this plugin resides at: http://code.google.com/p/struts2-jquery/ not sure what relationship this one has to the former: http://code.google.com/p/struts2-jquery-plugin/ All that said, if you just want to push forward with the deprecated dojo plugin, I'll again suggest using firebug within firefox to track down what's going wrong in the browser. -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Using json in Struts 2.1.8.1
supply the fully qualified action name to the url s:url var=url value=/admin/Autocomplete!getNames.action/ also make sure there is a result defined for that action in your declarator action name=JSONList result/ajax/JSONList.js/result /action anyone seen result type='json' ?? as far not getting there you should follow dales advice d/l and install firefox http://support.mozilla.com/en-US/kb/Firefox+exe+is+always+running then install firebug plugin http://getfirebug.com/downloads you can view the entire DOM tree as well as interrogate request and resulting response fill in the blank ..what name is at question mark gov.? Martin __ Verzicht und Vertraulichkeitanmerkung Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Date: Tue, 20 Apr 2010 08:34:15 -0700 From: karna...@yahoo.com Subject: Re: Using json in Struts 2.1.8.1 To: user@struts.apache.org CC: d...@newfield.org Hi All, Added below lines in struts.xml file package name=admin extends=struts-default,json-default result-types result-type name=json class=org.apache.struts2.json.JSONResult / /result-types action name=Autocomplete!* class=gov.admin.action.ManageAction method={1} result type=jsonparam name=rootjson/param/result /action /package Added following lines .jsp file bSearch JSON:nbsp;/b s:url id=url action=Autocomplete method=getNames / sx:autocompleter href=%{url} loadOnTextChange=true loadMinimumCount=3 / even included %@ taglib prefix=sx uri=/struts-dojo-tags% and head sx:head / /head When it builds the page it is showing below lines input dojoType=struts:ComboBox dataUrl=/admin/Autocomplete!getNames.action id=manageForm_ keyName=nullKey loadOnType=true loadMinimum=3 visibleDownArrow=true / script language=JavaScript type=text/javascriptdjConfig.searchIds.push(manageForm_);/script after entering 3 or more characters it supposed to invoke 'getNames' method but it is not even starting invocation of this method Can anyone please let me know where I'm wrong. Thanks in advance. Regards, Sharath. --- On Fri, 4/16/10, Dale Newfield d...@newfield.org wrote: From: Dale Newfield d...@newfield.org Subject: Re: Using json in Struts 2.1.8.1 To: Struts Users Mailing List user@struts.apache.org Date: Friday, April 16, 2010, 10:39 AM package name=package_name extends=struts-default namespace=/namespace_name result-types result-type name=json class=com.googlecode.jsonplugin.JSONResult / /result-types Or just package name=package-name extends=json-default -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org _ The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail. http://www.windowslive.com/campaign/thenewbusy?tile=multicalendarocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5
Re: Using json in Struts 2.1.8.1
Hi Dale, Can you please send me sample example using AJAX in struts 2.1.8, where action method returns json list to a page. Thanks in advance. Regards, Sharath. --- On Fri, 4/16/10, Dale Newfield d...@newfield.org wrote: From: Dale Newfield d...@newfield.org Subject: Re: Using json in Struts 2.1.8.1 To: Struts Users Mailing List user@struts.apache.org Date: Friday, April 16, 2010, 10:39 AM package name=package_name extends=struts-default namespace=/namespace_name result-types result-type name=json class=com.googlecode.jsonplugin.JSONResult / /result-types Or just package name=package-name extends=json-default -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Using json in Struts 2.1.8.1
what do u think if we using enunciate enunciate.codehaus.org/ http://enunciate.codehaus.org/F On Tue, Apr 20, 2010 at 1:14 AM, sharath karnati karna...@yahoo.com wrote: Hi Dale, Can you please send me sample example using AJAX in struts 2.1.8, where action method returns json list to a page. Thanks in advance. Regards, Sharath. --- On Fri, 4/16/10, Dale Newfield d...@newfield.org wrote: From: Dale Newfield d...@newfield.org Subject: Re: Using json in Struts 2.1.8.1 To: Struts Users Mailing List user@struts.apache.org Date: Friday, April 16, 2010, 10:39 AM package name=package_name extends=struts-default namespace=/namespace_name result-types result-type name=json class=com.googlecode.jsonplugin.JSONResult / /result-types Or just package name=package-name extends=json-default -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Using json in Struts 2.1.8.1
Hi sameer, In struts 2.1.8.1 having 'struts2-dojo-plugin-2.1.8.1.jar' file so we don't need to use 'jsonplugin-0.34.jar' for using json. This is my understanding :) If we are not including 'jsonplugin-0.34.jar' then we cannot use com.googlecode.jsonplugin.JSONResult With new Struts 2.1.8.1 version how to use json without using any annotations in action. Can someone please send me some examples for using json in this new version of struts2. Thanks in advance. Regards, Sharath. --- On Thu, 4/15/10, hisameer cool_sameer_fo...@yahoo.com wrote: From: hisameer cool_sameer_fo...@yahoo.com Subject: Re: Using json in Struts 2.1.8.1 To: user@struts.apache.org Date: Thursday, April 15, 2010, 7:22 PM Do something like this: In your struts.xml define result types as follows: package name=package_name extends=struts-default namespace=/namespace_name result-types result-type name=json class=com.googlecode.jsonplugin.JSONResult / /result-types then in the action mapping: action name=action_name class=AutocompleteField method=getCities() result type=json /result /action and put annotation in the getter method in your action class: @JSON public MapString,String getJson() { return json; } and u can use this json map in the jsp page. I Hope it helps! sharath wrote: Hi All, I'm having following Action - Action(Begin) - public class AutocompleteField extends ActionSupport { private String city; private MapString,String json; public String execute() throws Exception() { return SUCCESS; } public String getCities() throws Exception() { json = new HashMapString,String(); if(city != null city.length() 0) { CityDao dao = new CityDao(); ListCity cities = dao.getCitiesStartingWith(city); for(City city : cities) { json.put(city.getId(), city.getName() + , + city.getState().getAbbreviation()); } } return SUCCESS; } public void setCity(String city) { this.city = city; } public MapString,String getJson() { return json; } } - Action(End) - In struts.xml file I given following entries action name=Autocomplete!* class=gov.action.AutocompleteField method={1} !-- result type=jsonjson/result -- result name=success type=json / /action When I keep 'jsonplugin-0.34.jar' file getting below error java.lang.NoClassDefFoundError: com/opensymphony/xwork2/util/TextUtils After reading some posts, they said that we should not include this .jar in this new struts2.1.8 version. I removed this .jar file I added 'struts2-dojo-plugin-2.1.8.1.jar' file in /WEB-INF/lib folder. When I deploy the application getting below error There is no result type defined for type 'json' mapped with name 'success'. Did you mean 'json'? - result Can anyone please let me know, how to define 'json' in struts.xml file? in package level I even added 'json-default' package name=admin extends=struts-default,json-default Thanks in advance. Regards, Sharath. -- View this message in context: http://old.nabble.com/Using-json-in-Struts-2.1.8.1-tp28245651p28261689.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Using json in Struts 2.1.8.1
package name=package_name extends=struts-default namespace=/namespace_name result-types result-type name=json class=com.googlecode.jsonplugin.JSONResult / /result-types Or just package name=package-name extends=json-default -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Using json in Struts 2.1.8.1
As of struts 2.1.8, you have (well can, but it's recommended) use the struts2-json-plugin rather than the googlecode version (the google code one has been transferred to apache as a struts 2 plugin). To do that, just use the class name org.apache.struts2.json.JSONResult (see http://struts.apache.org/2.1.8.1/struts2-plugins/struts2-json-plugin/apidocs/org/apache/struts2/json/JSONResult.html ) for your json result. Ie : package name=package_name extends=struts-default namespace=/namespace_name result-types result-type name=json class=org.apache.struts2.json.JSONResult / /result-types And include the jar file (can be found at http://repo2.maven.org/maven2/org/apache/struts/struts2-json-plugin/2.1.8.1/struts2-json-plugin-2.1.8.1.jar or in the complete distribution of struts 2) in your classpath. So your understanding is good, but you need the struts2-json-plugin-2.1.8.1.jar file too. Denis. Le 2010-04-16 10:00, sharath karnati a écrit : Hi sameer, In struts 2.1.8.1 having 'struts2-dojo-plugin-2.1.8.1.jar' file so we don't need to use 'jsonplugin-0.34.jar' for using json. This is my understanding :) If we are not including 'jsonplugin-0.34.jar' then we cannot use com.googlecode.jsonplugin.JSONResult With new Struts 2.1.8.1 version how to use json without using any annotations in action. Can someone please send me some examples for using json in this new version of struts2. Thanks in advance. Regards, Sharath. --- On Thu, 4/15/10, hisameercool_sameer_fo...@yahoo.com wrote: From: hisameercool_sameer_fo...@yahoo.com Subject: Re: Using json in Struts 2.1.8.1 To: user@struts.apache.org Date: Thursday, April 15, 2010, 7:22 PM Do something like this: In your struts.xml define result types as follows: package name=package_name extends=struts-default namespace=/namespace_name result-types result-type name=json class=com.googlecode.jsonplugin.JSONResult / /result-types then in the action mapping: action name=action_name class=AutocompleteField method=getCities() result type=json /result /action and put annotation in the getter method in your action class: @JSON public MapString,String getJson() { return json; } and u can use this json map in the jsp page. I Hope it helps! sharath wrote: Hi All, I'm having following Action - Action(Begin) - public class AutocompleteField extends ActionSupport { private String city; private MapString,String json; public String execute() throws Exception() { return SUCCESS; } public String getCities() throws Exception() { json = new HashMapString,String(); if(city != null city.length() 0) { CityDao dao = new CityDao(); ListCity cities = dao.getCitiesStartingWith(city); for(City city : cities) { json.put(city.getId(), city.getName() + , + city.getState().getAbbreviation()); } } return SUCCESS; } public void setCity(String city) { this.city = city; } public MapString,String getJson() { return json; } } - Action(End) - In struts.xml file I given following entries action name=Autocomplete!* class=gov.action.AutocompleteField method={1} !--result type=jsonjson/result -- result name=success type=json / /action When I keep 'jsonplugin-0.34.jar' file getting below error java.lang.NoClassDefFoundError: com/opensymphony/xwork2/util/TextUtils After reading some posts, they said that we should not include this .jar in this new struts2.1.8 version. I removed this .jar file I added 'struts2-dojo-plugin-2.1.8.1.jar' file in /WEB-INF/lib folder. When I deploy the application getting below error There is no result type defined for type 'json' mapped with name 'success'. Did you mean 'json'? - result Can anyone please let me know, how to define 'json' in struts.xml file? in package level I even added 'json-default' package name=admin extends=struts-default,json-default Thanks in advance. Regards, Sharath. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Using json in Struts 2.1.8.1
Can anyone please let me know, how to use json?? Thanks, Sharath. --- On Wed, 4/14/10, sharath karnati karna...@yahoo.com wrote: From: sharath karnati karna...@yahoo.com Subject: Using json in Struts 2.1.8.1 To: user@struts.apache.org Cc: karna...@yahoo.com Date: Wednesday, April 14, 2010, 1:22 PM Hi All, I'm having following Action - Action(Begin) - public class AutocompleteField extends ActionSupport { private String city; private MapString,String json; public String execute() throws Exception() { return SUCCESS; } public String getCities() throws Exception() { json = new HashMapString,String(); if(city != null city.length() 0) { CityDao dao = new CityDao(); ListCity cities = dao.getCitiesStartingWith(city); for(City city : cities) { json.put(city.getId(), city.getName() + , + city.getState().getAbbreviation()); } } return SUCCESS; } public void setCity(String city) { this.city = city; } public MapString,String getJson() { return json; } } - Action(End) - In struts.xml file I given following entries action name=Autocomplete!* class=gov.action.AutocompleteField method={1} !-- result type=jsonparam name=rootjson/param/result -- result name=success type=json / /action When I keep 'jsonplugin-0.34.jar' file getting below error java.lang.NoClassDefFoundError: com/opensymphony/xwork2/util/TextUtils After reading some posts, they said that we should not include this .jar in this new struts2.1.8 version. I removed this .jar file I added 'struts2-dojo-plugin-2.1.8.1.jar' file in /WEB-INF/lib folder. When I deploy the application getting below error There is no result type defined for type 'json' mapped with name 'success'. Did you mean 'json'? - result Can anyone please let me know, how to define 'json' in struts.xml file? in package level I even added 'json-default' package name=admin extends=struts-default,json-default Thanks in advance. Regards, Sharath.
Re: Using json in Struts 2.1.8.1
Do something like this: In your struts.xml define result types as follows: package name=package_name extends=struts-default namespace=/namespace_name result-types result-type name=json class=com.googlecode.jsonplugin.JSONResult / /result-types then in the action mapping: action name=action_name class=AutocompleteField method=getCities() result type=json /result /action and put annotation in the getter method in your action class: @JSON public MapString,String getJson() { return json; } and u can use this json map in the jsp page. I Hope it helps! sharath wrote: Hi All, I'm having following Action - Action(Begin) - public class AutocompleteField extends ActionSupport { private String city; private MapString,String json; public String execute() throws Exception() { return SUCCESS; } public String getCities() throws Exception() { json = new HashMapString,String(); if(city != null city.length() 0) { CityDao dao = new CityDao(); ListCity cities = dao.getCitiesStartingWith(city); for(City city : cities) { json.put(city.getId(), city.getName() + , + city.getState().getAbbreviation()); } } return SUCCESS; } public void setCity(String city) { this.city = city; } public MapString,String getJson() { return json; } } - Action(End) - In struts.xml file I given following entries action name=Autocomplete!* class=gov.action.AutocompleteField method={1} !-- result type=jsonjson/result -- result name=success type=json / /action When I keep 'jsonplugin-0.34.jar' file getting below error java.lang.NoClassDefFoundError: com/opensymphony/xwork2/util/TextUtils After reading some posts, they said that we should not include this .jar in this new struts2.1.8 version. I removed this .jar file I added 'struts2-dojo-plugin-2.1.8.1.jar' file in /WEB-INF/lib folder. When I deploy the application getting below error There is no result type defined for type 'json' mapped with name 'success'. Did you mean 'json'? - result Can anyone please let me know, how to define 'json' in struts.xml file? in package level I even added 'json-default' package name=admin extends=struts-default,json-default Thanks in advance. Regards, Sharath. -- View this message in context: http://old.nabble.com/Using-json-in-Struts-2.1.8.1-tp28245651p28261689.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Using json in Struts 2.1.8.1
Hi All, I'm having following Action - Action(Begin) - public class AutocompleteField extends ActionSupport { private String city; private MapString,String json; public String execute() throws Exception() { return SUCCESS; } public String getCities() throws Exception() { json = new HashMapString,String(); if(city != null city.length() 0) { CityDao dao = new CityDao(); ListCity cities = dao.getCitiesStartingWith(city); for(City city : cities) { json.put(city.getId(), city.getName() + , + city.getState().getAbbreviation()); } } return SUCCESS; } public void setCity(String city) { this.city = city; } public MapString,String getJson() { return json; } } - Action(End) - In struts.xml file I given following entries action name=Autocomplete!* class=gov.action.AutocompleteField method={1} !-- result type=jsonparam name=rootjson/param/result -- result name=success type=json / /action When I keep 'jsonplugin-0.34.jar' file getting below error java.lang.NoClassDefFoundError: com/opensymphony/xwork2/util/TextUtils After reading some posts, they said that we should not include this .jar in this new struts2.1.8 version. I removed this .jar file I added 'struts2-dojo-plugin-2.1.8.1.jar' file in /WEB-INF/lib folder. When I deploy the application getting below error There is no result type defined for type 'json' mapped with name 'success'. Did you mean 'json'? - result Can anyone please let me know, how to define 'json' in struts.xml file? in package level I even added 'json-default' package name=admin extends=struts-default,json-default Thanks in advance. Regards, Sharath.