struts2-json-plugin

Giving an empty json result while executing struts 2 action class

寵の児 提交于 2019-12-30 11:51:33
问题 Im trying to retrieve data from DB using hibernate ORM and get the out-put as json result using Struts2. Everything work up to retrieving data from DB, but for the json result I get only {} . I think I have done something wrong with my coding. But need some help to figure it out. Here is my Action class : @ParentPackage("json-default") public class SocialIconsAction extends ActionSupport { private List<TiendayaCurrencies> _currency; public List<TiendayaCurrencies> getCurrency() { return

How to display nested properties of a model class in Struts2 grid?

谁说胖子不能爱 提交于 2019-12-25 07:48:18
问题 I have a grid provided by the struts2-jquery-grid-3.7.0 plugin as follows. <s:url id="remoteurl" action="ProductGrid" namespace="/admin_side"/> <s:url id="editurl" action="ProductCRUD"/> <sjg:grid id="gridmultitable" caption="Product" dataType="json" href="%{remoteurl}" pager="true" navigator="true" navigatorSearchOptions="{sopt:['eq','ne','lt','gt']}" navigatorEdit="false" navigatorView="false" navigatorAddOptions="{height:280, width:500, reloadAfterSubmit:true}" navigatorEditOptions="

Struts2 Junit4 tests accumulate JSON responses with every action execution

与世无争的帅哥 提交于 2019-12-24 15:13:24
问题 I've written a few Junit4 tests, which looks like this : public class TestCampaignList extends StrutsJUnit4TestCase<Object> { public static final Logger LOG = Logger.getLogger(TestCampaignList.class.getName()); @Before public void loginAdmin() throws ServletException, UnsupportedEncodingException { request.setParameter("email", "nitin.cool4urchat@gmail.com"); request.setParameter("password", "22"); String response = executeAction("/login/admin"); System.out.println("Login Response : " +

strust 2 (jquery plugin) show action exceptions as ajax error

北城以北 提交于 2019-12-24 10:48:02
问题 Can you tell me how can I get the action exceptions , convert and send them as json errors. I am using the strust2 jquery plugin to validate my forms with ajax. The framework will do it automatically by defining the sj:submit validate=true and annotating the actions <s:form action="login"> <s:textfield name="username" /> <s:textfield name="password" /> <sj:submit button="true" validate="true" /> </s:form> The action is: @Validations(requiredStrings = { @RequiredStringValidator(fieldName =

Im trying to get JSON data from js and receiving null in action class

淺唱寂寞╮ 提交于 2019-12-22 17:29:20
问题 I'm getting JSON from client side. I want to send it through ajax. However, i'm getting null inside my action class. my JSON string {"data":[{"id":"","col":1,"row":1,"size_x":1,"size_y":1}, {"id":"","col":1,"row":2,"size_x":1,"size_y":1}, {"id":"","col":1,"row":3,"size_x":1,"size_y":1}, {"id":"","col":1,"row":4,"size_x":1,"size_y":1}, {"id":"","col":1,"row":6,"size_x":1,"size_y":1}, {"id":"","col":1,"row":5,"size_x":1,"size_y":1} ] } AJAX var seats = {"data" : positions}; var seatPosition =

How to bind JSON to Java object in Struts2 using struts2-json-plugin

社会主义新天地 提交于 2019-12-21 03:58:36
问题 I want to deserialize (bind) JSON to java object. How to do it in Struts2? I am trying to do it with struts2-json-plugin as you can see in code below, but sent JSON from frontend is not binding to my java object. Could you help me, please how to make this code to work correctly? Please take a look at my Action class, I am not sure if I'm handling JSON correctly in this Action, or maybe I missed something? JSON which I am trying to bind: {"data":[ {"active":true,"color":"orange","date":"2008

Struts2 AnnotationValidationInterceptor

假装没事ソ 提交于 2019-12-20 04:23:23
问题 I am having a frustrating time implementing struts2-jquery-plugin-3.6.0 into a Struts2 2.3.14.3 website. I recently updated the Struts2 version to 2.3.14.3, and all its dependencies, and the website functions fully and properly. I am now trying to update some tables to look more modern, like this, (look in the widgets tab). My .jsp page is getting read properly, but the sj: tags are not being displayed properly. I know the sj: tags are being read properly because if I have mistakes in the

Incompatible types for property setData [JSON+Struts2 plugin]

旧城冷巷雨未停 提交于 2019-12-13 15:32:37
问题 I need to configure JSON Plugin (https://struts.apache.org/docs/json-plugin.html) with my current JAVA web application. What I've done: 1) Added to pom.xml file all dependencies for the plugin. <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-json-plugin</artifactId> <version>2.3.24.1</version> </dependency> 2) Extended the package in struts.xml with json-default <package name="my-test-package" extends="xxx, json-default" namespace="/my-test-package"> 3) Added to my

Custom Struts type converter is not working

浪尽此生 提交于 2019-12-12 19:14:00
问题 I do have a getter/setter for the Date variable, like so: private Date registrationDate; @TypeConversion(converter = "org.com.helper.DataHelper") public Date getRegistrationDate() { return registrationDate; } @TypeConversion(converter = "org.com.helper.DataHelper") public void setRegistrationDate(Date registrationDate) { this.registrationDate = registrationDate; } As you can see I've created a custom struts converter to convert the incoming string to the Date format and then assign it. But it

How to parse received json data in action

女生的网名这么多〃 提交于 2019-12-12 02:14:18
问题 I am sending json array data from JSP to Action class for that I have included struts2-json-plugin . I want to parse it to receive it as a ArrayList elements. my code is In JSP: $.ajax({ url: "UpdateNotification", dataType: "json", data: {ids: JSON.stringify(ids)}, success: function(data) { alert("success " + data.st); } }) In action: public class Test extends ActionSupport { ArrayList<String> ids = new ArrayList<String>(); public ArrayList<String> getIds() { return ids; } public void setIds