Re: How to apply an Action conversion annotation for individual object field?
Ok - thanks for clarification. On Fri, Mar 4, 2022 at 5:37 AM Lukasz Lenart wrote: > wt., 1 mar 2022 o 04:10 Burton Rhodes napisał(a): > > > > I am attempting to convert my [action]-conversion.properties files to > > annotations and I having difficulty figuring out how to migrate this > entry: > > > > > > > *"searchCriteria.emailQueueStates=com.afs.web.common.struts.converter.MyStringToCollectionConverter"* > > > > into an @annotation for the action class below... > > > > *public class BaseAction extends ActionSupport {* > > > > *@Element(value = > > com.afs.web.common.struts.converter.MyStringToCollectionConverter)* > > > > *private SearchCriteriaEmailQueue searchCriteria;* > > > > */// code omitted* > > *}* > > > > > > How do I specify just the individual "emailQueueStates" parameter > > instead of the entire SearchCriteriaEmailQueue class? > > Without polluting the model it won't work, I would suggest using > struts-conversion.properties for such kind of conversion > > > Regards > -- > Łukasz > + 48 606 323 122 http://www.lenart.org.pl/ > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
Re: How to apply an Action conversion annotation for individual object field?
wt., 1 mar 2022 o 04:10 Burton Rhodes napisał(a): > > I am attempting to convert my [action]-conversion.properties files to > annotations and I having difficulty figuring out how to migrate this entry: > > > *"searchCriteria.emailQueueStates=com.afs.web.common.struts.converter.MyStringToCollectionConverter"* > > into an @annotation for the action class below... > > *public class BaseAction extends ActionSupport {* > > *@Element(value = > com.afs.web.common.struts.converter.MyStringToCollectionConverter)* > > *private SearchCriteriaEmailQueue searchCriteria;* > > */// code omitted* > *}* > > > How do I specify just the individual "emailQueueStates" parameter > instead of the entire SearchCriteriaEmailQueue class? Without polluting the model it won't work, I would suggest using struts-conversion.properties for such kind of conversion Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
How to apply an Action conversion annotation for individual object field?
I am attempting to convert my [action]-conversion.properties files to annotations and I having difficulty figuring out how to migrate this entry: *"searchCriteria.emailQueueStates=com.afs.web.common.struts.converter.MyStringToCollectionConverter"* into an @annotation for the action class below... *public class BaseAction extends ActionSupport {* *@Element(value = com.afs.web.common.struts.converter.MyStringToCollectionConverter)* *private SearchCriteriaEmailQueue searchCriteria;* */// code omitted* *}* How do I specify just the individual "emailQueueStates" parameter instead of the entire SearchCriteriaEmailQueue class?
Re: Fwd: Type conversion collection with interface type elements
On 4/5/2018 6:52 PM, Nuno Oliveira wrote: > Your fix worked :) and I see why it did not work, thank you. > > Also yes, you are right, it should be Role instead of Roles but it is a > legacy class and the change implies a lot of fixes. It's on the "to do > list". > > Once more, thank you. You're welcome :) glad to hear this. However, I think it's better that Struts honor .properties file (where element class has been defined strictly by user) before the generic parametrics [1]. Could you please register an issue at [2] with title "conversion fails when generic type is an interface" then paste these emails contents in it's description. Thanks for your report! [1] github.com/apache/struts/blob/05829e3faadd15cfa67eb234cd1775f2b98918cb/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DefaultObjectTypeDeterminer.java#L100 [2] issues.apache.org/jira/projects/WW/
Re: Fwd: Type conversion collection with interface type elements
Your fix worked :) and I see why it did not work, thank you. Also yes, you are right, it should be Role instead of Roles but it is a legacy class and the change implies a lot of fixes. It's on the "to do list". Once more, thank you. On Qui, 2018-04-05 at 13:13 +, Yasser Zamani wrote: > [copy with removed links to avoid detection as spam] > > > Forwarded Message ---- > Subject: Re: Type conversion collection with interface type elements > Date: Thu, 5 Apr 2018 13:02:01 + > From: Yasser Zamani > Reply-To: Struts Users Mailing List > To: user@struts.apache.org > > > > On 4/4/2018 7:20 PM, Nuno Oliveira wrote: > > Hi, > > > > I am having problems populating an action variable Set by request using > > struts type conversion if the Set has the element type defined as an > > interface. > > I have a UserAction-conversion.properties file with the following > > configuration using the class implementation: > > > > KeyProperty_roles=id > > Element_roles=path.to.class.Roles > > CreateIfNull_roles=true > > > > And UserAction has the collection Set. Roles obviously > > implements RolesInterface. > > > > If the Set element type is deleted it works just fine. > > Am I doing something wrong or is this not possible? > > I reproduced it and seems it's because it tries to instantiate a new > element but the interface cannot being instantiated. Please see [1] to > know why it tries to instantiate interface instead of class. > > Annotating the getRoles or setRoles method with @Element(value = > path.to.class.Roles.class) may fix this issue. (shouldn't it be > path.to.class.Role instead? it seems Roles is a list not element) > > Regards. > > [1] > github.com/apache/struts/blob/05829e3faadd15cfa67eb234cd1775f2b98918cb/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DefaultObjectTypeDeterminer.java#L100 > > > > > Thanks > > > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Fwd: Type conversion collection with interface type elements
[copy with removed links to avoid detection as spam] Forwarded Message Subject: Re: Type conversion collection with interface type elements Date: Thu, 5 Apr 2018 13:02:01 + From: Yasser Zamani Reply-To: Struts Users Mailing List To: user@struts.apache.org On 4/4/2018 7:20 PM, Nuno Oliveira wrote: > Hi, > > I am having problems populating an action variable Set by request using > struts type conversion if the Set has the element type defined as an > interface. > I have a UserAction-conversion.properties file with the following > configuration using the class implementation: > > KeyProperty_roles=id > Element_roles=path.to.class.Roles > CreateIfNull_roles=true > > And UserAction has the collection Set. Roles obviously > implements RolesInterface. > > If the Set element type is deleted it works just fine. > Am I doing something wrong or is this not possible? I reproduced it and seems it's because it tries to instantiate a new element but the interface cannot being instantiated. Please see [1] to know why it tries to instantiate interface instead of class. Annotating the getRoles or setRoles method with @Element(value = path.to.class.Roles.class) may fix this issue. (shouldn't it be path.to.class.Role instead? it seems Roles is a list not element) Regards. [1] github.com/apache/struts/blob/05829e3faadd15cfa67eb234cd1775f2b98918cb/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DefaultObjectTypeDeterminer.java#L100 > > Thanks >
Re: Type conversion collection with interface type elements
On 4/4/2018 7:20 PM, Nuno Oliveira wrote: > Hi, > > I am having problems populating an action variable Set by request using > struts type conversion if the Set has the element type defined as an > interface. > I have a UserAction-conversion.properties file with the following > configuration using the class implementation: > > KeyProperty_roles=id > Element_roles=path.to.class.Roles > CreateIfNull_roles=true > > And UserAction has the collection Set. Roles obviously > implements RolesInterface. > > If the Set element type is deleted it works just fine. > Am I doing something wrong or is this not possible? I reproduced it and seems it's because it tries to instantiate a new element but the interface cannot being instantiated. Please see [1] to know why it tries to instantiate interface instead of class. Annotating the getRoles or setRoles method with @Element(value = path.to.class.Roles.class) may fix this issue. (shouldn't it be path.to.class.Role instead? it seems Roles is a list not element) Regards. [1] https://github.com/apache/struts/blob/05829e3faadd15cfa67eb234cd1775f2b98918cb/core/src/main/java/com/opensymphony/xwork2/conversion/impl/DefaultObjectTypeDeterminer.java#L100 > > Thanks > - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Type conversion collection with interface type elements
Hi, I am having problems populating an action variable Set by request using struts type conversion if the Set has the element type defined as an interface. I have a UserAction-conversion.properties file with the following configuration using the class implementation: KeyProperty_roles=id Element_roles=path.to.class.Roles CreateIfNull_roles=true And UserAction has the collection Set. Roles obviously implements RolesInterface. If the Set element type is deleted it works just fine. Am I doing something wrong or is this not possible? Thanks - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Conversion Error Interceptor prevent errors for empty values
Yasser, Thanks for pointing me to the right class. After debugging, I found the problem was in my template and it was including the option body in the value when trying to set it to empty. There is no issue with the Interceptor and it is working as documented. Thanks for your help. Paul R. Zepernick Sr. Programmer Analyst HealthSmart Benefit Solutions -Original Message- From: Yasser Zamani [mailto:yasser.zam...@live.com] On Behalf Of Yasser Zamani Sent: Wednesday, February 14, 2018 11:41 AM To: user@struts.apache.org Subject: Re: Conversion Error Interceptor prevent errors for empty values On 2/14/2018 5:13 PM, Paul Zepernick wrote: > Yes, I have it happening on 2.5.14.1. I have a select box pointing at a > Integer like this: auditForm.incorrectAuditReason.id I am using the rest > plugin which is including it in the stack. I have attached the source from > Maven. Where is the check being done in the code? I see the check for > shouldAddError() always returning true. > No you should check `org.apache.struts2.interceptor.StrutsConversionErrorInterceptor` (prefixed with `Struts`) instead. Could you put a break point on it's `shouldAddError` method and see what happens when you post auditForm.incorrectAuditReason.id? > I have attempted to override the default interceptor by adding this in my > package and overriding the shouldAddError(), but it continues to call the > default Struts ConversionErrorInterceptor. > > class="com.hs.iws.struts2.IwsConversionErrorInterceptor"/> > I think you should define your stack including your new interceptor and ref it in your action definition. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org Disclaimer: This communication and any files transmitted with it may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this communication in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Conversion Error Interceptor prevent errors for empty values
On 2/14/2018 5:13 PM, Paul Zepernick wrote: > Yes, I have it happening on 2.5.14.1. I have a select box pointing at a > Integer like this: auditForm.incorrectAuditReason.id I am using the rest > plugin which is including it in the stack. I have attached the source from > Maven. Where is the check being done in the code? I see the check for > shouldAddError() always returning true. > No you should check `org.apache.struts2.interceptor.StrutsConversionErrorInterceptor` (prefixed with `Struts`) instead. Could you put a break point on it's `shouldAddError` method and see what happens when you post auditForm.incorrectAuditReason.id? > I have attempted to override the default interceptor by adding this in my > package and overriding the shouldAddError(), but it continues to call the > default Struts ConversionErrorInterceptor. > > class="com.hs.iws.struts2.IwsConversionErrorInterceptor"/> > I think you should define your stack including your new interceptor and ref it in your action definition. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Conversion Error Interceptor prevent errors for empty values
Trying the attachment again as a txt Paul R. Zepernick Sr. Programmer Analyst HealthSmart Benefit Solutions -Original Message- From: Paul Zepernick [mailto:paul.zepern...@healthsmart.com] Sent: Wednesday, February 14, 2018 8:44 AM To: user@struts.apache.org Subject: RE: Conversion Error Interceptor prevent errors for empty values Yes, I have it happening on 2.5.14.1. I have a select box pointing at a Integer like this: auditForm.incorrectAuditReason.id I am using the rest plugin which is including it in the stack. I have attached the source from Maven. Where is the check being done in the code? I see the check for shouldAddError() always returning true. I have attempted to override the default interceptor by adding this in my package and overriding the shouldAddError(), but it continues to call the default Struts ConversionErrorInterceptor. Paul R. Zepernick Sr. Programmer Analyst HealthSmart Benefit Solutions -Original Message- From: Yasser Zamani [mailto:yasser.zam...@live.com] On Behalf Of Yasser Zamani Sent: Wednesday, February 14, 2018 4:25 AM To: user@struts.apache.org Subject: Re: Conversion Error Interceptor prevent errors for empty values On 2/13/2018 8:06 PM, Paul Zepernick wrote: > Can someone provide some clarification on if this interceptor should be > adding a field error when an empty string is passed to a Integer in the > action? No, it should not be happening for `conversionError` interceptor. Does it happen? > I am trying to prevent the field error from happening in this case. It > looks like it should not be happening according to the docs: > https://struts.apache.org/core-developers/conversion-error-interceptor.html , > or am I not understanding what it is saying here: > > "This interceptor extends ConversionErrorInterceptor but only adds conversion > errors from the ActionContext to the field errors of the action if the field > value is not null, "", or {""} (a size 1 String array with only an empty > String). See ConversionErrorInterceptor for more information, as well as the > Type Conversion documentation" You understood correctly. I reviewed it's code and looks like it should behave as above. Doesn't it? I also saw `conversionError` is already included in default stack. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org Disclaimer: This communication and any files transmitted with it may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this communication in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package com.opensymphony.xwork2.interceptor; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.conversion.impl.XWorkConverter; import com.opensymphony.xwork2.util.ValueStack; import org.apache.commons.lang3.StringEscapeUtils; import java.util.HashMap; import java.util.Map; /** * * ConversionErrorInterceptor adds conversion errors from the ActionContext to the Action's field errors. * * * This interceptor adds any error found in the {@link ActionContext}'s conversionErrors map as a field error (provided * that the action implements {@link ValidationAware}). In addition, any field that contains a validation error has its * original value saved such that any subsequent requests for that value return the original value rather than the value * in the action. This is important because if the value "abc" is submitted and can't be converted to an int, we want to * display the original string ("abc&q
RE: Conversion Error Interceptor prevent errors for empty values
Yes, I have it happening on 2.5.14.1. I have a select box pointing at a Integer like this: auditForm.incorrectAuditReason.id I am using the rest plugin which is including it in the stack. I have attached the source from Maven. Where is the check being done in the code? I see the check for shouldAddError() always returning true. I have attempted to override the default interceptor by adding this in my package and overriding the shouldAddError(), but it continues to call the default Struts ConversionErrorInterceptor. Paul R. Zepernick Sr. Programmer Analyst HealthSmart Benefit Solutions -Original Message- From: Yasser Zamani [mailto:yasser.zam...@live.com] On Behalf Of Yasser Zamani Sent: Wednesday, February 14, 2018 4:25 AM To: user@struts.apache.org Subject: Re: Conversion Error Interceptor prevent errors for empty values On 2/13/2018 8:06 PM, Paul Zepernick wrote: > Can someone provide some clarification on if this interceptor should be > adding a field error when an empty string is passed to a Integer in the > action? No, it should not be happening for `conversionError` interceptor. Does it happen? > I am trying to prevent the field error from happening in this case. It > looks like it should not be happening according to the docs: > https://struts.apache.org/core-developers/conversion-error-interceptor.html , > or am I not understanding what it is saying here: > > "This interceptor extends ConversionErrorInterceptor but only adds conversion > errors from the ActionContext to the field errors of the action if the field > value is not null, "", or {""} (a size 1 String array with only an empty > String). See ConversionErrorInterceptor for more information, as well as the > Type Conversion documentation" You understood correctly. I reviewed it's code and looks like it should behave as above. Doesn't it? I also saw `conversionError` is already included in default stack. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org Disclaimer: This communication and any files transmitted with it may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this communication in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Conversion Error Interceptor prevent errors for empty values
On 2/13/2018 8:06 PM, Paul Zepernick wrote: > Can someone provide some clarification on if this interceptor should be > adding a field error when an empty string is passed to a Integer in the > action? No, it should not be happening for `conversionError` interceptor. Does it happen? > I am trying to prevent the field error from happening in this case. It > looks like it should not be happening according to the docs: > https://struts.apache.org/core-developers/conversion-error-interceptor.html , > or am I not understanding what it is saying here: > > "This interceptor extends ConversionErrorInterceptor but only adds conversion > errors from the ActionContext to the field errors of the action if the field > value is not null, "", or {""} (a size 1 String array with only an empty > String). See ConversionErrorInterceptor for more information, as well as the > Type Conversion documentation" You understood correctly. I reviewed it's code and looks like it should behave as above. Doesn't it? I also saw `conversionError` is already included in default stack. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Conversion Error Interceptor prevent errors for empty values
Can someone provide some clarification on if this interceptor should be adding a field error when an empty string is passed to a Integer in the action? I am trying to prevent the field error from happening in this case. It looks like it should not be happening according to the docs: https://struts.apache.org/core-developers/conversion-error-interceptor.html , or am I not understanding what it is saying here: "This interceptor extends ConversionErrorInterceptor but only adds conversion errors from the ActionContext to the field errors of the action if the field value is not null, "", or {""} (a size 1 String array with only an empty String). See ConversionErrorInterceptor for more information, as well as the Type Conversion documentation" Paul R. Zepernick Sr. Programmer Analyst HealthSmart Benefit Solutions Disclaimer: This communication and any files transmitted with it may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this communication in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.
Re: Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
thanks Yasser for all you help and code. I would like to conclude this as a struts2 upgrade change, as BigDecimal field value was setting as BigDecimal.ZERO when field value passed as empty in struts2.5.10.x or < whereas 2.5.13 will set such empty BigDecimal field as null value (that is the correct behavior according to me as well), so planning to do a through testing across my project and correct such issues. -- Sent from: http://struts.1045723.n5.nabble.com/Struts-User-f3426046.html - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
2017-10-04 12:41 GMT+02:00 Yasser Zamani : >> 2.5.13. But now I also tested 2.5.10.1 and get following warn when try >> to set empty string value to a BigDecimal: >> >> Unexpected Exception caught setting 'myList[0].crAmt' on 'class >> me.zamani.yasser.ww_convention.actions.MyBigDecimalList: Error setting >> expression 'myList[0].crAmt' with value ['', ] > > This is because of line#93 [1] in Struts 2.5.13: > > ```java > return format.parse(strValue); > ``` This an expected behaviour, assigning an empty String to BigDecimal means you want to have "null" - there is no default value as for primitives (0 for int, false for boolean, etc). I would rather add a required validator upfront instead of changing the conversion logic. Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
On 10/4/2017 10:45 AM, sreekanth wrote: > thanks Yasser, let me setup a sample too. I already went through fixes > introduced at WW-4581 as well and ran a test against it and found that's not > the reason for this behavior rather something related to form field binding. > > Here i'm adding your finding which i too believe the root cause for this new > behavior. > > * > 2.5.13. But now I also tested 2.5.10.1 and get following warn when try > to set empty string value to a BigDecimal: > > Unexpected Exception caught setting 'myList[0].crAmt' on 'class > me.zamani.yasser.ww_convention.actions.MyBigDecimalList: Error setting > expression 'myList[0].crAmt' with value ['', ] > * > This is because of line#93 [1] in Struts 2.5.13: ```java return format.parse(strValue); ``` Currently it cannot parse empty values to 0 as java's DecimalFormat class cannot. Maybe we can change the behavior by replacing any empty with "0" in Strut's future versions ?! Until that time, I think you can extend NumberConverter and override it's convertToBigDecimal method and use it instead (see also [2]): ```java @override protected Object convertToBigDecimal(context,value) { String strValue = String.valueOf(value); if(null==value || strValue.isNullOrEmpty()) strValue="0"; return super.convertToBigDecimal(context,strValue); } ``` Hope these help! Yasser. [1] https://gitbox.apache.org/repos/asf?p=struts.git;a=blob;f=core/src/main/java/com/opensymphony/xwork2/conversion/impl/NumberConverter.java;h=16bbd499e00f03d4a673cd43d90dc261db3849df;hb=f874f9cde56f74c5161b17e645f779805c51a04b#l93 [2] https://saifmasadeh.blogspot.com/2012/10/custom-converter-for-bigdecimal-struts2.htm > > > -- > Sent from: http://struts.1045723.n5.nabble.com/Struts-User-f3426046.html > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org >
Re: Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
thanks Yasser, let me setup a sample too. I already went through fixes introduced at WW-4581 as well and ran a test against it and found that's not the reason for this behavior rather something related to form field binding. Here i'm adding your finding which i too believe the root cause for this new behavior. * 2.5.13. But now I also tested 2.5.10.1 and get following warn when try to set empty string value to a BigDecimal: Unexpected Exception caught setting 'myList[0].crAmt' on 'class me.zamani.yasser.ww_convention.actions.MyBigDecimalList: Error setting expression 'myList[0].crAmt' with value ['', ] * -- Sent from: http://struts.1045723.n5.nabble.com/Struts-User-f3426046.html - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
On 10/4/2017 9:19 AM, sreekanth wrote: > thanks Yasser, that info was great, so do you think so the way struts2 binds > BigDecimal changed between these two versions ? I found the difference at [1]. That is in order to fix WW-4581 [2]. [1] https://gitbox.apache.org/repos/asf?p=struts.git;a=commitdiff;h=f874f9cde56f74c5161b17e645f779805c51a04b [2] https://issues.apache.org/jira/browse/WW-4581 > and also if possible kindly > share your sample project in github so that i can fork it and check myself > faster. > My sample is inside a big project like a big Struts lab ;) but the config is simple as below: ```java package me.zamani.yasser.ww_convention.actions; import java.math.BigDecimal; /** * Created by user on 10/3/2017. */ public class A { public String getStrVal() { return strVal; } public void setStrVal(String strVal) { this.strVal = strVal; } public BigDecimal getDrAmt() { return drAmt; } public void setDrAmt(BigDecimal drAmt) { this.drAmt = drAmt; } public BigDecimal getCrAmt() { return crAmt; } public void setCrAmt(BigDecimal crAmt) { this.crAmt = crAmt; } String strVal; BigDecimal drAmt; BigDecimal crAmt; } ``` ```java package me.zamani.yasser.ww_convention.actions; import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.convention.annotation.InterceptorRef; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import java.lang.reflect.Field; import java.math.BigDecimal; import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; @Results({ @Result(name = Action.SUCCESS, location = "/WEB-INF/content/myBigDecimalList.jsp"/*, type = "freemarker"*/) }) public class MyBigDecimalList extends ActionSupport { public List getMyList() { return myList; } public void setMyList(List myList) { this.myList = myList; } private List myList; @org.apache.struts2.convention.annotation.Action(value="myBigDecimalList") public String execute() throws Exception { A a = new A(); a.setStrVal("my str val"); a.setCrAmt(new BigDecimal("0.0120816681711721685132943093776702880859375")); a.setDrAmt(new BigDecimal("0.0220816681711721685132943093776702880859375")); myList=new ArrayList<>(); myList.add(a); NumberFormat format = NumberFormat.getNumberInstance(getLocale()); //NumberFormat.set format.setMaximumFractionDigits(40); return Action.SUCCESS; } } ``` ```jsp <%@taglib prefix="s" uri="/struts-tags"%> <%-- Created by IntelliJ IDEA. User: user Date: 8/18/2017 Time: 12:36 AM To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> AdvancedWildcardAction1 ``` Hope these help! Yasser. > > > -- > Sent from: http://struts.1045723.n5.nabble.com/Struts-User-f3426046.html > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org >
Re: Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
thanks Yasser, that info was great, so do you think so the way struts2 binds BigDecimal changed between these two versions ? and also if possible kindly share your sample project in github so that i can fork it and check myself faster. -- Sent from: http://struts.1045723.n5.nabble.com/Struts-User-f3426046.html - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
On 10/4/2017 8:07 AM, sreekanth wrote: > thanks Yasser, may i know with which version of struts you have tested it > 2.5.10.1 or 2.5.13 ? > 2.5.13. But now I also tested 2.5.10.1 and get following warn when try to set empty string value to a BigDecimal: Unexpected Exception caught setting 'myList[0].crAmt' on 'class me.zamani.yasser.ww_convention.actions.MyBigDecimalList: Error setting expression 'myList[0].crAmt' with value ['', ] Also, 2.5.10.1 does not round my values during creating the s:hidden tag. > > > -- > Sent from: http://struts.1045723.n5.nabble.com/Struts-User-f3426046.html > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org >
Re: Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
thanks Yasser, may i know with which version of struts you have tested it 2.5.10.1 or 2.5.13 ? -- Sent from: http://struts.1045723.n5.nabble.com/Struts-User-f3426046.html - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
On 10/3/2017 10:33 PM, sreekanth wrote: > Thanks Yasser, if my previous doubts get cleared then probably i can assume > there is behavioral change in binding empty value. If thats not the case > then will try to replicate as you have mentioned. > In my yesterday test application, empty string value converts to null. The locale is en_US. > > > -- > Sent from: http://struts.1045723.n5.nabble.com/Struts-User-f3426046.html > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org >
Re: Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
Thanks Yasser, if my previous doubts get cleared then probably i can assume there is behavioral change in binding empty value. If thats not the case then will try to replicate as you have mentioned. -- Sent from: http://struts.1045723.n5.nabble.com/Struts-User-f3426046.html - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
Hi Lukasz, what bothering me is, we haven't changed this particular jsp since an year or more and its working fine till 2.5.10.x. I have the following doubt, if it can be answered then i can assume whats going wrong in my code. What was the behaviour of struts 2.5.10.1 while converting an empty value ? was it converting to null or was it converting to BigDecimal ZERO ? -- Sent from: http://struts.1045723.n5.nabble.com/Struts-User-f3426046.html - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
On 10/3/2017 9:56 PM, sreekanth wrote: > The value not getting set at all, its coming as null. By the time i will also > see if i can provide some log as you mentioned. > I tested similar action with a list of A where A has two BigDecimals; posted values (myList[x].y] getting set here however they're rounded but are setted. please use following resources to find the cause there: [1] https://struts.apache.org/docs/devmode.html [2] https://struts.apache.org/getting-started/how-to-create-a-struts2-web-application.html (Step 4 - Add Logging; set levels to WARN) > > > -- > Sent from: http://struts.1045723.n5.nabble.com/Struts-User-f3426046.html > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org >
Re: Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
2017-10-03 20:03 GMT+02:00 sreekanth : > Thanks Lukasz, can you please point me some wiki page or what change i have > to do to make my existing code working ? Hm... as far I recall there is no special settings, just use format according to user locale, eg.: US locale 1.000,12, DE locale 1 000,12 Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
The value not getting set at all, its coming as null. By the time i will also see if i can provide some log as you mentioned. -- Sent from: http://struts.1045723.n5.nabble.com/Struts-User-f3426046.html - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
On 10/3/2017 8:26 PM, sreekanth wrote: > Hi, > We have a List object which is getting set at JSP (element added > dynamically in front end), while saving this form the object's value for > BigDecimal fields are getting null. > > eg: > > Class A { > String strVal; > BigDecimal drAmt; > BigDecimal crAmt; > } > > in jsp > > > > > > while we submit the form *strVal* is getting binded properly but both *drAmt > and crAmt* not getting set. Do they not being setted at all or they being setted but with a rounded value? If not setted at all, I recommend setting devmode to true and configuring log4j2 level to WARN and then examining the output for any related WARN. If you have problem with rounded values posted back, then I think you can `setMaximumFractionDigits` to a larger number in current locale. > > When i revert the upgrade back to 2.5.10.1 then it started working. > > > > -- > Sent from: http://struts.1045723.n5.nabble.com/Struts-User-f3426046.html > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org >
Re: Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
Thanks Lukasz, can you please point me some wiki page or what change i have to do to make my existing code working ? -- Sent from: http://struts.1045723.n5.nabble.com/Struts-User-f3426046.html - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
2017-10-03 18:56 GMT+02:00 sreekanth : > Hi, > We have a List object which is getting set at JSP (element added > dynamically in front end), while saving this form the object's value for > BigDecimal fields are getting null. > > eg: > > Class A { > String strVal; > BigDecimal drAmt; > BigDecimal crAmt; > } > > in jsp > > > > > > while we submit the form *strVal* is getting binded properly but both *drAmt > and crAmt* not getting set. As from Struts version 2.3.12, the built-in converter is Locale aware which means it will convert String to BigDecimal according to user locale. Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Iusse in BigDecimal conversion after upgrading from 2.5.10.1 to 2.5.13
Hi, We have a List object which is getting set at JSP (element added dynamically in front end), while saving this form the object's value for BigDecimal fields are getting null. eg: Class A { String strVal; BigDecimal drAmt; BigDecimal crAmt; } in jsp while we submit the form *strVal* is getting binded properly but both *drAmt and crAmt* not getting set. When i revert the upgrade back to 2.5.10.1 then it started working. -- Sent from: http://struts.1045723.n5.nabble.com/Struts-User-f3426046.html - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Can you use type conversion with JSONInterceptor?
Super cool, thanks :) 2016-12-02 11:40 GMT+01:00 Miguel Almeida : > Thank you Lukasz! > > I will check if/how we can inject the converter there. If we manage to > get it working in a way that helps the ticket resolution I'll also post > the information there. > > > > On Sex, 2016-12-02 at 09:50 +0100, Lukasz Lenart wrote: > >> Hi, >> >> JSON plugin uses its own conversation mechanism, check JSONPopulator >> but I think it should be possible to inject XWorkConverter and use it >> to convert objects - this requires implementing your own >> JSONPopulator. >> >> There is a task to do it so it should happen in Struts 2.5 ;-) >> https://issues.apache.org/jira/browse/WW-3364 >> >> >> Regards - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Can you use type conversion with JSONInterceptor?
Thank you Lukasz! I will check if/how we can inject the converter there. If we manage to get it working in a way that helps the ticket resolution I'll also post the information there. On Sex, 2016-12-02 at 09:50 +0100, Lukasz Lenart wrote: > Hi, > > JSON plugin uses its own conversation mechanism, check JSONPopulator > but I think it should be possible to inject XWorkConverter and use it > to convert objects - this requires implementing your own > JSONPopulator. > > There is a task to do it so it should happen in Struts 2.5 ;-) > https://issues.apache.org/jira/browse/WW-3364 > > > Regards
Re: Can you use type conversion with JSONInterceptor?
Hi, JSON plugin uses its own conversation mechanism, check JSONPopulator but I think it should be possible to inject XWorkConverter and use it to convert objects - this requires implementing your own JSONPopulator. There is a task to do it so it should happen in Struts 2.5 ;-) https://issues.apache.org/jira/browse/WW-3364 Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ 2016-12-01 20:07 GMT+01:00 Miguel Almeida : > Imagine SearchAction{ > > private List evaluatedRecords; > } > > Record is an interface so to get auto-wiring to work you'd usually > set-up a > > SearchAction-conversion.properties: > KeyProperty_evaluatedRecords=id > Element_evaluatedRecords=com.bibliovigilance.model.RecordImpl > CreateIfNull_evaluatedRecords=true > > > I now want to create an Ajax post on this action. I tried the following: > > var evaluatedRecords = [ > {"id": "10672"} > ] > > var json_parameters = {evaluatedRecords: > evaluatedRecords}; > > $.ajax({ > url: 'SearchmarkSelectedArticlesJSON.action', > cache: false, > contentType: 'application/json', > data: JSON.stringify(json_parameters), > type: "POST" > }); > > I believe I need to set-up the JSON interceptor on my action, so I > added: > method="markSelectedArticles"> > > > > The problem is that this interceptor doesn't seem to be using the > -conversion.properties, so it throws an error when it tries to > instantiate the Record class: > > java.lang.InstantiationException: com.bibliovigilance.model.Record > at java.lang.Class.newInstance(Class.java:368) > at > org.apache.struts2.json.JSONPopulator.convertToCollection(JSONPopulator.java:250) > > > I also tried removing the Record type in the List ( List > evaluatedRecords). But in this case the JSON deserialization of the > above mentioned ajax call will create a List evaluatedRecords with 1 > element, but that element is a Map (I didn't investigate, but I suppose > it'll have id in the key and 10672 in the value). > > How would we configure this correctly? Is it possible for the JSON > interceptor to be aware of the -conversion.properties? If not, what > alternatives do you envision? > > Thanks! > > Miguel - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Can you use type conversion with JSONInterceptor?
Imagine SearchAction{ private List evaluatedRecords; } Record is an interface so to get auto-wiring to work you'd usually set-up a SearchAction-conversion.properties: KeyProperty_evaluatedRecords=id Element_evaluatedRecords=com.bibliovigilance.model.RecordImpl CreateIfNull_evaluatedRecords=true I now want to create an Ajax post on this action. I tried the following: var evaluatedRecords = [ {"id": "10672"} ] var json_parameters = {evaluatedRecords: evaluatedRecords}; $.ajax({ url: 'SearchmarkSelectedArticlesJSON.action', cache: false, contentType: 'application/json', data: JSON.stringify(json_parameters), type: "POST" }); I believe I need to set-up the JSON interceptor on my action, so I added: The problem is that this interceptor doesn't seem to be using the -conversion.properties, so it throws an error when it tries to instantiate the Record class: java.lang.InstantiationException: com.bibliovigilance.model.Record at java.lang.Class.newInstance(Class.java:368) at org.apache.struts2.json.JSONPopulator.convertToCollection(JSONPopulator.java:250) I also tried removing the Record type in the List ( List evaluatedRecords). But in this case the JSON deserialization of the above mentioned ajax call will create a List evaluatedRecords with 1 element, but that element is a Map (I didn't investigate, but I suppose it'll have id in the key and 10672 in the value). How would we configure this correctly? Is it possible for the JSON interceptor to be aware of the -conversion.properties? If not, what alternatives do you envision? Thanks! Miguel
Re: Set timezone in jsonwriter for date conversion
Yeah, right now it's hard. I think the best option is to write your own JSON result with all the custom stuff you need - JSONWriter & JSONUtil. I'm going to refactor JSON plugin to be more extensible but it won't happen till Struts 2.5. Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ 2015-11-05 1:05 GMT+01:00 JOSE L MARTINEZ-AVIAL : > Hello, > >Let me clarify the issue I have. I would like to be able to customize > the way the JSON plugin formats the date when converting an objecto to > json. Specifically, when I'm returning a JSONResult to a client. In order > to do that I need to modify the DateFormatter used by JSONWriter so I can > change its timezone. I took a look at the code, and it seems that make that > modification is going to be hard. It would be something like this: > > Extend JSONWriter to be able to use timezone with a Date(Maybe receiving > the timezone as a parameter, or using annotation at the field level) > Extend JSONUtil to call my custom JSONWriter. > Extend JSONResult to call my customer JSONUtil, by overriding the method > createJSONString. This would pretty much imply copy the whole code, as the > method has a bunch of dependences from private variables when calling > JSONUtil. > > Can anyone suggest a better approach? > > JL > > 2015-11-03 14:13 GMT-05:00 JOSE L MARTINEZ-AVIAL : > >> Hello, >>I'm using Struts 2.3.16.3. I use the json plugin to return information >> to the client (browser and ios App). The problem I have is that the >> dates/times are local to my server, and since I have the option to know the >> client's timezone, I would like to return the date to the client converted >> to his local time. In order to do that I need to set the timezone of the >> DateFormatter used by the json plugin. I don't see any issue way to do >> that, apart from extending JSONWriter. Is that something possible? how I >> would indicate the plugin to use my own version of JSONWriter? >> >> Thanks >> >> JL >> - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Set timezone in jsonwriter for date conversion
Hello, Let me clarify the issue I have. I would like to be able to customize the way the JSON plugin formats the date when converting an objecto to json. Specifically, when I'm returning a JSONResult to a client. In order to do that I need to modify the DateFormatter used by JSONWriter so I can change its timezone. I took a look at the code, and it seems that make that modification is going to be hard. It would be something like this: Extend JSONWriter to be able to use timezone with a Date(Maybe receiving the timezone as a parameter, or using annotation at the field level) Extend JSONUtil to call my custom JSONWriter. Extend JSONResult to call my customer JSONUtil, by overriding the method createJSONString. This would pretty much imply copy the whole code, as the method has a bunch of dependences from private variables when calling JSONUtil. Can anyone suggest a better approach? JL 2015-11-03 14:13 GMT-05:00 JOSE L MARTINEZ-AVIAL : > Hello, >I'm using Struts 2.3.16.3. I use the json plugin to return information > to the client (browser and ios App). The problem I have is that the > dates/times are local to my server, and since I have the option to know the > client's timezone, I would like to return the date to the client converted > to his local time. In order to do that I need to set the timezone of the > DateFormatter used by the json plugin. I don't see any issue way to do > that, apart from extending JSONWriter. Is that something possible? how I > would indicate the plugin to use my own version of JSONWriter? > > Thanks > > JL >
Set timezone in jsonwriter for date conversion
Hello, I'm using Struts 2.3.16.3. I use the json plugin to return information to the client (browser and ios App). The problem I have is that the dates/times are local to my server, and since I have the option to know the client's timezone, I would like to return the date to the client converted to his local time. In order to do that I need to set the timezone of the DateFormatter used by the json plugin. I don't see any issue way to do that, apart from extending JSONWriter. Is that something possible? how I would indicate the plugin to use my own version of JSONWriter? Thanks JL
Re: More website doc problems: Type Conversion and Conversion Annotation
Thanks, fixed! 2015-09-01 0:18 GMT+02:00 JOSE L MARTINEZ-AVIAL : > Hello, > page https://struts.apache.org/docs/dispatcher-result.html is also > failing. > > thanks > > JL > > 2015-08-20 2:11 GMT-04:00 Lukasz Lenart : > >> 2015-08-19 18:55 GMT+02:00 rgm : >> > In order to determine the best way to prompt for and store a >> > javax.mail.internet.InternetAddress, I began researching these pages, >> which >> > are broken to various degrees: >> > >> > https://cwiki.apache.org/confluence/display/WW/Type+Conversion >> > https://cwiki.apache.org/confluence/display/WW/Conversion+Annotation >> > >> > Both show "Error formatting macro: snippet: >> > java.lang.IndexOutOfBoundsException: Index: 20, Size: 20." >> >> Thanks for reporting, resolved :) >> >> >> Regards >> -- >> Łukasz >> + 48 606 323 122 http://www.lenart.org.pl/ >> >> - >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: More website doc problems: Type Conversion and Conversion Annotation
Hello, page https://struts.apache.org/docs/dispatcher-result.html is also failing. thanks JL 2015-08-20 2:11 GMT-04:00 Lukasz Lenart : > 2015-08-19 18:55 GMT+02:00 rgm : > > In order to determine the best way to prompt for and store a > > javax.mail.internet.InternetAddress, I began researching these pages, > which > > are broken to various degrees: > > > > https://cwiki.apache.org/confluence/display/WW/Type+Conversion > > https://cwiki.apache.org/confluence/display/WW/Conversion+Annotation > > > > Both show "Error formatting macro: snippet: > > java.lang.IndexOutOfBoundsException: Index: 20, Size: 20." > > Thanks for reporting, resolved :) > > > Regards > -- > Łukasz > + 48 606 323 122 http://www.lenart.org.pl/ > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
Re: More website doc problems: Type Conversion and Conversion Annotation
2015-08-19 18:55 GMT+02:00 rgm : > In order to determine the best way to prompt for and store a > javax.mail.internet.InternetAddress, I began researching these pages, which > are broken to various degrees: > > https://cwiki.apache.org/confluence/display/WW/Type+Conversion > https://cwiki.apache.org/confluence/display/WW/Conversion+Annotation > > Both show "Error formatting macro: snippet: > java.lang.IndexOutOfBoundsException: Index: 20, Size: 20." Thanks for reporting, resolved :) Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
More website doc problems: Type Conversion and Conversion Annotation
In order to determine the best way to prompt for and store a javax.mail.internet.InternetAddress, I began researching these pages, which are broken to various degrees: https://cwiki.apache.org/confluence/display/WW/Type+Conversion https://cwiki.apache.org/confluence/display/WW/Conversion+Annotation Both show "Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20."
Re: Format Conversion
2015-05-15 10:13 GMT+02:00 Dhandapani, Rajeswaran : > Hi All, > > I have the below code to display the cost in currency format and the iterator > iterates over hash map. All the values are displayed inside property tag > except the formatted "value.cost". Could you please help me to fix the > display. > > > > > > > > > Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Format Conversion
Hi All, I have the below code to display the cost in currency format and the iterator iterates over hash map. All the values are displayed inside property tag except the formatted "value.cost". Could you please help me to fix the display. Thank you. Rajeswaran D ** This message and any files or attachments sent with this message contain confidential information and is intended only for the individual named. If you are not the named addressee, you should not disseminate, distribute, copy or use any part of this email. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return Email. Email transmission cannot be guaranteed to be secure or error-free as information can be intercepted, corrupted, lost, destroyed, late, incomplete or may contain viruses. The sender, therefore, does not accept liability for any errors or omissions in the contents of this message, which arise as a result of email transmission. **
Re: Antwort: Re: Problems with type conversion and special characters
Really I was using a custom type converter (with annotations on getters & setters) but I had the problem that when typeconversionexception was thrown the dynamic contents on my web page (objects retrieved from db or from actions) didn't display. Really I don't know what the problem was, i suspect something with interceptors, maybe paramters interceptor wasn't able to retrieve passed parameters, but it's just a theory. Alessio Matteo Software developer & It assistant Via Angelo di Pietro, 6 I-00165 Rome, Italy Phone/Fax +39 06 6390339 E-mail amat...@transtecservices.com www.transtecservices.com Please consider the environment before printing this email Il 15/10/2013 10:40, Christoph Nenning ha scritto: Thank you so much, I solved the special characters problems by setting the struts i18n constant to ISO-8859-1! About the conversion error, I know it was a dev mode warning, but when the exception was thrown every dynamic content in my page disappeard... Anyway I solved the issue by declaring every action attribute as a string and using specific regex xml validators to deny invalid inputs. Then, in the action, I use parser and other utility methods to convert the attributes to their correct formats. Regards Instead of using strings as action members I would suggest to use custom TypeConverters: https://struts.apache.org/release/2.0.x/docs/type-conversion.html Note there is a TypeConversion annotation, too. That can be used to annotate action getters/setters. Regards, Christoph This Email was scanned by Sophos Anti Virus
Antwort: Re: Problems with type conversion and special characters
> > Thank you so much, I solved the special characters problems by setting > the struts i18n constant to ISO-8859-1! > About the conversion error, I know it was a dev mode warning, but when > the exception was thrown every dynamic content in my page disappeard... > Anyway I solved the issue by declaring every action attribute as a > string and using specific regex xml validators to deny invalid inputs. > Then, in the action, I use parser and other utility methods to convert > the attributes to their correct formats. > > Regards > > Instead of using strings as action members I would suggest to use custom TypeConverters: https://struts.apache.org/release/2.0.x/docs/type-conversion.html Note there is a TypeConversion annotation, too. That can be used to annotate action getters/setters. Regards, Christoph This Email was scanned by Sophos Anti Virus
Re: Problems with type conversion and special characters
Thank you so much, I solved the special characters problems by setting the struts i18n constant to ISO-8859-1! About the conversion error, I know it was a dev mode warning, but when the exception was thrown every dynamic content in my page disappeard... Anyway I solved the issue by declaring every action attribute as a string and using specific regex xml validators to deny invalid inputs. Then, in the action, I use parser and other utility methods to convert the attributes to their correct formats. Regards Il 11/10/2013 07:19, Lukasz Lenart ha scritto: Please ask such questions via User Mailing List 2013/10/10 Alessio Matteo : Hi, I'm trying to develop my Struts2 application, but I'm facing 2 problems that I can't solve: 1. I'm using xml validations for input forms, but I have a problem with double, dates and all non string type fields (all other validations are working fine). For example, I have a s:textfield on a jsp that is connected to a Date type object in the relative action, if I enter a correct date everything works fine, but if I try to input something "wrong"(a letter for example), the framework fails to convert the string I entered and I get this exception : java.lang.NoSuchMethodException: package.ActionName.setFieldName([Ljava.lang.String;) I also tried to implement my own converter extending StrutsTypeConverter and it seems to work, but when I throw TypeConversionException I keep on getting the same exception. What am I missing? I'm thinking about some interceptor problem, like conversionError interceptor, my package extends struts-default so all interceptors should be available, right? Should I configure something else about interceptors? Is it in devMode? It looks like just a warning in logs. 2. When in a s:textfield (in a generical jsp), I insert a ISO-8859-1 special character (like à,è,ì etc..), in the relaive action, the relative field is populated with "?" instead of special characters. I'm encoding everything in ISO-8859-1 (form acceptcharset, head page declaration, <%@ contentype%> etc..) but I can't find a way to convert this characters before they're passed to the action (Maybe interceptor problems here too?). may miss something obvious, indeed need someone to help me. ISO-8859-1 isn't the best choice, whole Java world uses UTF-8, also Struts2 by default encodes everything with UTF-8. So the best option is to switch to UTF-8 or you can change struts.i18n.encoding constant to ISO-8859-1 but thus probably won't solve all your problems. Regards - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Type conversion on a Map
2012/9/21 Miguel Almeida : > Sure! > > Here's a maven project with a failing test case. > > There's actually a map being built, but it's a , and the key > reads "OGNL no conversion possible". Got it working, but I think the main problem is with key value - it isn't a simple string but an int that must be converted to complex class Entity. First thing, in TypeConversionAction-conversion.properties just put: Key_simpleMap=test.example.Entity Element_simpleMap=java.lang.String CreateIfNull_codePropertyMap=true Next create xwork-conversion.properties in the root folder (src/java/resources) with: test.example.Entity=test.example.EntityConverter And the very end create EntityConverter (Struts2 must know how to convert int into Entity) public class EntityConverter extends StrutsTypeConverter { @Override public Object convertFromString(Map context, String[] values, Class toClass) { if (values != null && values.length > 0) { Entity entity = new Entity(); entity.setId(Integer.parseInt(values[0])); return entity; } return null; } @Override public String convertToString(Map context, Object o) { if (o != null) { return "" + ((Entity) o).getId(); } return null; } @Override public Object convertValue(Map context, Object o, Class toClass) { if (toClass == Entity.class) { return convertFromString(context, new String[]{o.toString()}, toClass); } return super.convertValue(context, o, toClass); } } The problem is in convertValue() method which supports only String based conversions (but simpleMap[1] => key = 1 was already converted to int) - and I'm thinking that the method should be changed from public Object convertValue(Map context, Object o, Class toClass) { if (toClass.equals(String.class)) { return convertToString(context, o); } else if (o instanceof String[]) { return convertFromString(context, (String[]) o, toClass); } else if (o instanceof String) { return convertFromString(context, new String[]{(String) o}, toClass); // <-- problematic line } else { return performFallbackConversion(context, o, toClass); } } to public Object convertValue(Map context, Object o, Class toClass) { if (toClass.equals(String.class)) { return convertToString(context, o); } else if (o instanceof String[]) { return convertFromString(context, (String[]) o, toClass); // <-- changed } else { return convertFromString(context, new String[]{o.toString()}, toClass); } } I've been using Struts 2.3.5-SNAPSHOT Kind regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: Type conversion on a Map
On Fri, 2012-09-21 at 09:04 -0400, Martin Gainty wrote: > a stupid question but i have to ask If you mean "where is the initialisation of simpleMap e.g. simpleMap=new java.util.HashMap();" - it's not there. I don't think you need to, Struts initializes it. (see below) > > public class TypeConversionAction extends ActionSupport > { > private Map simpleMap; //where is the initialisation of > simpleMap e.g. simpleMap=new java.util.HashMap(); > public Map getSimpleMap() { return simpleMap; } > public void setSimpleMap(Map simpleMap) { > this.simpleMap = simpleMap; } > public String execute() { return SUCCESS; } > } > > //then the test-harness: > > package test.example; > import java.util.Map; > import org.apache.struts2.StrutsTestCase; > import org.junit.Test; > import com.opensymphony.xwork2.ActionProxy; > import com.opensymphony.xwork2.ActionSupport; > > public class TypeConversionTest extends StrutsTestCase > { > private ActionProxy actionProxy; > private ActionSupport action; > > @Test > public void test() throws Exception{ > Entity entity = new Entity(); > entity.setId(1); > super.setUp(); > > request.setParameter("simpleMap[1]", "value"); > createAction("/example/Convesion.action"); > executeProxy(); > > Map complexMap = ((TypeConversionAction) > action).getSimpleMap(); > assertNotNull(complexMap); //getSimpleMap is NULL in the Action so it > would always be NULL here No. The test fails below, not here. executeProxy executed the action and initialized the map. If you run the test you'll see it fails on the last assertEquals, not here. > > assertFalse(complexMap.isEmpty()); //FAIL it is empty > assertEquals("value", complexMap.get(entity)); //Never initialised so > this would fail as well This is where it is failing. Not because it hasn't been initialized, but because it doesn't have that key. Miguel Almeida
RE: Type conversion on a Map
a stupid question but i have to ask public class TypeConversionAction extends ActionSupport { private Map simpleMap; //where is the initialisation of simpleMap e.g. simpleMap=new java.util.HashMap(); public Map getSimpleMap() { return simpleMap; } public void setSimpleMap(Map simpleMap) { this.simpleMap = simpleMap; } public String execute() { return SUCCESS; } } //then the test-harness: package test.example; import java.util.Map; import org.apache.struts2.StrutsTestCase; import org.junit.Test; import com.opensymphony.xwork2.ActionProxy; import com.opensymphony.xwork2.ActionSupport; public class TypeConversionTest extends StrutsTestCase { private ActionProxy actionProxy; private ActionSupport action; @Test public void test() throws Exception{ Entity entity = new Entity(); entity.setId(1); super.setUp(); request.setParameter("simpleMap[1]", "value"); createAction("/example/Convesion.action"); executeProxy(); Map complexMap = ((TypeConversionAction) action).getSimpleMap(); assertNotNull(complexMap); //getSimpleMap is NULL in the Action so it would always be NULL here assertFalse(complexMap.isEmpty()); //FAIL it is empty assertEquals("value", complexMap.get(entity)); //Never initialised so this would fail as well } /** * Creates the action with the given actionPath if it wasn't already created * @see isAlreadyCreated * @param actionPath * @throws Exception */ public ActionSupport createAction(String actionPath) throws Exception { actionProxy = getActionProxy(actionPath); action = (ActionSupport) actionProxy.getAction(); return action; } /** * Executes the action created and returns the result * @return * @throws Exception */ public String executeProxy() throws Exception { actionProxy.setExecuteResult(false); return actionProxy.execute(); } } ? Saludos, Martin __ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité 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. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. Subject: Re: Type conversion on a Map From: mig...@almeida.at To: user@struts.apache.org Date: Fri, 21 Sep 2012 10:31:24 +0100 Sure! Here's a maven project with a failing test case. There's actually a map being built, but it's a , and the key reads "OGNL no conversion possible". Cheers, Miguel Almeida On Thu, 2012-09-20 at 19:44 +0200, Lukasz Lenart wrote: Hi, Could you share the unit test as well ? The whole code would be the best :-) Regards - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Type conversion on a Map
Hi, Could you share the unit test as well ? The whole code would be the best :-) Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Type conversion on a Map
Dear all, Considering: 1) the action property Map complexMap; 2) CodeProperty has an int id property How would you configure type conversion and refer to it on the JSP to populate it? I am currently trying the following -conversion configuration: KeyProperty_complexMap=id Element_complexMap=java.lang.String Key_complexMap=persist.model.CodeProperty CreateIfNull_complexMap=true However, a simple jUnit test where I populate the request with getRequest().setParameter("complexMap[" + String.valueOf(33) + "]","test") doesn't populate the map as expected. Is the -conversion file wrong, the parameter set in the unit test, or both? Cheers, Miguel Almeida
Type Conversion annotation
Hi, Can we define @TypeConversion annotation of the nested property at the parent level. For Example I have a bean public class Bike { private Name name; public Name getName() { return this.name; } public void setName(Name name) { this.name = name; } } I would like to specify the @TypeConversion annotation for Name property in the model like below @Conversion public class Person { Bike bike; @TypeConversion(key = "bike.name", converter = "org.apache.struts.helloworld.model.MyConverter") public Bike getBike() { return this.bike; } public void setBike(Bike bike) { this.bike = bike; } } Is this possible? Regards, Shrinivas
Re: conversion error repopulation not working
I'll add this code as an additional example, but I'm wondering is it a good way to base on fieldErrors as they can be also populated by validators. Maybe adding ConversionAware interface with specific method to populate conversionErrors would be better ? Then I could extend ActionSupport with getFormatted() but base on conversionErrors instead. WDYT ? Regards -- Łukasz mobile +48 606 323 122 http://www.lenart.org.pl/ Warszawa JUG conference - Confitura http://confitura.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: conversion error repopulation not working
This works nicely. Thanks! Cheers, J. On Thu, May 31, 2012 at 3:07 PM, Łukasz Lenart wrote: > Can be reduced to this: > > public String getFormatted(String key, String fieldName, List args) { > if (getFieldErrors().isEmpty()) { > return getText(key, args); > } else { > return > ActionContext.getContext().getValueStack().findString(defaultValue); > } > } > > and it works just for one field ;-) There should check if there is a > error for given fieldName > > > Regards > -- > Łukasz > mobile +48 606 323 122 http://www.lenart.org.pl/ > Warszawa JUG conference - Confitura http://confitura.pl/ >
Re: conversion error repopulation not working
Can be reduced to this: public String getFormatted(String key, String fieldName, List args) { if (getFieldErrors().isEmpty()) { return getText(key, args); } else { return ActionContext.getContext().getValueStack().findString(defaultValue); } } and it works just for one field ;-) There should check if there is a error for given fieldName Regards -- Łukasz mobile +48 606 323 122 http://www.lenart.org.pl/ Warszawa JUG conference - Confitura http://confitura.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: conversion error repopulation not working
2012/5/31 J. Garcia : > The short-circuiting option sounds good. There could even be a specially > dedicated getText() (or alternative method name) for this scenario, which > should be rather frequent in l10n apps. Not the best solution, but works: and in ExampleAction (or any other base action class): public String getFormatted(String key, String defaultValue, List args) { TextProviderFactory tpf = new TextProviderFactory(); if (container != null) { container.inject(tpf); } TextProvider tp = tpf.createInstance(getClass(), this); if (getFieldErrors().isEmpty()) { return tp.getText(key, args); } else { return ActionContext.getContext().getValueStack().findString(defaultValue); } } Regards -- Łukasz mobile +48 606 323 122 http://www.lenart.org.pl/ Warszawa JUG conference - Confitura http://confitura.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: conversion error repopulation not working
2012/5/31 Łukasz Lenart : > Ok, looks like a problem is with getText() in jsp but I think there is > no other way ... you can use String instead and check for errors in > getter/setter but I'm not sure if it does the trick The problem is a bit complicated here as getText(String key, String[] args) accepts only strings, so getText("format.number", {user.born}) is converted to call getText("{0,number,#,##0.#}", String[]{"1980"}) - notice that all params are Strings - and then MessageFormat throws exception as it cannot format String as a Number. Right now I don't see any bright solution, I think there should be a short-circuit when conversion error occurs to skip evaluating getText() expression and just return what was specified as a key / name property. Regards -- Łukasz mobile +48 606 323 122 http://www.lenart.org.pl/ Warszawa JUG conference - Confitura http://confitura.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: conversion error repopulation not working
2012/5/31 J. Garcia : > Ok. Sorry. > Fixed the example to match the real situation. Prepare() will only execute > now if the request is a get method. Ok, looks like a problem is with getText() in jsp but I think there is no other way ... you can use String instead and check for errors in getter/setter but I'm not sure if it does the trick Regards -- Łukasz mobile +48 606 323 122 http://www.lenart.org.pl/ Warszawa JUG conference - Confitura http://confitura.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: conversion error repopulation not working
2012/5/29 J. Garcia : > Attached an example, generated from struts2 archetype and modified to > reproduce the situation. > > - run with mvn jetty:run. I use maven 2.2.1. > - on browser, type: localhost:8080/struts-test/example/Login > - you'll see a form, with formatted integer. > - modify the integer like this: AAA > - submit. An error msg informing of conversion error is shown. However, the > value AAA is not maintained. Instead, the current bean value is shown. But you use Preparable each time, and prepare overrides what was sent by user. I'm not sure if I understood that correctly but the same works fine in showcase application. Regards -- Łukasz mobile +48 606 323 122 http://www.lenart.org.pl/ Warszawa JUG conference - Confitura http://confitura.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: conversion error repopulation not working
2012/5/29 J. Garcia : > Integer. Strange, should work. Could you post an example code ? Regards -- Łukasz mobile +48 606 323 122 http://www.lenart.org.pl/ Warszawa JUG conference - Confitura http://confitura.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: conversion error repopulation not working
Integer. On Mon, May 28, 2012 at 10:04 AM, Łukasz Lenart < lukasz.len...@googlemail.com> wrote: > Is it int either Integer ? > > > Regards > -- > Łukasz > mobile +48 606 323 122 http://www.lenart.org.pl/ > Warszawa JUG conference - Confitura http://confitura.pl/ >
Re: conversion error repopulation not working
Is it int either Integer ? Regards -- Łukasz mobile +48 606 323 122 http://www.lenart.org.pl/ Warszawa JUG conference - Confitura http://confitura.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: conversion error repopulation not working
Thanks Lukasz for your reply. While preparing a minimal example, I got the reason of it all. The real situation is: - The input form has an int field - The value already available should be formatted and localized: 43,000 / 43.000 - In order to achive l10n, the input field tag is like this: In such a situation, the TextProviderHelper.getText() method is run, which obtains the value from the bean, rather than obtaining it from the wrong user input which was not possible to convert into the bean. It would be nice if there was a specific method which would check if the value to obtain is from an input field with conversion error. In such a case, it would obtain the value from the user input. If no error, the value would be from the bean. Does it make sense? Cheers, J. On Thu, May 24, 2012 at 8:10 AM, Łukasz Lenart wrote: > Could you add some code example ? > > > Regards > -- > Łukasz > mobile +48 606 323 122 http://www.lenart.org.pl/ > Warszawa JUG conference - Confitura http://confitura.pl/ > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
Re: conversion error repopulation not working
Could you add some code example ? Regards -- Łukasz mobile +48 606 323 122 http://www.lenart.org.pl/ Warszawa JUG conference - Confitura http://confitura.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
conversion error repopulation not working
Hi, In order to implement a good user experience, I am trying to put into practice the conversion validator, as documented here: http://struts.apache.org/2.3.3/docs/conversion-validator.html The ideal would be: a form with one integer field. If the user enters a non valid integer, the value remains in the input field and the user is informed of the error like this: Invalid value '198o' for field 'Year'. (notice the letter at the end). For this, I declare the conversion-validator, and have to remove the conversionError from the interceptors stack. While debugging, the class ConversionErrorFieldValidator builds a map, with the full fieldName and the entered value. The method repopulateField from RepopulateConversionErrorFieldValidatorSupport is run, which in theory repopulates the stack with this code: if (doExprOverride) { invocation.addPreResultListener(new PreResultListener() { public void beforeResult(ActionInvocation invocation, String resultCode) { ValueStack stack = ActionContext.getContext().getValueStack(); stack.setExprOverrides(fakeParams); } }); } However, when showing the jsp for user input, the invalid value is not in the form input field. It does not seem to work as documented in the mentioned url. Cheers, J.
Re: Struts 2 -Big Decimal auto conversion issue
Thanx Dave On Sun, May 6, 2012 at 4:56 PM, Dave Newton wrote: > Because it uses the default BigDecimal parsing. > > Options include: > > * Using an interceptor to strip leading/trailing spaces from form elements > before type conversion > * Using a custom type converter that does basically the same thing > * Etc. > > Dave > > On Sun, May 6, 2012 at 9:53 AM, George Eapen >wrote: > > > Dear All, > > > > Big Decimal auto conversion fails when an empty string is > received.Excerpt > > of the stack given below. > > > > /-- Encapsulated exception \ > > java.lang.NoSuchMethodException: > > com.path.ConvTest.setId([Ljava.lang.String;) > > at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1206) > > at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1454) > > > > When an empty string is received from the client it searches for a method > > with argument String instead of Big Decimal.But works perfectly fine if > the > > value is not empty.If Big Decimal data type is changed to Integer then > > there is no issue even if the value is empty string.Could you please let > me > > know why this happens or am i missing something.Thank you > > > > -- > > Regards, > > George Eapen > > > -- Regards, George Eapen The biggest risk is not taking any risk…In a world that is changing really quickly, the only strategy that is guaranteed to fail is not taking risks
Re: Struts 2 -Big Decimal auto conversion issue
Because it uses the default BigDecimal parsing. Options include: * Using an interceptor to strip leading/trailing spaces from form elements before type conversion * Using a custom type converter that does basically the same thing * Etc. Dave On Sun, May 6, 2012 at 9:53 AM, George Eapen wrote: > Dear All, > > Big Decimal auto conversion fails when an empty string is received.Excerpt > of the stack given below. > > /-- Encapsulated exception \ > java.lang.NoSuchMethodException: > com.path.ConvTest.setId([Ljava.lang.String;) > at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1206) > at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1454) > > When an empty string is received from the client it searches for a method > with argument String instead of Big Decimal.But works perfectly fine if the > value is not empty.If Big Decimal data type is changed to Integer then > there is no issue even if the value is empty string.Could you please let me > know why this happens or am i missing something.Thank you > > -- > Regards, > George Eapen >
Struts 2 -Big Decimal auto conversion issue
Dear All, Big Decimal auto conversion fails when an empty string is received.Excerpt of the stack given below. /-- Encapsulated exception \ java.lang.NoSuchMethodException: com.path.ConvTest.setId([Ljava.lang.String;) at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1206) at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1454) When an empty string is received from the client it searches for a method with argument String instead of Big Decimal.But works perfectly fine if the value is not empty.If Big Decimal data type is changed to Integer then there is no issue even if the value is empty string.Could you please let me know why this happens or am i missing something.Thank you -- Regards, George Eapen
RE: BigDecimal type conversion
Excellent! Thank you, Beez P.S. No response on the "bug" comment. Out of curiosity, what is the reason for overriding such trimming as seen by the parent class? Any idea? -Original Message- From: Dave Newton [mailto:davelnew...@gmail.com] Sent: Monday, December 19, 2011 3:25 PM To: Struts Users Mailing List Subject: Re: BigDecimal type conversion Either a type convertor, or an interceptor that trims everything. d. On Dec 19, 2011 3:23 PM, "Biesbrock, Kevin" wrote: > Our application is rolling with Struts 2.2.1. > > One action class implements ModelDriven and in the model we have a > Map; where we rolled a custom type > converter for BusinessObjectA and BusinessObjectB has a BigDecimal. > This model has been in production for well over 4 months with no > issue; that is, until someone recently added a space to the end of the > related input field, e.g., "54 " (quotes added for emphasis). > > This causes > com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter to fail here: > > 402 if (toType == BigDecimal.class) { > 403 return new BigDecimal((String) value); > > ...seemingly because it doesn't trim prior to creating a new BigDecimal. > > > 1. I feel like 403 should be calling bigDecValue(value, true) like > the parent in > com.opensymphony.xwork2.conversion.impl.DefaultTypeConverter.convertVa > lue() > > 139 if (toType == BigDecimal.class) > 140 result = bigDecValue(value); > > If #1 sounds like a candidate for a bug report, I would be happy to > report it if provided the appropriate url to post to. > > > 2. Our temporary solution will be to roll our own BigDecimal type > converter so we can .trim() the string passed into the > constructor(String) > > Does #2 sound like the best solution? Do you have a more efficient or > less "custom" approach? > > Thank you for your time, > Kevin Biesbrock > > - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: BigDecimal type conversion
Either a type convertor, or an interceptor that trims everything. d. On Dec 19, 2011 3:23 PM, "Biesbrock, Kevin" wrote: > Our application is rolling with Struts 2.2.1. > > One action class implements ModelDriven and in the model we have a > Map; where we rolled a custom type > converter for BusinessObjectA and BusinessObjectB has a BigDecimal. This > model has been in production for well over 4 months with no issue; that is, > until someone recently added a space to the end of the related input field, > e.g., "54 " (quotes added for emphasis). > > This causes com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter to > fail here: > > 402 if (toType == BigDecimal.class) { > 403 return new BigDecimal((String) value); > > ...seemingly because it doesn't trim prior to creating a new BigDecimal. > > > 1. I feel like 403 should be calling bigDecValue(value, true) like > the parent in > com.opensymphony.xwork2.conversion.impl.DefaultTypeConverter.convertValue() > > 139 if (toType == BigDecimal.class) > 140 result = bigDecValue(value); > > If #1 sounds like a candidate for a bug report, I would be happy to report > it if provided the appropriate url to post to. > > > 2. Our temporary solution will be to roll our own BigDecimal type > converter so we can .trim() the string passed into the constructor(String) > > Does #2 sound like the best solution? Do you have a more efficient or less > "custom" approach? > > Thank you for your time, > Kevin Biesbrock > >
BigDecimal type conversion
Our application is rolling with Struts 2.2.1. One action class implements ModelDriven and in the model we have a Map; where we rolled a custom type converter for BusinessObjectA and BusinessObjectB has a BigDecimal. This model has been in production for well over 4 months with no issue; that is, until someone recently added a space to the end of the related input field, e.g., "54 " (quotes added for emphasis). This causes com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter to fail here: 402 if (toType == BigDecimal.class) { 403 return new BigDecimal((String) value); ...seemingly because it doesn't trim prior to creating a new BigDecimal. 1. I feel like 403 should be calling bigDecValue(value, true) like the parent in com.opensymphony.xwork2.conversion.impl.DefaultTypeConverter.convertValue() 139 if (toType == BigDecimal.class) 140 result = bigDecValue(value); If #1 sounds like a candidate for a bug report, I would be happy to report it if provided the appropriate url to post to. 2. Our temporary solution will be to roll our own BigDecimal type converter so we can .trim() the string passed into the constructor(String) Does #2 sound like the best solution? Do you have a more efficient or less "custom" approach? Thank you for your time, Kevin Biesbrock
Re: struts2 string to map conversion
Parameters will returns String[] but not string check out that might be causing the problem. -- View this message in context: http://struts.1045723.n5.nabble.com/struts2-string-to-map-conversion-tp5052114p5060791.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: struts2 string to map conversion
What is your client side code (JSP)? In OGNL expression, a value assignment is something like: "aMap[aKey] = aValue" So, you need create HTML code like: On the server side, the OGNL expression will be converted into Java method invoking like: yourAction.getAMap().put("aKey", "aValue") Unfortunately, the Java generic system don't know the element data type of your Map, so, the data type for [aKey] and [aValue] may be a problem. I suggest you just declare the map as Map, and do the conversion by yourself. All I talked above are not tested, just suggestion. You need do the test and check if it is correct. 2011/12/6 cwalet : > any body knows how to use Struts2 TypeConversion(in xwork libs) to > convert a parameter string to a hashmap object? > I tried this: > > @TypeConversion(key = "phone", rule = ConversionRule.MAP, converter = > "java.lang.String") > public void setHmss(HashMap hmso) { > this.hmso = hmso; > } > > but no convert had it done.how?any suggestion? > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: struts2 string to map conversion
Have you read through this - http://struts.apache.org/2.x/docs/ognl-basics.html The type conversion is generally called automagically. -W On Tue, Dec 6, 2011 at 8:46 AM, cwalet wrote: > any body knows how to use Struts2 TypeConversion(in xwork libs) to > convert a parameter string to a hashmap object? > I tried this: > > @TypeConversion(key = "phone", rule = ConversionRule.MAP, converter = > "java.lang.String") > public void setHmss(HashMap hmso) { > this.hmso = hmso; > } > > but no convert had it done.how?any suggestion? > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > -- Wes Wannemacher Head Engineer, WanTii, Inc. Need Training? Struts, Spring, Maven, Tomcat... Ask me for a quote! - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
struts2 string to map conversion
any body knows how to use Struts2 TypeConversion(in xwork libs) to convert a parameter string to a hashmap object? I tried this: @TypeConversion(key = "phone", rule = ConversionRule.MAP, converter = "java.lang.String") public void setHmss(HashMap hmso) { this.hmso = hmso; } but no convert had it done.how?any suggestion? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: [S2] Displaying user entered values after failed type conversion while using getText()?
I have 2 suggestion: (A)Declare the input data field in your action as a String, instead of date or integer. So, the String field can hold anything input from client side. But this will be inconvenience to use, because you have to convert the string value to the date or integer value by yourself, before you can use it. Another solution is: (B)Declare 2 fields in your action. One as date or integer, to hold the type converted valid value. Another as String, to hold the original input text. On the input page side, you also need 2 form elements. One is , which will send data to the [real value] field, and another is , which will send data to the [original input text] field. User can only see the , and input data in it. you can create some JS code, to copy the content to the element, before the form be posted. When the type conversion fails, and the input page displayed again, the element will contains the original input text, and the element will contains empty text. You can create some JS code, to copy the element content to the element, after the page loaded. Or, you can simply set the value of the element from the [original input text] field of Action. Hope this helps. 2011/11/17 Burton Rhodes : > I am having an issue with displaying the original value entered on a > form after failed type conversion. This "bug" is caused by my use of > getText() in the form value fields. I'm curious how one solves this > issue for making sure the field is formatted correctly upon display, > but also making sure the users see the orignal malformed entry after > failed type conversion. I have a few examples below. The last one > displays works the way it should. The top two only present an empty > field upon failed type conversion. > > [code snippets] > > > value="%{getText('format.dateShort',{xaction.closedDate != null ? > xaction.closedDate :''})}" /> > > > value="%{getText('format.money',{xaction.listPrice != null ? > xaction.listPrice :''})}"/> > > > > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
[S2] Displaying user entered values after failed type conversion while using getText()?
I am having an issue with displaying the original value entered on a form after failed type conversion. This "bug" is caused by my use of getText() in the form value fields. I'm curious how one solves this issue for making sure the field is formatted correctly upon display, but also making sure the users see the orignal malformed entry after failed type conversion. I have a few examples below. The last one displays works the way it should. The top two only present an empty field upon failed type conversion. [code snippets] - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: slow request/response may be because of validation/conversion
I think conversion and validation should not be turned off. The [conversion] convert http parameters (which is String) to the real data type so your action can accept. The [validation] check the parameters if they a valid. And also, normally, conversion and validation should not take too much time. The log you showed to us start at 2011-10-10 10:55:42,187 and finished at 2011-10-10 10:55:42,393 So, it only cost 200 ms. I think you need printout more debug info, and find out where is the real bottle neck. And, as Carl said, the setting of [struts.devMode] can make Struts2 slow. [it has a significant impact on performance, since the entire configuration will be reloaded on every request] Try turn it off and see what happens. This page may help: http://struts.apache.org/2.x/docs/devmode.html - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: slow request/response may be because of validation/conversion
It sounds to me like you do not have your logging configured to filter out the stuff from com.opensymphony.xwork2.conversion. It also might depend on what server you are using. I recall having trouble with GlassFish and struts2 in regards to this logging in the past. At the moment I am using Tomcat 6 for a project and simply modifying log4j works great. Another option could be to get rid of if you have it in your struts.xml. Not sure if this causes extra logging - check out the documentation to be sure. A few ideas anyway. On Mon, Oct 10, 2011 at 4:28 PM, Maurizio Cucchiara wrote: > You could try to configure your custom interceptor stack starting from > basic stack [1] > [1] > http://struts.apache.org/2.x/docs/interceptors.html#Interceptors-TheDefaultConfiguration > Maurizio Cucchiara > > > > On 10 October 2011 16:09, Amir Wasim wrote: > > Hi, > > > > > > > > > > > > I am using struts2 for a project. It works flawlessly but for some resons > > its slow on actions. Below is the Debug log and I have noticed that there > > are many messages which are related to conversion and validation. Can > > someone tell me how I am able to stop them so that I is a little bit > fast. > > Currently without debug the request response time is almost 2-3 seconds > on a > > local machine and with debugging enabled its 7-8 secs. > > > > > > > > Regards, > > > > Amir > > > > > > PS: Bellow are some of the chunks from just one request/response. Most of > > them are repeated multiple times for each attribute. The one with > > template/xhtml/div.ftl is repeated for each request. > > > > - > > > > > > 2011-10-10 10:55:42,187 DEBUG http-bio-8080-exec-6 > > org.springframework.beans.factory.support.DefaultListableBeanFactory - > Not > > autowiring property 'genderList' of bean > > 'com.cerner.pacs.action.PatientAction' by name: no matching bean found > > > > 2011-10-10 10:55:42,189 DEBUG http-bio-8080-exec-6 > > com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil - cannot > find > > method [prepareList] in action [com.pac.action.PatientAction@1346812] > > > > > > 2011-10-10 10:55:42,217 DEBUG http-bio-8080-exec-6 > > com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler - > Entering > > nullPropertyValue [target=[com.pac.action.PatientAction@1346812, > > com.opensymphony.xwork2.DefaultTextProvider@30b601], property=struts] > > > > > > 2011-10-10 10:55:42,372 DEBUG http-bio-8080-exec-6 > > org.springframework.beans.factory.support.DefaultListableBeanFactory - > > Ignoring constructor [public > > org.apache.struts2.dispatcher.ServletDispatcherResult(java.lang.String)] > of > > bean 'org.apache.struts2.dispatcher.ServletDispatcherResult': > > org.springframework.beans.factory.UnsatisfiedDependencyException: Error > > creating bean with name > > 'org.apache.struts2.dispatcher.ServletDispatcherResult': Unsatisfied > > dependency expressed through constructor argument with index 0 of type > > [java.lang.String]: : No matching bean of type [java.lang.String] found > for > > dependency: expected at least 1 bean which qualifies as autowire > candidate > > for this dependency. Dependency annotations: {}; nested exception is > > org.springframework.beans.factory.NoSuchBeanDefinitionException: No > matching > > bean of type [java.lang.String] found for dependency: expected at least 1 > > bean which qualifies as autowire candidate for this dependency. > Dependency > > annotations: {} > > > > 2011-10-10 10:55:42,378 DEBUG http-bio-8080-exec-6 > > com.opensymphony.xwork2.conversion.impl.XWorkConverter - Property: null > > > > 2011-10-10 10:55:42,378 DEBUG http-bio-8080-exec-6 > > com.opensymphony.xwork2.conversion.impl.XWorkConverter - Class: > > com.opensymphony.xwork2.util.CompoundRoot > > > > 2011-10-10 10:55:42,378 DEBUG http-bio-8080-exec-6 > > com.opensymphony.xwork2.conversion.impl.XWorkConverter - field-level type > > converter for property [null] = none found > > > > 2011-10-10 10:55:42,379 DEBUG http-bio-8080-exec-6 > > com.opensymphony.xwork2.conversion.impl.XWorkConverter - global-level > type > > converter for property [null] = none found > > > > 2011-10-10 10:55:42,379 DEBUG http-bio-8080-exec-6 > > com.opensymphony.xwork2.conversion.impl.XWorkConverter - falling back to > > default type converter > > [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@13cba41] > > > > > > [com.
Re: slow request/response may be because of validation/conversion
It looks like you have enabled DEBUG on everything - Spring, Struts2, Freemarker, etc. Please try to reduce the scope and maybe look into your Spring configuration or so... Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ Warszawa JUG conference - Confitura http://confitura.pl/ 2011/10/10 Amir Wasim : > Hi, > > > > > > I am using struts2 for a project. It works flawlessly but for some resons > its slow on actions. Below is the Debug log and I have noticed that there > are many messages which are related to conversion and validation. Can > someone tell me how I am able to stop them so that I is a little bit fast. > Currently without debug the request response time is almost 2-3 seconds on a > local machine and with debugging enabled its 7-8 secs. > > > > Regards, > > Amir > > > PS: Bellow are some of the chunks from just one request/response. Most of > them are repeated multiple times for each attribute. The one with > template/xhtml/div.ftl is repeated for each request. > > - > > > 2011-10-10 10:55:42,187 DEBUG http-bio-8080-exec-6 > org.springframework.beans.factory.support.DefaultListableBeanFactory - Not > autowiring property 'genderList' of bean > 'com.cerner.pacs.action.PatientAction' by name: no matching bean found > > 2011-10-10 10:55:42,189 DEBUG http-bio-8080-exec-6 > com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil - cannot find > method [prepareList] in action [com.pac.action.PatientAction@1346812] > > > 2011-10-10 10:55:42,217 DEBUG http-bio-8080-exec-6 > com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler - Entering > nullPropertyValue [target=[com.pac.action.PatientAction@1346812, > com.opensymphony.xwork2.DefaultTextProvider@30b601], property=struts] > > > 2011-10-10 10:55:42,372 DEBUG http-bio-8080-exec-6 > org.springframework.beans.factory.support.DefaultListableBeanFactory - > Ignoring constructor [public > org.apache.struts2.dispatcher.ServletDispatcherResult(java.lang.String)] of > bean 'org.apache.struts2.dispatcher.ServletDispatcherResult': > org.springframework.beans.factory.UnsatisfiedDependencyException: Error > creating bean with name > 'org.apache.struts2.dispatcher.ServletDispatcherResult': Unsatisfied > dependency expressed through constructor argument with index 0 of type > [java.lang.String]: : No matching bean of type [java.lang.String] found for > dependency: expected at least 1 bean which qualifies as autowire candidate > for this dependency. Dependency annotations: {}; nested exception is > org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching > bean of type [java.lang.String] found for dependency: expected at least 1 > bean which qualifies as autowire candidate for this dependency. Dependency > annotations: {} > > 2011-10-10 10:55:42,378 DEBUG http-bio-8080-exec-6 > com.opensymphony.xwork2.conversion.impl.XWorkConverter - Property: null > > 2011-10-10 10:55:42,378 DEBUG http-bio-8080-exec-6 > com.opensymphony.xwork2.conversion.impl.XWorkConverter - Class: > com.opensymphony.xwork2.util.CompoundRoot > > 2011-10-10 10:55:42,378 DEBUG http-bio-8080-exec-6 > com.opensymphony.xwork2.conversion.impl.XWorkConverter - field-level type > converter for property [null] = none found > > 2011-10-10 10:55:42,379 DEBUG http-bio-8080-exec-6 > com.opensymphony.xwork2.conversion.impl.XWorkConverter - global-level type > converter for property [null] = none found > > 2011-10-10 10:55:42,379 DEBUG http-bio-8080-exec-6 > com.opensymphony.xwork2.conversion.impl.XWorkConverter - falling back to > default type converter > [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@13cba41] > > > [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@13cba41] > > 2011-10-10 10:55:42,385 DEBUG http-bio-8080-exec-6 > org.apache.struts2.components.UIBean - Rendering template > /template/xhtml/div > > 2011-10-10 10:55:42,388 DEBUG http-bio-8080-exec-6 freemarker.cache - > template/xhtml/div.ftl[de_DE,UTF-8,parsed] no source found. > > 2011-10-10 10:55:42,391 DEBUG http-bio-8080-exec-6 freemarker.cache - > template/simple/div.ftl[de_DE,UTF-8,parsed] using cached since > jar:file:/C:/Users/aw022236/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/pacs/WEB-INF/lib/struts2-core-2.2.3.1.jar!/template/simple/div.ftl > didn't change. > > 2011-10-10 10:55:42,391 DEBUG http-bio-8080-exec-6 > org.apache.struts2.components.template.FreemarkerTemplateEngine - Rendering > template /template/simple/div.ftl > > 2011-10-10 10:55:42,392 DEBUG http-bio-8080-exec-6 freemarker.beans - Key > 'name' was not found on instance of java.util.L
Re: slow request/response may be because of validation/conversion
You could try to configure your custom interceptor stack starting from basic stack [1] [1] http://struts.apache.org/2.x/docs/interceptors.html#Interceptors-TheDefaultConfiguration Maurizio Cucchiara On 10 October 2011 16:09, Amir Wasim wrote: > Hi, > > > > > > I am using struts2 for a project. It works flawlessly but for some resons > its slow on actions. Below is the Debug log and I have noticed that there > are many messages which are related to conversion and validation. Can > someone tell me how I am able to stop them so that I is a little bit fast. > Currently without debug the request response time is almost 2-3 seconds on a > local machine and with debugging enabled its 7-8 secs. > > > > Regards, > > Amir > > > PS: Bellow are some of the chunks from just one request/response. Most of > them are repeated multiple times for each attribute. The one with > template/xhtml/div.ftl is repeated for each request. > > - > > > 2011-10-10 10:55:42,187 DEBUG http-bio-8080-exec-6 > org.springframework.beans.factory.support.DefaultListableBeanFactory - Not > autowiring property 'genderList' of bean > 'com.cerner.pacs.action.PatientAction' by name: no matching bean found > > 2011-10-10 10:55:42,189 DEBUG http-bio-8080-exec-6 > com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil - cannot find > method [prepareList] in action [com.pac.action.PatientAction@1346812] > > > 2011-10-10 10:55:42,217 DEBUG http-bio-8080-exec-6 > com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler - Entering > nullPropertyValue [target=[com.pac.action.PatientAction@1346812, > com.opensymphony.xwork2.DefaultTextProvider@30b601], property=struts] > > > 2011-10-10 10:55:42,372 DEBUG http-bio-8080-exec-6 > org.springframework.beans.factory.support.DefaultListableBeanFactory - > Ignoring constructor [public > org.apache.struts2.dispatcher.ServletDispatcherResult(java.lang.String)] of > bean 'org.apache.struts2.dispatcher.ServletDispatcherResult': > org.springframework.beans.factory.UnsatisfiedDependencyException: Error > creating bean with name > 'org.apache.struts2.dispatcher.ServletDispatcherResult': Unsatisfied > dependency expressed through constructor argument with index 0 of type > [java.lang.String]: : No matching bean of type [java.lang.String] found for > dependency: expected at least 1 bean which qualifies as autowire candidate > for this dependency. Dependency annotations: {}; nested exception is > org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching > bean of type [java.lang.String] found for dependency: expected at least 1 > bean which qualifies as autowire candidate for this dependency. Dependency > annotations: {} > > 2011-10-10 10:55:42,378 DEBUG http-bio-8080-exec-6 > com.opensymphony.xwork2.conversion.impl.XWorkConverter - Property: null > > 2011-10-10 10:55:42,378 DEBUG http-bio-8080-exec-6 > com.opensymphony.xwork2.conversion.impl.XWorkConverter - Class: > com.opensymphony.xwork2.util.CompoundRoot > > 2011-10-10 10:55:42,378 DEBUG http-bio-8080-exec-6 > com.opensymphony.xwork2.conversion.impl.XWorkConverter - field-level type > converter for property [null] = none found > > 2011-10-10 10:55:42,379 DEBUG http-bio-8080-exec-6 > com.opensymphony.xwork2.conversion.impl.XWorkConverter - global-level type > converter for property [null] = none found > > 2011-10-10 10:55:42,379 DEBUG http-bio-8080-exec-6 > com.opensymphony.xwork2.conversion.impl.XWorkConverter - falling back to > default type converter > [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@13cba41] > > > [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@13cba41] > > 2011-10-10 10:55:42,385 DEBUG http-bio-8080-exec-6 > org.apache.struts2.components.UIBean - Rendering template > /template/xhtml/div > > 2011-10-10 10:55:42,388 DEBUG http-bio-8080-exec-6 freemarker.cache - > template/xhtml/div.ftl[de_DE,UTF-8,parsed] no source found. > > 2011-10-10 10:55:42,391 DEBUG http-bio-8080-exec-6 freemarker.cache - > template/simple/div.ftl[de_DE,UTF-8,parsed] using cached since > jar:file:/C:/Users/aw022236/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/pacs/WEB-INF/lib/struts2-core-2.2.3.1.jar!/template/simple/div.ftl > didn't change. > > 2011-10-10 10:55:42,391 DEBUG http-bio-8080-exec-6 > org.apache.struts2.components.template.FreemarkerTemplateEngine - Rendering > template /template/simple/div.ftl > > 2011-10-10 10:55:42,392 DEBUG http-bio-8080-exec-6 freemarker.beans - Key > 'name' was not found on instance of java.util.LinkedHashMap. Introspection > information for the class i
slow request/response may be because of validation/conversion
Hi, I am using struts2 for a project. It works flawlessly but for some resons its slow on actions. Below is the Debug log and I have noticed that there are many messages which are related to conversion and validation. Can someone tell me how I am able to stop them so that I is a little bit fast. Currently without debug the request response time is almost 2-3 seconds on a local machine and with debugging enabled its 7-8 secs. Regards, Amir PS: Bellow are some of the chunks from just one request/response. Most of them are repeated multiple times for each attribute. The one with template/xhtml/div.ftl is repeated for each request. - 2011-10-10 10:55:42,187 DEBUG http-bio-8080-exec-6 org.springframework.beans.factory.support.DefaultListableBeanFactory - Not autowiring property 'genderList' of bean 'com.cerner.pacs.action.PatientAction' by name: no matching bean found 2011-10-10 10:55:42,189 DEBUG http-bio-8080-exec-6 com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil - cannot find method [prepareList] in action [com.pac.action.PatientAction@1346812] 2011-10-10 10:55:42,217 DEBUG http-bio-8080-exec-6 com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler - Entering nullPropertyValue [target=[com.pac.action.PatientAction@1346812, com.opensymphony.xwork2.DefaultTextProvider@30b601], property=struts] 2011-10-10 10:55:42,372 DEBUG http-bio-8080-exec-6 org.springframework.beans.factory.support.DefaultListableBeanFactory - Ignoring constructor [public org.apache.struts2.dispatcher.ServletDispatcherResult(java.lang.String)] of bean 'org.apache.struts2.dispatcher.ServletDispatcherResult': org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.apache.struts2.dispatcher.ServletDispatcherResult': Unsatisfied dependency expressed through constructor argument with index 0 of type [java.lang.String]: : No matching bean of type [java.lang.String] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [java.lang.String] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {} 2011-10-10 10:55:42,378 DEBUG http-bio-8080-exec-6 com.opensymphony.xwork2.conversion.impl.XWorkConverter - Property: null 2011-10-10 10:55:42,378 DEBUG http-bio-8080-exec-6 com.opensymphony.xwork2.conversion.impl.XWorkConverter - Class: com.opensymphony.xwork2.util.CompoundRoot 2011-10-10 10:55:42,378 DEBUG http-bio-8080-exec-6 com.opensymphony.xwork2.conversion.impl.XWorkConverter - field-level type converter for property [null] = none found 2011-10-10 10:55:42,379 DEBUG http-bio-8080-exec-6 com.opensymphony.xwork2.conversion.impl.XWorkConverter - global-level type converter for property [null] = none found 2011-10-10 10:55:42,379 DEBUG http-bio-8080-exec-6 com.opensymphony.xwork2.conversion.impl.XWorkConverter - falling back to default type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@13cba41] [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@13cba41] 2011-10-10 10:55:42,385 DEBUG http-bio-8080-exec-6 org.apache.struts2.components.UIBean - Rendering template /template/xhtml/div 2011-10-10 10:55:42,388 DEBUG http-bio-8080-exec-6 freemarker.cache - template/xhtml/div.ftl[de_DE,UTF-8,parsed] no source found. 2011-10-10 10:55:42,391 DEBUG http-bio-8080-exec-6 freemarker.cache - template/simple/div.ftl[de_DE,UTF-8,parsed] using cached since jar:file:/C:/Users/aw022236/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/pacs/WEB-INF/lib/struts2-core-2.2.3.1.jar!/template/simple/div.ftl didn't change. 2011-10-10 10:55:42,391 DEBUG http-bio-8080-exec-6 org.apache.struts2.components.template.FreemarkerTemplateEngine - Rendering template /template/simple/div.ftl 2011-10-10 10:55:42,392 DEBUG http-bio-8080-exec-6 freemarker.beans - Key 'name' was not found on instance of java.util.LinkedHashMap. Introspection information for the class is: {getClass=public final native java.lang.Class java.lang.Object.getClass(), clone=public java.lang.Object java.util.HashMap.clone(), put=public java.lang.Object java.util.HashMap.put(java.lang.Object,java.lang.Object), get=public java.lang.Object java.util.LinkedHashMap.get(java.lang.Object), remove=public java.lang.Object java.util.HashMap.remove(java.lang.Object), equals=public boolean java.util.AbstractMap.equals(java.lang.Object), entrySet=public java.util.Set java.util.HashMap.entrySet(), hashCode=public int java.util.AbstractMap.hashCode(), class=java.beans.PropertyDescriptor@37d1e4a6, keySet=public java.util.Set java.util.HashMap.keySet(), size=public int java.util.HashMap.size(), clear=public void
Re: Type conversion of List - how does one do it?
On Tue, 2011-05-17 at 14:42 -0700, Jeffrey Black wrote: > Hey there Miguel. > > Have a look here: > > http://struts.apache.org/2.0.14/docs/type-conversion.html#TypeConversion-GenericsandErasure Thanks Jb. In my case a possible solution is to remove the generic reference to the list (ie, changing List to List). This isn't usually necessary because Spring automatically injects the implementations in non-collection objects (ie, a private SomeInterface property is automatically injected with whichever bean we defined for SomeInterface in Spring), but doesn't work with collections (or I haven't figured out how to configure that in Spring). Given that an implementation-agnostic solution is preferable, the advice on the page "instantiate the target implementation first (eg. in a prepare method) or substitute in an implementation." is not, in my opinion, preferable. Miguel
Re: Type conversion of List - how does one do it?
Hey there Miguel. Have a look here: http://struts.apache.org/2.0.14/docs/type-conversion.html#TypeConversion-GenericsandErasure Best, jb From: Miguel To: user@struts.apache.org Sent: Tuesday, May 17, 2011 5:19 AM Subject: Type conversion of List - how does one do it? I've always struggled with type conversion of lists and I'd appreciate a more experienced brain to help me out. Consider the following multiple select box: As per the documentation, "name your element people.name and the framework will understand that it should create a new Person object for each selected item and set its name accordingly." This works correctly, without even needing an MyAction-conversion.properties file if my action has: private List users; However, because I usually work with interfaces (and Spring-inject my dependencies), to have my action implementation-agnostic I want to have. private List users; where User is an interface and UserImpl implements User. However, as soon as the List (and getter/setters) are changed to use User, the type conversion no longer works, yielding: 2011-05-17 11:17:13,554 WARN [CommonsLogger.java:60] : Error setting expression 'users.id' with value '[Ljava.lang.String;@13d344e7' ognl.OgnlException: Error converting given String values for Collection. [org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.itclinical.iwrs.model.User': Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)] This happens even if I have a UserEditAction-conversion.properties with: #KeyProperty_users=id #Element_users=iw.persist.model.UserImpl #CreateIfNull_users=true So, how can one use the automatic type conversion when your list is defined for an interface? Thank you in advance, Miguel Almeida
Type conversion of List - how does one do it?
I've always struggled with type conversion of lists and I'd appreciate a more experienced brain to help me out. Consider the following multiple select box: As per the documentation, "name your element people.name and the framework will understand that it should create a new Person object for each selected item and set its name accordingly." This works correctly, without even needing an MyAction-conversion.properties file if my action has: private List users; However, because I usually work with interfaces (and Spring-inject my dependencies), to have my action implementation-agnostic I want to have. private List users; where User is an interface and UserImpl implements User. However, as soon as the List (and getter/setters) are changed to use User, the type conversion no longer works, yielding: 2011-05-17 11:17:13,554 WARN [CommonsLogger.java:60] : Error setting expression 'users.id' with value '[Ljava.lang.String;@13d344e7' ognl.OgnlException: Error converting given String values for Collection. [org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.itclinical.iwrs.model.User': Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)] This happens even if I have a UserEditAction-conversion.properties with: #KeyProperty_users=id #Element_users=iw.persist.model.UserImpl #CreateIfNull_users=true So, how can one use the automatic type conversion when your list is defined for an interface? Thank you in advance, Miguel Almeida
Re: Conversion problem
Good idea - I included it to the java files location. But eclipse automatically copies it to the classes folder (just doublechecked). However, mvn jetty:run does use the target/classes folder as classfolder, but the webapp folder is /src/main/webapp.(where WEB-INF resides). Probably the failure is b/c the target/classes are not in the WEB-INF folder. On Mon, Apr 18, 2011 at 6:32 PM, Chris Pratt wrote: > Did you put it in the same location as the .class file, or the same location > as the .java file? As far as I know if it's in the same location as the > .class files (i.e. /WEB-INF/classes/com.package...) it should work, but > normally the .java files don't get included in the .war file. > (*Chris*) > > On Mon, Apr 18, 2011 at 9:01 AM, Christian Grobmeier > wrote: > >> Oh wow, is it true? >> >> It seem ProjectsAction-conversion.properties and ProjectsAction must >> be on the same location on classpath, but it must NOT reside in the >> classfolder itself. >> >> When I added it on the same folder just in src/main/resources its used >> from struts. >> >> Why not from the same location as the class is? >> >> Cheers >> Christian >> >> On Mon, Apr 18, 2011 at 5:40 PM, Christian Grobmeier >> wrote: >> > Hi, >> > >> >> It appears to be trying to set an Array of Strings to your >> setDeadlineTime >> >> method, is it typed to take an Array of Strings? >> > >> > no arrays anywhere. >> > >> > But I found out I get more debug output with: >> > log4j.logger.com.opensymphony.xwork2=DEBUG >> > >> > Now I could see that my conversion.properties file is not loaded. None >> > of my converters is used, it works for the other fields with the >> > default converter. >> > >> > A shortened logfile: >> > >> > DEBUG Property: deadlineTime >> > DEBUG Class: ...Project >> > DEBUG field-level type converter for property [deadlineTime] = none found >> > DEBUG Property: project.deadlineTime >> > DEBUG Class: ProjectsAction >> > DEBUG global-level type converter for property [deadlineTime] = noe found >> > DEBUG falling back to default type converter XWorkBasicConverter >> > >> > my time textfield throws an error, it cannot be handled by the default >> > converter. >> > >> > Now my assumption is i have done something wrong with the conversion >> properties. >> > >> > My entity is named "Project". The props is named: >> Project-conversion.properties >> > Its located in the same package as "Project". >> > >> > I have tried it with my Action "ProjectsAction" too. The file is >> > ProjectsAction-conversion.properties >> > Same location as ProjectsAction. >> > >> > Content is as follows: >> > deadlineTime = de.converter.DateConverter >> > >> > or in the actions case: >> > project.deadlineTime = de.converter.DateConverter >> > >> > Any ideas why this is not drawn by Struts? >> > >> > Thanks! >> > Christian >> > >> > >> >> (*Chris*) >> >> >> >> On Mon, Apr 18, 2011 at 7:59 AM, Christian Grobmeier < >> grobme...@gmail.com>wrote: >> >> >> >>> Hi all, >> >>> >> >>> i have a form with only 6 values. >> >>> 4 Dates, 1 int, one string. >> >>> >> >>> I created 2 different conversion classes for the 4 dates. One is for >> >>> creating a good date from a string like 13:30, one is for the actual >> >>> date. I don't know why, but the ones for dates work and the one for >> >>> time does not work. >> >>> >> >>> Even when i use the same conversion class for all fields, the time >> >>> fields do not work. >> >>> >> >>> In my jsp they are named correct: >> >>> >> >>> project.deadlineTime >> >>> >> >>> In my Pojo it is: >> >>> >> >>> Project.setDeadlineTime(Date deadlineTime) >> >>> >> >>> In my >> >>> >> >>> MyAction-conversion.properties: >> >>> >> >>> project.deadlineTime = de.blub.converter.TimeConverter >> >>> >> >>> As the property file has the working conversions defined, I
Re: Conversion problem
Did you put it in the same location as the .class file, or the same location as the .java file? As far as I know if it's in the same location as the .class files (i.e. /WEB-INF/classes/com.package...) it should work, but normally the .java files don't get included in the .war file. (*Chris*) On Mon, Apr 18, 2011 at 9:01 AM, Christian Grobmeier wrote: > Oh wow, is it true? > > It seem ProjectsAction-conversion.properties and ProjectsAction must > be on the same location on classpath, but it must NOT reside in the > classfolder itself. > > When I added it on the same folder just in src/main/resources its used > from struts. > > Why not from the same location as the class is? > > Cheers > Christian > > On Mon, Apr 18, 2011 at 5:40 PM, Christian Grobmeier > wrote: > > Hi, > > > >> It appears to be trying to set an Array of Strings to your > setDeadlineTime > >> method, is it typed to take an Array of Strings? > > > > no arrays anywhere. > > > > But I found out I get more debug output with: > > log4j.logger.com.opensymphony.xwork2=DEBUG > > > > Now I could see that my conversion.properties file is not loaded. None > > of my converters is used, it works for the other fields with the > > default converter. > > > > A shortened logfile: > > > > DEBUG Property: deadlineTime > > DEBUG Class: ...Project > > DEBUG field-level type converter for property [deadlineTime] = none found > > DEBUG Property: project.deadlineTime > > DEBUG Class: ProjectsAction > > DEBUG global-level type converter for property [deadlineTime] = noe found > > DEBUG falling back to default type converter XWorkBasicConverter > > > > my time textfield throws an error, it cannot be handled by the default > > converter. > > > > Now my assumption is i have done something wrong with the conversion > properties. > > > > My entity is named "Project". The props is named: > Project-conversion.properties > > Its located in the same package as "Project". > > > > I have tried it with my Action "ProjectsAction" too. The file is > > ProjectsAction-conversion.properties > > Same location as ProjectsAction. > > > > Content is as follows: > > deadlineTime = de.converter.DateConverter > > > > or in the actions case: > > project.deadlineTime = de.converter.DateConverter > > > > Any ideas why this is not drawn by Struts? > > > > Thanks! > > Christian > > > > > >> (*Chris*) > >> > >> On Mon, Apr 18, 2011 at 7:59 AM, Christian Grobmeier < > grobme...@gmail.com>wrote: > >> > >>> Hi all, > >>> > >>> i have a form with only 6 values. > >>> 4 Dates, 1 int, one string. > >>> > >>> I created 2 different conversion classes for the 4 dates. One is for > >>> creating a good date from a string like 13:30, one is for the actual > >>> date. I don't know why, but the ones for dates work and the one for > >>> time does not work. > >>> > >>> Even when i use the same conversion class for all fields, the time > >>> fields do not work. > >>> > >>> In my jsp they are named correct: > >>> > >>> project.deadlineTime > >>> > >>> In my Pojo it is: > >>> > >>> Project.setDeadlineTime(Date deadlineTime) > >>> > >>> In my > >>> > >>> MyAction-conversion.properties: > >>> > >>> project.deadlineTime = de.blub.converter.TimeConverter > >>> > >>> As the property file has the working conversions defined, I assume it > >>> is drawn correct. > >>> To avoid a problem in the converter, i have returned a new Date and > >>> once exchanged it with the working stuff. But nothing helped > >>> > >>> It always claims > >>> > >>> Error setting expression 'project.deadlineTime' with value > >>> '[Ljava.lang.String;@73ea7821' > >>> ognl.MethodFailedException: Method "setDeadlineTime" failed for object > >>> > >>> > >>> Then I tried to enable some logging output in the Converters. But they > >>> do not output anything (for none of the fields). All other of my > >>> classes can create output on the specific level. > >>> > >>> Even when I debug I cannot breakpoint and step into them. It is as if > >>> they would not exist. In all other classes it works > >>> > >>> My questions: > >>> - any ideas what I could look for and why the two fields are not > working? > >>> - why is there no logging possible? > >>> - and why can't I get into a breakpoint when debugging with eclipse > >>> and run-jetty-run plugin? > >>> > >>> Any help is appreciated :-( > >>> > >>> Thanks! > >>> Christian > >>> > >>> - > >>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > >>> For additional commands, e-mail: user-h...@struts.apache.org > >>> > >>> > >> > > > > > > > > -- > > http://www.grobmeier.de > > > > > > -- > http://www.grobmeier.de > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
Re: Conversion problem
Oh wow, is it true? It seem ProjectsAction-conversion.properties and ProjectsAction must be on the same location on classpath, but it must NOT reside in the classfolder itself. When I added it on the same folder just in src/main/resources its used from struts. Why not from the same location as the class is? Cheers Christian On Mon, Apr 18, 2011 at 5:40 PM, Christian Grobmeier wrote: > Hi, > >> It appears to be trying to set an Array of Strings to your setDeadlineTime >> method, is it typed to take an Array of Strings? > > no arrays anywhere. > > But I found out I get more debug output with: > log4j.logger.com.opensymphony.xwork2=DEBUG > > Now I could see that my conversion.properties file is not loaded. None > of my converters is used, it works for the other fields with the > default converter. > > A shortened logfile: > > DEBUG Property: deadlineTime > DEBUG Class: ...Project > DEBUG field-level type converter for property [deadlineTime] = none found > DEBUG Property: project.deadlineTime > DEBUG Class: ProjectsAction > DEBUG global-level type converter for property [deadlineTime] = noe found > DEBUG falling back to default type converter XWorkBasicConverter > > my time textfield throws an error, it cannot be handled by the default > converter. > > Now my assumption is i have done something wrong with the conversion > properties. > > My entity is named "Project". The props is named: > Project-conversion.properties > Its located in the same package as "Project". > > I have tried it with my Action "ProjectsAction" too. The file is > ProjectsAction-conversion.properties > Same location as ProjectsAction. > > Content is as follows: > deadlineTime = de.converter.DateConverter > > or in the actions case: > project.deadlineTime = de.converter.DateConverter > > Any ideas why this is not drawn by Struts? > > Thanks! > Christian > > >> (*Chris*) >> >> On Mon, Apr 18, 2011 at 7:59 AM, Christian Grobmeier >> wrote: >> >>> Hi all, >>> >>> i have a form with only 6 values. >>> 4 Dates, 1 int, one string. >>> >>> I created 2 different conversion classes for the 4 dates. One is for >>> creating a good date from a string like 13:30, one is for the actual >>> date. I don't know why, but the ones for dates work and the one for >>> time does not work. >>> >>> Even when i use the same conversion class for all fields, the time >>> fields do not work. >>> >>> In my jsp they are named correct: >>> >>> project.deadlineTime >>> >>> In my Pojo it is: >>> >>> Project.setDeadlineTime(Date deadlineTime) >>> >>> In my >>> >>> MyAction-conversion.properties: >>> >>> project.deadlineTime = de.blub.converter.TimeConverter >>> >>> As the property file has the working conversions defined, I assume it >>> is drawn correct. >>> To avoid a problem in the converter, i have returned a new Date and >>> once exchanged it with the working stuff. But nothing helped >>> >>> It always claims >>> >>> Error setting expression 'project.deadlineTime' with value >>> '[Ljava.lang.String;@73ea7821' >>> ognl.MethodFailedException: Method "setDeadlineTime" failed for object >>> >>> >>> Then I tried to enable some logging output in the Converters. But they >>> do not output anything (for none of the fields). All other of my >>> classes can create output on the specific level. >>> >>> Even when I debug I cannot breakpoint and step into them. It is as if >>> they would not exist. In all other classes it works >>> >>> My questions: >>> - any ideas what I could look for and why the two fields are not working? >>> - why is there no logging possible? >>> - and why can't I get into a breakpoint when debugging with eclipse >>> and run-jetty-run plugin? >>> >>> Any help is appreciated :-( >>> >>> Thanks! >>> Christian >>> >>> - >>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>> For additional commands, e-mail: user-h...@struts.apache.org >>> >>> >> > > > > -- > http://www.grobmeier.de > -- http://www.grobmeier.de - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Conversion problem
Hi, > It appears to be trying to set an Array of Strings to your setDeadlineTime > method, is it typed to take an Array of Strings? no arrays anywhere. But I found out I get more debug output with: log4j.logger.com.opensymphony.xwork2=DEBUG Now I could see that my conversion.properties file is not loaded. None of my converters is used, it works for the other fields with the default converter. A shortened logfile: DEBUG Property: deadlineTime DEBUG Class: ...Project DEBUG field-level type converter for property [deadlineTime] = none found DEBUG Property: project.deadlineTime DEBUG Class: ProjectsAction DEBUG global-level type converter for property [deadlineTime] = noe found DEBUG falling back to default type converter XWorkBasicConverter my time textfield throws an error, it cannot be handled by the default converter. Now my assumption is i have done something wrong with the conversion properties. My entity is named "Project". The props is named: Project-conversion.properties Its located in the same package as "Project". I have tried it with my Action "ProjectsAction" too. The file is ProjectsAction-conversion.properties Same location as ProjectsAction. Content is as follows: deadlineTime = de.converter.DateConverter or in the actions case: project.deadlineTime = de.converter.DateConverter Any ideas why this is not drawn by Struts? Thanks! Christian > (*Chris*) > > On Mon, Apr 18, 2011 at 7:59 AM, Christian Grobmeier > wrote: > >> Hi all, >> >> i have a form with only 6 values. >> 4 Dates, 1 int, one string. >> >> I created 2 different conversion classes for the 4 dates. One is for >> creating a good date from a string like 13:30, one is for the actual >> date. I don't know why, but the ones for dates work and the one for >> time does not work. >> >> Even when i use the same conversion class for all fields, the time >> fields do not work. >> >> In my jsp they are named correct: >> >> project.deadlineTime >> >> In my Pojo it is: >> >> Project.setDeadlineTime(Date deadlineTime) >> >> In my >> >> MyAction-conversion.properties: >> >> project.deadlineTime = de.blub.converter.TimeConverter >> >> As the property file has the working conversions defined, I assume it >> is drawn correct. >> To avoid a problem in the converter, i have returned a new Date and >> once exchanged it with the working stuff. But nothing helped >> >> It always claims >> >> Error setting expression 'project.deadlineTime' with value >> '[Ljava.lang.String;@73ea7821' >> ognl.MethodFailedException: Method "setDeadlineTime" failed for object >> >> >> Then I tried to enable some logging output in the Converters. But they >> do not output anything (for none of the fields). All other of my >> classes can create output on the specific level. >> >> Even when I debug I cannot breakpoint and step into them. It is as if >> they would not exist. In all other classes it works >> >> My questions: >> - any ideas what I could look for and why the two fields are not working? >> - why is there no logging possible? >> - and why can't I get into a breakpoint when debugging with eclipse >> and run-jetty-run plugin? >> >> Any help is appreciated :-( >> >> Thanks! >> Christian >> >> - >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> > -- http://www.grobmeier.de - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Conversion problem
It appears to be trying to set an Array of Strings to your setDeadlineTime method, is it typed to take an Array of Strings? (*Chris*) On Mon, Apr 18, 2011 at 7:59 AM, Christian Grobmeier wrote: > Hi all, > > i have a form with only 6 values. > 4 Dates, 1 int, one string. > > I created 2 different conversion classes for the 4 dates. One is for > creating a good date from a string like 13:30, one is for the actual > date. I don't know why, but the ones for dates work and the one for > time does not work. > > Even when i use the same conversion class for all fields, the time > fields do not work. > > In my jsp they are named correct: > > project.deadlineTime > > In my Pojo it is: > > Project.setDeadlineTime(Date deadlineTime) > > In my > > MyAction-conversion.properties: > > project.deadlineTime = de.blub.converter.TimeConverter > > As the property file has the working conversions defined, I assume it > is drawn correct. > To avoid a problem in the converter, i have returned a new Date and > once exchanged it with the working stuff. But nothing helped > > It always claims > > Error setting expression 'project.deadlineTime' with value > '[Ljava.lang.String;@73ea7821' > ognl.MethodFailedException: Method "setDeadlineTime" failed for object > > > Then I tried to enable some logging output in the Converters. But they > do not output anything (for none of the fields). All other of my > classes can create output on the specific level. > > Even when I debug I cannot breakpoint and step into them. It is as if > they would not exist. In all other classes it works > > My questions: > - any ideas what I could look for and why the two fields are not working? > - why is there no logging possible? > - and why can't I get into a breakpoint when debugging with eclipse > and run-jetty-run plugin? > > Any help is appreciated :-( > > Thanks! > Christian > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
Conversion problem
Hi all, i have a form with only 6 values. 4 Dates, 1 int, one string. I created 2 different conversion classes for the 4 dates. One is for creating a good date from a string like 13:30, one is for the actual date. I don't know why, but the ones for dates work and the one for time does not work. Even when i use the same conversion class for all fields, the time fields do not work. In my jsp they are named correct: project.deadlineTime In my Pojo it is: Project.setDeadlineTime(Date deadlineTime) In my MyAction-conversion.properties: project.deadlineTime = de.blub.converter.TimeConverter As the property file has the working conversions defined, I assume it is drawn correct. To avoid a problem in the converter, i have returned a new Date and once exchanged it with the working stuff. But nothing helped It always claims Error setting expression 'project.deadlineTime' with value '[Ljava.lang.String;@73ea7821' ognl.MethodFailedException: Method "setDeadlineTime" failed for object Then I tried to enable some logging output in the Converters. But they do not output anything (for none of the fields). All other of my classes can create output on the specific level. Even when I debug I cannot breakpoint and step into them. It is as if they would not exist. In all other classes it works My questions: - any ideas what I could look for and why the two fields are not working? - why is there no logging possible? - and why can't I get into a breakpoint when debugging with eclipse and run-jetty-run plugin? Any help is appreciated :-( Thanks! Christian - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Invocation of type conversion manually
I used interfaces to get this to work. So every Security Assert defines also an interface that should be implemented by the Actions. It took a while, but it's working now. Thanks for the advices. 2010/12/14 Chris Pratt > If you just need access to the parameters from the action, you can use: > > String resource = > > invocation.getProxy().getConfig().getParams().get("AuthoritationInterceptor.resource"); > > I've used this several times to get parameters from the configuration, but > I > usually put the parameters on the action instead of on the interceptor > since > I consider them resources of the action invocation. I don't know if this > would also access the interceptor params or not. I would go with something > more like: > > > [...] > > > > >Eco > >MenuGestor > >MenuBanquero > >MenuCliente > > > > [...] > > > (*Chris*) > > On Mon, Dec 13, 2010 at 9:05 PM, JOSE L MARTINEZ-AVIAL >wrote: > > > I know that the inteceptor knows which action is invoked. I just don't > want > > it to need to be aware of that. That's why I assigned a resource for each > > action, using a parameter in the definition of the action: > > > > [...] > > > > > > name="AuthoritationInterceptor.resource">Eco > > > >MenuGestor > >MenuBanquero > >MenuCliente > > > > [...] > > > > I could implement an interface for the action, but that would require > > defining an interface for each rule(since each rule needs different > > parameters). The second options is valid, but I like the idea of just > > declaring the getXXX method in the rule, and having the framework do the > > work for me(mostly, the type-conversion). What do you think? > > > > > > 2010/12/13 Maurizio Cucchiara > > > > > Ok, now it's definitively clear. > > > First every interceptor knows exactly which action is invoked through > > > action > > > invocation. > > > With that said your action could implement (1) your custom interface or > > (2) > > > a generic Request Aware interface in order to retrieve request > > parameters. > > > Does this answer your question? > > > > > > Maurizio Cucchiara > > > > > > Il giorno 14/dic/2010 03.27, "JOSE L MARTINEZ-AVIAL" > > > ha > > > scritto: > > > Hi Maurizio, Li, > > > Thanks for your suggestion, but the problem with the approaches you > > > suggested is that they link the security rules too much to the actions. > > We > > > want to be as abstract as possible. For that, we have developed the > > > following implementation: > > > > > > We created some entities called SecurityResource which represent a set > > of > > > possible user actions. For example, we can have a SecurityResource > called > > > SeeCustomer, that would be applied to any request related with seeing a > > > customer, or a SecurityResource called ModifyOwnProfile, used to filter > > any > > > action related to the modification of the profile. Every Action (unless > > it > > > is public) in the system is associated to a resource. > > > > > > We have also define some entities called SecurityAssert. A > > SecurityAssert > > > is a rule that checks some conditions, and returns true or false. They > > are > > > implemented through classes that implement a specific interface. For > each > > > SecurityResource we have a list of SecurityAsserts that need to be > > > validated. So our security definition look as follows: > > > > > >> > class="com.test.rules.SecurityAssertHasRole"> > > > Regla de seguridad para comprobar si un usuario > > > tiene un rol > > > > > > > > >> > class="com.test.rules.SecurityAssertDistributionList"> > > > Regla de seguridad para comprobar si un usuario > > > puede acceder a las listas de distribucion > > > > > > > > > > > >> > character="mandatory"> > > > > > > Role1 > > > Role2 > > > Role3 > > > > > > > > > > > > > > > Some of the rules need information from the request(customer number, > for > > > example). In an ideal world the interceptor should not know anything > > about > > > the action it is trying to check. It should only invoke the rules, and > > > check > > > their results. So I(the interceptor) should to be able to pass > parameters > > > from the request to the rule without actually having to know anything > > about > > > the request or the rules. Maybe the approach is complex, but we are > > > planning > > > to have some hundredths of actions, and be able to be as granular and > > > modular as possible with respect to security. Any ideas? > > > > > > thanks > > > > > > JL > > > > > > 2010/12/12 Li Ying > > > > > > > > > > I think you don't need this bothering job. > > > > > > > > You can: > > > > > > > > (1)Define some properties in your bas... > > > > > >
Re: Invocation of type conversion manually
If you just need access to the parameters from the action, you can use: String resource = invocation.getProxy().getConfig().getParams().get("AuthoritationInterceptor.resource"); I've used this several times to get parameters from the configuration, but I usually put the parameters on the action instead of on the interceptor since I consider them resources of the action invocation. I don't know if this would also access the interceptor params or not. I would go with something more like: [...] > >Eco >MenuGestor >MenuBanquero >MenuCliente > > [...] > (*Chris*) On Mon, Dec 13, 2010 at 9:05 PM, JOSE L MARTINEZ-AVIAL wrote: > I know that the inteceptor knows which action is invoked. I just don't want > it to need to be aware of that. That's why I assigned a resource for each > action, using a parameter in the definition of the action: > > [...] > > >Eco > >MenuGestor >MenuBanquero >MenuCliente > > [...] > > I could implement an interface for the action, but that would require > defining an interface for each rule(since each rule needs different > parameters). The second options is valid, but I like the idea of just > declaring the getXXX method in the rule, and having the framework do the > work for me(mostly, the type-conversion). What do you think? > > > 2010/12/13 Maurizio Cucchiara > > > Ok, now it's definitively clear. > > First every interceptor knows exactly which action is invoked through > > action > > invocation. > > With that said your action could implement (1) your custom interface or > (2) > > a generic Request Aware interface in order to retrieve request > parameters. > > Does this answer your question? > > > > Maurizio Cucchiara > > > > Il giorno 14/dic/2010 03.27, "JOSE L MARTINEZ-AVIAL" > ha > > scritto: > > Hi Maurizio, Li, > > Thanks for your suggestion, but the problem with the approaches you > > suggested is that they link the security rules too much to the actions. > We > > want to be as abstract as possible. For that, we have developed the > > following implementation: > > > > We created some entities called SecurityResource which represent a set > of > > possible user actions. For example, we can have a SecurityResource called > > SeeCustomer, that would be applied to any request related with seeing a > > customer, or a SecurityResource called ModifyOwnProfile, used to filter > any > > action related to the modification of the profile. Every Action (unless > it > > is public) in the system is associated to a resource. > > > > We have also define some entities called SecurityAssert. A > SecurityAssert > > is a rule that checks some conditions, and returns true or false. They > are > > implemented through classes that implement a specific interface. For each > > SecurityResource we have a list of SecurityAsserts that need to be > > validated. So our security definition look as follows: > > > >> class="com.test.rules.SecurityAssertHasRole"> > > Regla de seguridad para comprobar si un usuario > > tiene un rol > > > > > >> class="com.test.rules.SecurityAssertDistributionList"> > > Regla de seguridad para comprobar si un usuario > > puede acceder a las listas de distribucion > > > > > > > >> character="mandatory"> > > > > Role1 > > Role2 > > Role3 > > > > > > > > > > Some of the rules need information from the request(customer number, for > > example). In an ideal world the interceptor should not know anything > about > > the action it is trying to check. It should only invoke the rules, and > > check > > their results. So I(the interceptor) should to be able to pass parameters > > from the request to the rule without actually having to know anything > about > > the request or the rules. Maybe the approach is complex, but we are > > planning > > to have some hundredths of actions, and be able to be as granular and > > modular as possible with respect to security. Any ideas? > > > > thanks > > > > JL > > > > 2010/12/12 Li Ying > > > > > > > I think you don't need this bothering job. > > > > > > You can: > > > > > > (1)Define some properties in your bas... > > >
Re: Invocation of type conversion manually
I know that the inteceptor knows which action is invoked. I just don't want it to need to be aware of that. That's why I assigned a resource for each action, using a parameter in the definition of the action: [...] Eco MenuGestor MenuBanquero MenuCliente [...] I could implement an interface for the action, but that would require defining an interface for each rule(since each rule needs different parameters). The second options is valid, but I like the idea of just declaring the getXXX method in the rule, and having the framework do the work for me(mostly, the type-conversion). What do you think? 2010/12/13 Maurizio Cucchiara > Ok, now it's definitively clear. > First every interceptor knows exactly which action is invoked through > action > invocation. > With that said your action could implement (1) your custom interface or (2) > a generic Request Aware interface in order to retrieve request parameters. > Does this answer your question? > > Maurizio Cucchiara > > Il giorno 14/dic/2010 03.27, "JOSE L MARTINEZ-AVIAL" ha > scritto: > Hi Maurizio, Li, > Thanks for your suggestion, but the problem with the approaches you > suggested is that they link the security rules too much to the actions. We > want to be as abstract as possible. For that, we have developed the > following implementation: > > We created some entities called SecurityResource which represent a set of > possible user actions. For example, we can have a SecurityResource called > SeeCustomer, that would be applied to any request related with seeing a > customer, or a SecurityResource called ModifyOwnProfile, used to filter any > action related to the modification of the profile. Every Action (unless it > is public) in the system is associated to a resource. > > We have also define some entities called SecurityAssert. A SecurityAssert > is a rule that checks some conditions, and returns true or false. They are > implemented through classes that implement a specific interface. For each > SecurityResource we have a list of SecurityAsserts that need to be > validated. So our security definition look as follows: > >class="com.test.rules.SecurityAssertHasRole"> > Regla de seguridad para comprobar si un usuario > tiene un rol > > >class="com.test.rules.SecurityAssertDistributionList"> > Regla de seguridad para comprobar si un usuario > puede acceder a las listas de distribucion > > > >character="mandatory"> > > Role1 > Role2 > Role3 > > > > > Some of the rules need information from the request(customer number, for > example). In an ideal world the interceptor should not know anything about > the action it is trying to check. It should only invoke the rules, and > check > their results. So I(the interceptor) should to be able to pass parameters > from the request to the rule without actually having to know anything about > the request or the rules. Maybe the approach is complex, but we are > planning > to have some hundredths of actions, and be able to be as granular and > modular as possible with respect to security. Any ideas? > > thanks > > JL > > 2010/12/12 Li Ying > > > > I think you don't need this bothering job. > > > > You can: > > > > (1)Define some properties in your bas... >
Re: Invocation of type conversion manually
Ok, now it's definitively clear. First every interceptor knows exactly which action is invoked through action invocation. With that said your action could implement (1) your custom interface or (2) a generic Request Aware interface in order to retrieve request parameters. Does this answer your question? Maurizio Cucchiara Il giorno 14/dic/2010 03.27, "JOSE L MARTINEZ-AVIAL" ha scritto: Hi Maurizio, Li, Thanks for your suggestion, but the problem with the approaches you suggested is that they link the security rules too much to the actions. We want to be as abstract as possible. For that, we have developed the following implementation: We created some entities called SecurityResource which represent a set of possible user actions. For example, we can have a SecurityResource called SeeCustomer, that would be applied to any request related with seeing a customer, or a SecurityResource called ModifyOwnProfile, used to filter any action related to the modification of the profile. Every Action (unless it is public) in the system is associated to a resource. We have also define some entities called SecurityAssert. A SecurityAssert is a rule that checks some conditions, and returns true or false. They are implemented through classes that implement a specific interface. For each SecurityResource we have a list of SecurityAsserts that need to be validated. So our security definition look as follows: Regla de seguridad para comprobar si un usuario tiene un rol Regla de seguridad para comprobar si un usuario puede acceder a las listas de distribucion Role1 Role2 Role3 Some of the rules need information from the request(customer number, for example). In an ideal world the interceptor should not know anything about the action it is trying to check. It should only invoke the rules, and check their results. So I(the interceptor) should to be able to pass parameters from the request to the rule without actually having to know anything about the request or the rules. Maybe the approach is complex, but we are planning to have some hundredths of actions, and be able to be as granular and modular as possible with respect to security. Any ideas? thanks JL 2010/12/12 Li Ying > I think you don't need this bothering job. > > You can: > > (1)Define some properties in your bas...
Re: Invocation of type conversion manually
Hi Maurizio, Li, Thanks for your suggestion, but the problem with the approaches you suggested is that they link the security rules too much to the actions. We want to be as abstract as possible. For that, we have developed the following implementation: We created some entities called SecurityResource which represent a set of possible user actions. For example, we can have a SecurityResource called SeeCustomer, that would be applied to any request related with seeing a customer, or a SecurityResource called ModifyOwnProfile, used to filter any action related to the modification of the profile. Every Action (unless it is public) in the system is associated to a resource. We have also define some entities called SecurityAssert. A SecurityAssert is a rule that checks some conditions, and returns true or false. They are implemented through classes that implement a specific interface. For each SecurityResource we have a list of SecurityAsserts that need to be validated. So our security definition look as follows: Regla de seguridad para comprobar si un usuario tiene un rol Regla de seguridad para comprobar si un usuario puede acceder a las listas de distribucion Role1 Role2 Role3 Some of the rules need information from the request(customer number, for example). In an ideal world the interceptor should not know anything about the action it is trying to check. It should only invoke the rules, and check their results. So I(the interceptor) should to be able to pass parameters from the request to the rule without actually having to know anything about the request or the rules. Maybe the approach is complex, but we are planning to have some hundredths of actions, and be able to be as granular and modular as possible with respect to security. Any ideas? thanks JL 2010/12/12 Li Ying > I think you don't need this bothering job. > > You can: > > (1)Define some properties in your base class of all your action classes. > (2)Use these properties to capture data from the request. > (3)Run your interceptor AFTER the interceptors of struts2. > But BEFORE the execution of the Action class > > So, > The interceptors of struts2 will do the data-conversion for you. > Your interceptor can simply extract parameters all you need from the > Action instance. > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
Re: Invocation of type conversion manually
I think you don't need this bothering job. You can: (1)Define some properties in your base class of all your action classes. (2)Use these properties to capture data from the request. (3)Run your interceptor AFTER the interceptors of struts2. But BEFORE the execution of the Action class So, The interceptors of struts2 will do the data-conversion for you. Your interceptor can simply extract parameters all you need from the Action instance. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Invocation of type conversion manually
2010/12/10 Jose Luis Martinez Avial : >The > validation should be dinamic, so the rules should be able to receive > information from the request. Basing Rule Access Control on request's parameters might induce security flow risks. > What I would like to do is to use Struts' > mechanism to process, parse and type-convert the request's parameters > to do that. So I would invocate the Struts' conversion over the classes > implementing the rules, and set the parameters in the rules, the same > way Struts does with the actions. I've tried looking at the code, but > I'm a bit lost. Can somebody give some orientation on how to invoke the > conversion? What about using an abstract BaseAction with your rule bean declared inside? -- Maurizio Cucchiara - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org