Author Login
Post Reply
user Digest 24 Jul 2008 18:23:58 -0000 Issue 8159
Topics (messages 189286 through 189296):
Re: [s2] Making textfield input optional
189286 by: Dave Newton
189287 by: Milan Milanovic
189288 by: Gabriel Belingueres
189289 by: Milan Milanovic
189290 by: Gabriel Belingueres
189291 by: Milan Milanovic
189292 by: Gabriel Belingueres
[S2] how to have the form horizontally?
189293 by: xianwinwin
189295 by: Piero Sartini
Re: namespace headpain
189294 by: Brad A Cupit
Re: What is the best way to handle cancel, Update, Back Buttons in Struts2
189296 by: matt.payne
Administrivia:
---------------------------------------------------------------------
To post to the list, e-mail: user@(protected)
To unsubscribe, e-mail: user-digest-unsubscribe@(protected)
For additional commands, e-mail: user-digest-help@(protected)
----------------------------------------------------------------------

Attachment:
user_189286.ezm (zipped)Are you using a BigDecimal type converter (one of which was just posted)?
AFAIK it won't work w/o the converter, but I could be remembering incorrectly.
Dave
--- On Thu, 7/24/08, Milan Milanovic <milanmilanovich@(protected):
> From: Milan Milanovic <milanmilanovich@(protected)>
> Subject: Re: [s2] Making textfield input optional
> To: user@(protected)
> Date: Thursday, July 24, 2008, 11:36 AM
> Dear Gabriel,
>
> no, my actual question is related to the issue when user
> doesn't enter
> anything to the textfield which is connected to BigDecimal
> in my action
> class.
>
> --
> Thx, Milan
>
>
>
> Gabriel Belingueres-2 wrote:
> >
> > Please make sure that the input string is according
> the BigDecimal format:
> >
> http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#BigDecimal(
java.lang.String)
> >
> > 2008/7/24 Milan Milanovic
> <milanmilanovich@(protected)>:
> >>
> >> Hi Gabriel,
> >>
> >> no I cannot do this because my field is of type
> BigDecimal and I must
> >> have
> >> get/set methods for it.
> >>
> >> --
> >> Thx, Milan
> >>
> >>
> >> Gabriel Belingueres-2 wrote:
> >>>
> >>> instead of:
> >>>
> >>> public vlid setInValue(BigDecimal x) {
> >>> this.x = x;
> >>> }
> >>>
> >>> test with this:
> >>>
> >>> public vlid setInValue(String s) {
> >>> this.x = new BigDecimal(s);
> >>> }
> >>>
> >>>
> >>> 2008/7/24 Milan Milanovic
> <milanmilanovich@(protected)>:
> >>>>
> >>>> Hi Jim,
> >>>>
> >>>> no, I have that method.
> >>>>
> >>>> --
> >>>> Thx, Milan
> >>>>
> >>>>
> >>>> Jim Kiley wrote:
> >>>>>
> >>>>> Doesn't that exception usually get
> thrown when, in this case,
> >>>>> ViewAction
> >>>>> doesn't have a setInValue()
> method?
> >>>>>
> >>>>> jk
> >>>>>
> >>>>> On Thu, Jul 24, 2008 at 10:31 AM,
> Gabriel Belingueres
> >>>>> <belingueres@(protected)>
> >>>>> wrote:
> >>>>>
> >>>>>> Which is the data type of inValue?
> >>>>>>
> >>>>>> 2008/7/24 Milan Milanovic
> <milanmilanovich@(protected)>:
> >>>>>> >
> >>>>>> > Hi,
> >>>>>> >
> >>>>>> > I have one form with multiple
> textfields, and I want to one of that
> >>>>>> > textfield be optional for
> user, i.e., he doesn't need to enter
> >>>>>> information
> >>>>>> > in that particular field.
> Now, when user don't enter I get this in
> >>>>>> my
> >>>>>> log:
> >>>>>> >
> >>>>>> > ERROR
>
com.opensymphony.xwork2.interceptor.ParametersInterceptor:204
> >>>>>> -
> >>>>>> > ParametersInterceptor -
> [setParameters]: Unexpected Exception
> >>>>>> caught
> >>>>>> setting
> >>>>>> > 'inValue' on
> 'class com.myProject.action.ViewAction: Error setting
> >>>>>> > expression 'inValue'
> with value '[Ljava.lang.String;@(protected)'
> >>>>>> >
> >>>>>> > How can I enable this but
> without getting this error ?
> >>>>>> >
> >>>>>> > --
> >>>>>> > Thx, Milan
> >>>>>> > --
> >>>>>> > View this message in context:
> >>>>>>
> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18632806.html
> >>>>>> > Sent from the Struts - User
> mailing list archive at Nabble.com.
> >>>>>> >
> >>>>>> >
> >>>>>> >
> >>>>>>
> ---------------------------------------------------------------------
> >>>>>> > To unsubscribe, e-mail:
> user-unsubscribe@(protected)
> >>>>>> > For additional commands,
> e-mail: user-help@(protected)
> >>>>>> >
> >>>>>> >
> >>>>>>
> >>>>>>
> ---------------------------------------------------------------------
> >>>>>> To unsubscribe, e-mail:
> user-unsubscribe@(protected)
> >>>>>> For additional commands, e-mail:
> user-help@(protected)
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>> --
> >>>>> Jim Kiley
> >>>>> Technical Consultant | Summa
> >>>>> [p] 412.258.3346 [m] 412.445.1729
> >>>>> http://www.summa-tech.com
> >>>>>
> >>>>>
> >>>>
> >>>> --
> >>>> View this message in context:
> >>>>
> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18633474.html
> >>>> Sent from the Struts - User mailing list
> archive at Nabble.com.
> >>>>
> >>>>
> >>>>
> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail:
> user-unsubscribe@(protected)
> >>>> For additional commands, e-mail:
> user-help@(protected)
> >>>>
> >>>>
> >>>
> >>>
> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail:
> user-unsubscribe@(protected)
> >>> For additional commands, e-mail:
> user-help@(protected)
> >>>
> >>>
> >>>
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18633888.html
> >> Sent from the Struts - User mailing list archive
> at Nabble.com.
> >>
> >>
> >>
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail:
> user-unsubscribe@(protected)
> >> For additional commands, e-mail:
> user-help@(protected)
> >>
> >>
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> user-unsubscribe@(protected)
> > For additional commands, e-mail:
> user-help@(protected)
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18634541.html
> Sent from the Struts - User mailing list archive at
> Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail:
> user-help@(protected)

Attachment:
user_189287.ezm (zipped)Dear Newton,
Yes, I'm using BigDecimal type converter given here:
http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html
http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html .
--
Thx, Milan
newton.dave wrote:
>
> Are you using a BigDecimal type converter (one of which was just posted)?
>
> AFAIK it won't work w/o the converter, but I could be remembering
> incorrectly.
>
> Dave
>
> --- On Thu, 7/24/08, Milan Milanovic <milanmilanovich@(protected):
>
>> From: Milan Milanovic <milanmilanovich@(protected)>
>> Subject: Re: [s2] Making textfield input optional
>> To: user@(protected)
>> Date: Thursday, July 24, 2008, 11:36 AM
>> Dear Gabriel,
>>
>> no, my actual question is related to the issue when user
>> doesn't enter
>> anything to the textfield which is connected to BigDecimal
>> in my action
>> class.
>>
>> --
>> Thx, Milan
>>
>>
>>
>> Gabriel Belingueres-2 wrote:
>> >
>> > Please make sure that the input string is according
>> the BigDecimal format:
>> >
>> http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#BigDecimal(
java.lang.String)
>> >
>> > 2008/7/24 Milan Milanovic
>> <milanmilanovich@(protected)>:
>> >>
>> >> Hi Gabriel,
>> >>
>> >> no I cannot do this because my field is of type
>> BigDecimal and I must
>> >> have
>> >> get/set methods for it.
>> >>
>> >> --
>> >> Thx, Milan
>> >>
>> >>
>> >> Gabriel Belingueres-2 wrote:
>> >>>
>> >>> instead of:
>> >>>
>> >>> public vlid setInValue(BigDecimal x) {
>> >>> this.x = x;
>> >>> }
>> >>>
>> >>> test with this:
>> >>>
>> >>> public vlid setInValue(String s) {
>> >>> this.x = new BigDecimal(s);
>> >>> }
>> >>>
>> >>>
>> >>> 2008/7/24 Milan Milanovic
>> <milanmilanovich@(protected)>:
>> >>>>
>> >>>> Hi Jim,
>> >>>>
>> >>>> no, I have that method.
>> >>>>
>> >>>> --
>> >>>> Thx, Milan
>> >>>>
>> >>>>
>> >>>> Jim Kiley wrote:
>> >>>>>
>> >>>>> Doesn't that exception usually get
>> thrown when, in this case,
>> >>>>> ViewAction
>> >>>>> doesn't have a setInValue()
>> method?
>> >>>>>
>> >>>>> jk
>> >>>>>
>> >>>>> On Thu, Jul 24, 2008 at 10:31 AM,
>> Gabriel Belingueres
>> >>>>> <belingueres@(protected)>
>> >>>>> wrote:
>> >>>>>
>> >>>>>> Which is the data type of inValue?
>> >>>>>>
>> >>>>>> 2008/7/24 Milan Milanovic
>> <milanmilanovich@(protected)>:
>> >>>>>> >
>> >>>>>> > Hi,
>> >>>>>> >
>> >>>>>> > I have one form with multiple
>> textfields, and I want to one of that
>> >>>>>> > textfield be optional for
>> user, i.e., he doesn't need to enter
>> >>>>>> information
>> >>>>>> > in that particular field.
>> Now, when user don't enter I get this in
>> >>>>>> my
>> >>>>>> log:
>> >>>>>> >
>> >>>>>> > ERROR
>>
com.opensymphony.xwork2.interceptor.ParametersInterceptor:204
>> >>>>>> -
>> >>>>>> > ParametersInterceptor -
>> [setParameters]: Unexpected Exception
>> >>>>>> caught
>> >>>>>> setting
>> >>>>>> > 'inValue' on
>> 'class com.myProject.action.ViewAction: Error setting
>> >>>>>> > expression 'inValue'
>> with value '[Ljava.lang.String;@(protected)'
>> >>>>>> >
>> >>>>>> > How can I enable this but
>> without getting this error ?
>> >>>>>> >
>> >>>>>> > --
>> >>>>>> > Thx, Milan
>> >>>>>> > --
>> >>>>>> > View this message in context:
>> >>>>>>
>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18632806.html
>> >>>>>> > Sent from the Struts - User
>> mailing list archive at Nabble.com.
>> >>>>>> >
>> >>>>>> >
>> >>>>>> >
>> >>>>>>
>> ---------------------------------------------------------------------
>> >>>>>> > To unsubscribe, e-mail:
>> user-unsubscribe@(protected)
>> >>>>>> > For additional commands,
>> e-mail: user-help@(protected)
>> >>>>>> >
>> >>>>>> >
>> >>>>>>
>> >>>>>>
>> ---------------------------------------------------------------------
>> >>>>>> To unsubscribe, e-mail:
>> user-unsubscribe@(protected)
>> >>>>>> For additional commands, e-mail:
>> user-help@(protected)
>> >>>>>>
>> >>>>>>
>> >>>>>
>> >>>>>
>> >>>>> --
>> >>>>> Jim Kiley
>> >>>>> Technical Consultant | Summa
>> >>>>> [p] 412.258.3346 [m] 412.445.1729
>> >>>>> http://www.summa-tech.com
>> >>>>>
>> >>>>>
>> >>>>
>> >>>> --
>> >>>> View this message in context:
>> >>>>
>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18633474.html
>> >>>> Sent from the Struts - User mailing list
>> archive at Nabble.com.
>> >>>>
>> >>>>
>> >>>>
>> ---------------------------------------------------------------------
>> >>>> To unsubscribe, e-mail:
>> user-unsubscribe@(protected)
>> >>>> For additional commands, e-mail:
>> user-help@(protected)
>> >>>>
>> >>>>
>> >>>
>> >>>
>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail:
>> user-unsubscribe@(protected)
>> >>> For additional commands, e-mail:
>> user-help@(protected)
>> >>>
>> >>>
>> >>>
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18633888.html
>> >> Sent from the Struts - User mailing list archive
>> at Nabble.com.
>> >>
>> >>
>> >>
>> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail:
>> user-unsubscribe@(protected)
>> >> For additional commands, e-mail:
>> user-help@(protected)
>> >>
>> >>
>> >
>> >
>> ---------------------------------------------------------------------
>> > To unsubscribe, e-mail:
>> user-unsubscribe@(protected)
>> > For additional commands, e-mail:
>> user-help@(protected)
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18634541.html
>> Sent from the Struts - User mailing list archive at
>> Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail:
>> user-help@(protected)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_189288.ezm (zipped)I'm using S2.1.2 (are you using the same version?), and it will throw
a NumberFormatException when setting an empty string, but this
workaround will make ParameterInterceptor to think it is setting a
String parameter:
public void setValue(String s) {
if (!StringUtils.isBlank(s)) {
try {
this.value= new BigDecimal(s);
catch(NumberFormatException e) {
this.value = null;
}
}
}
of course you still need a validator so that the string doesn't
violate the BigDecimal grammar.
Other option (may be more clean) is the action having both the string
instance and the real BigDecimal instance, then the form will only set
the string instance.
2008/7/24 Milan Milanovic <milanmilanovich@(protected)>:
>
> Dear Newton,
>
> Yes, I'm using BigDecimal type converter given here:
> http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html
> http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html .
>
> --
> Thx, Milan
>
>
> newton.dave wrote:
>>
>> Are you using a BigDecimal type converter (one of which was just posted)?
>>
>> AFAIK it won't work w/o the converter, but I could be remembering
>> incorrectly.
>>
>> Dave
>>
>> --- On Thu, 7/24/08, Milan Milanovic <milanmilanovich@(protected):
>>
>>> From: Milan Milanovic <milanmilanovich@(protected)>
>>> Subject: Re: [s2] Making textfield input optional
>>> To: user@(protected)
>>> Date: Thursday, July 24, 2008, 11:36 AM
>>> Dear Gabriel,
>>>
>>> no, my actual question is related to the issue when user
>>> doesn't enter
>>> anything to the textfield which is connected to BigDecimal
>>> in my action
>>> class.
>>>
>>> --
>>> Thx, Milan
>>>
>>>
>>>
>>> Gabriel Belingueres-2 wrote:
>>> >
>>> > Please make sure that the input string is according
>>> the BigDecimal format:
>>> >
>>> http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#BigDecimal(
java.lang.String)
>>> >
>>> > 2008/7/24 Milan Milanovic
>>> <milanmilanovich@(protected)>:
>>> >>
>>> >> Hi Gabriel,
>>> >>
>>> >> no I cannot do this because my field is of type
>>> BigDecimal and I must
>>> >> have
>>> >> get/set methods for it.
>>> >>
>>> >> --
>>> >> Thx, Milan
>>> >>
>>> >>
>>> >> Gabriel Belingueres-2 wrote:
>>> >>>
>>> >>> instead of:
>>> >>>
>>> >>> public vlid setInValue(BigDecimal x) {
>>> >>> this.x = x;
>>> >>> }
>>> >>>
>>> >>> test with this:
>>> >>>
>>> >>> public vlid setInValue(String s) {
>>> >>> this.x = new BigDecimal(s);
>>> >>> }
>>> >>>
>>> >>>
>>> >>> 2008/7/24 Milan Milanovic
>>> <milanmilanovich@(protected)>:
>>> >>>>
>>> >>>> Hi Jim,
>>> >>>>
>>> >>>> no, I have that method.
>>> >>>>
>>> >>>> --
>>> >>>> Thx, Milan
>>> >>>>
>>> >>>>
>>> >>>> Jim Kiley wrote:
>>> >>>>>
>>> >>>>> Doesn't that exception usually get
>>> thrown when, in this case,
>>> >>>>> ViewAction
>>> >>>>> doesn't have a setInValue()
>>> method?
>>> >>>>>
>>> >>>>> jk
>>> >>>>>
>>> >>>>> On Thu, Jul 24, 2008 at 10:31 AM,
>>> Gabriel Belingueres
>>> >>>>> <belingueres@(protected)>
>>> >>>>> wrote:
>>> >>>>>
>>> >>>>>> Which is the data type of inValue?
>>> >>>>>>
>>> >>>>>> 2008/7/24 Milan Milanovic
>>> <milanmilanovich@(protected)>:
>>> >>>>>> >
>>> >>>>>> > Hi,
>>> >>>>>> >
>>> >>>>>> > I have one form with multiple
>>> textfields, and I want to one of that
>>> >>>>>> > textfield be optional for
>>> user, i.e., he doesn't need to enter
>>> >>>>>> information
>>> >>>>>> > in that particular field.
>>> Now, when user don't enter I get this in
>>> >>>>>> my
>>> >>>>>> log:
>>> >>>>>> >
>>> >>>>>> > ERROR
>>>
com.opensymphony.xwork2.interceptor.ParametersInterceptor:204
>>> >>>>>> -
>>> >>>>>> > ParametersInterceptor -
>>> [setParameters]: Unexpected Exception
>>> >>>>>> caught
>>> >>>>>> setting
>>> >>>>>> > 'inValue' on
>>> 'class com.myProject.action.ViewAction: Error setting
>>> >>>>>> > expression 'inValue'
>>> with value '[Ljava.lang.String;@(protected)'
>>> >>>>>> >
>>> >>>>>> > How can I enable this but
>>> without getting this error ?
>>> >>>>>> >
>>> >>>>>> > --
>>> >>>>>> > Thx, Milan
>>> >>>>>> > --
>>> >>>>>> > View this message in context:
>>> >>>>>>
>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18632806.html
>>> >>>>>> > Sent from the Struts - User
>>> mailing list archive at Nabble.com.
>>> >>>>>> >
>>> >>>>>> >
>>> >>>>>> >
>>> >>>>>>
>>> ---------------------------------------------------------------------
>>> >>>>>> > To unsubscribe, e-mail:
>>> user-unsubscribe@(protected)
>>> >>>>>> > For additional commands,
>>> e-mail: user-help@(protected)
>>> >>>>>> >
>>> >>>>>> >
>>> >>>>>>
>>> >>>>>>
>>> ---------------------------------------------------------------------
>>> >>>>>> To unsubscribe, e-mail:
>>> user-unsubscribe@(protected)
>>> >>>>>> For additional commands, e-mail:
>>> user-help@(protected)
>>> >>>>>>
>>> >>>>>>
>>> >>>>>
>>> >>>>>
>>> >>>>> --
>>> >>>>> Jim Kiley
>>> >>>>> Technical Consultant | Summa
>>> >>>>> [p] 412.258.3346 [m] 412.445.1729
>>> >>>>> http://www.summa-tech.com
>>> >>>>>
>>> >>>>>
>>> >>>>
>>> >>>> --
>>> >>>> View this message in context:
>>> >>>>
>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18633474.html
>>> >>>> Sent from the Struts - User mailing list
>>> archive at Nabble.com.
>>> >>>>
>>> >>>>
>>> >>>>
>>> ---------------------------------------------------------------------
>>> >>>> To unsubscribe, e-mail:
>>> user-unsubscribe@(protected)
>>> >>>> For additional commands, e-mail:
>>> user-help@(protected)
>>> >>>>
>>> >>>>
>>> >>>
>>> >>>
>>> ---------------------------------------------------------------------
>>> >>> To unsubscribe, e-mail:
>>> user-unsubscribe@(protected)
>>> >>> For additional commands, e-mail:
>>> user-help@(protected)
>>> >>>
>>> >>>
>>> >>>
>>> >>
>>> >> --
>>> >> View this message in context:
>>> >>
>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18633888.html
>>> >> Sent from the Struts - User mailing list archive
>>> at Nabble.com.
>>> >>
>>> >>
>>> >>
>>> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail:
>>> user-unsubscribe@(protected)
>>> >> For additional commands, e-mail:
>>> user-help@(protected)
>>> >>
>>> >>
>>> >
>>> >
>>> ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail:
>>> user-unsubscribe@(protected)
>>> > For additional commands, e-mail:
>>> user-help@(protected)
>>> >
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18634541.html
>>> Sent from the Struts - User mailing list archive at
>>> Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>> For additional commands, e-mail:
>>> user-help@(protected)
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18634840.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment:
user_189289.ezm (zipped)Dear Gabriel,
thank you. I tried without my Converter class for BigDecimal and it is the
same, when user doesn't enter value I got that error in a log.
I'm using S2 2.0.11.1. This solution is good, but my value that is set comes
from model where I have class and attribute (BigDecimal) with its get/set
methods, by putting this set(String) instead of set(BigDecimal) I'm
violating class semantics ?
The other solution is O.K., but I've already used it with Dates and
datetimepicker. Can I change in some way this BigDecimal converter to avoid
this error:
http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html
http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html
--
Regards, Milan.
Gabriel Belingueres-2 wrote:
>
> I'm using S2.1.2 (are you using the same version?), and it will throw
> a NumberFormatException when setting an empty string, but this
> workaround will make ParameterInterceptor to think it is setting a
> String parameter:
>
> public void setValue(String s) {
> if (!StringUtils.isBlank(s)) {
> try {
> this.value= new BigDecimal(s);
> catch(NumberFormatException e) {
> this.value = null;
> }
> }
> }
>
> of course you still need a validator so that the string doesn't
> violate the BigDecimal grammar.
>
> Other option (may be more clean) is the action having both the string
> instance and the real BigDecimal instance, then the form will only set
> the string instance.
>
> 2008/7/24 Milan Milanovic <milanmilanovich@(protected)>:
>>
>> Dear Newton,
>>
>> Yes, I'm using BigDecimal type converter given here:
>> http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html
>> http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html .
>>
>> --
>> Thx, Milan
>>
>>
>> newton.dave wrote:
>>>
>>> Are you using a BigDecimal type converter (one of which was just
>>> posted)?
>>>
>>> AFAIK it won't work w/o the converter, but I could be remembering
>>> incorrectly.
>>>
>>> Dave
>>>
>>> --- On Thu, 7/24/08, Milan Milanovic <milanmilanovich@(protected):
>>>
>>>> From: Milan Milanovic <milanmilanovich@(protected)>
>>>> Subject: Re: [s2] Making textfield input optional
>>>> To: user@(protected)
>>>> Date: Thursday, July 24, 2008, 11:36 AM
>>>> Dear Gabriel,
>>>>
>>>> no, my actual question is related to the issue when user
>>>> doesn't enter
>>>> anything to the textfield which is connected to BigDecimal
>>>> in my action
>>>> class.
>>>>
>>>> --
>>>> Thx, Milan
>>>>
>>>>
>>>>
>>>> Gabriel Belingueres-2 wrote:
>>>> >
>>>> > Please make sure that the input string is according
>>>> the BigDecimal format:
>>>> >
>>>> http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#BigDecimal(
java.lang.String)
>>>> >
>>>> > 2008/7/24 Milan Milanovic
>>>> <milanmilanovich@(protected)>:
>>>> >>
>>>> >> Hi Gabriel,
>>>> >>
>>>> >> no I cannot do this because my field is of type
>>>> BigDecimal and I must
>>>> >> have
>>>> >> get/set methods for it.
>>>> >>
>>>> >> --
>>>> >> Thx, Milan
>>>> >>
>>>> >>
>>>> >> Gabriel Belingueres-2 wrote:
>>>> >>>
>>>> >>> instead of:
>>>> >>>
>>>> >>> public vlid setInValue(BigDecimal x) {
>>>> >>> this.x = x;
>>>> >>> }
>>>> >>>
>>>> >>> test with this:
>>>> >>>
>>>> >>> public vlid setInValue(String s) {
>>>> >>> this.x = new BigDecimal(s);
>>>> >>> }
>>>> >>>
>>>> >>>
>>>> >>> 2008/7/24 Milan Milanovic
>>>> <milanmilanovich@(protected)>:
>>>> >>>>
>>>> >>>> Hi Jim,
>>>> >>>>
>>>> >>>> no, I have that method.
>>>> >>>>
>>>> >>>> --
>>>> >>>> Thx, Milan
>>>> >>>>
>>>> >>>>
>>>> >>>> Jim Kiley wrote:
>>>> >>>>>
>>>> >>>>> Doesn't that exception usually get
>>>> thrown when, in this case,
>>>> >>>>> ViewAction
>>>> >>>>> doesn't have a setInValue()
>>>> method?
>>>> >>>>>
>>>> >>>>> jk
>>>> >>>>>
>>>> >>>>> On Thu, Jul 24, 2008 at 10:31 AM,
>>>> Gabriel Belingueres
>>>> >>>>> <belingueres@(protected)>
>>>> >>>>> wrote:
>>>> >>>>>
>>>> >>>>>> Which is the data type of inValue?
>>>> >>>>>>
>>>> >>>>>> 2008/7/24 Milan Milanovic
>>>> <milanmilanovich@(protected)>:
>>>> >>>>>> >
>>>> >>>>>> > Hi,
>>>> >>>>>> >
>>>> >>>>>> > I have one form with multiple
>>>> textfields, and I want to one of that
>>>> >>>>>> > textfield be optional for
>>>> user, i.e., he doesn't need to enter
>>>> >>>>>> information
>>>> >>>>>> > in that particular field.
>>>> Now, when user don't enter I get this in
>>>> >>>>>> my
>>>> >>>>>> log:
>>>> >>>>>> >
>>>> >>>>>> > ERROR
>>>>
com.opensymphony.xwork2.interceptor.ParametersInterceptor:204
>>>> >>>>>> -
>>>> >>>>>> > ParametersInterceptor -
>>>> [setParameters]: Unexpected Exception
>>>> >>>>>> caught
>>>> >>>>>> setting
>>>> >>>>>> > 'inValue' on
>>>> 'class com.myProject.action.ViewAction: Error setting
>>>> >>>>>> > expression 'inValue'
>>>> with value '[Ljava.lang.String;@(protected)'
>>>> >>>>>> >
>>>> >>>>>> > How can I enable this but
>>>> without getting this error ?
>>>> >>>>>> >
>>>> >>>>>> > --
>>>> >>>>>> > Thx, Milan
>>>> >>>>>> > --
>>>> >>>>>> > View this message in context:
>>>> >>>>>>
>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18632806.html
>>>> >>>>>> > Sent from the Struts - User
>>>> mailing list archive at Nabble.com.
>>>> >>>>>> >
>>>> >>>>>> >
>>>> >>>>>> >
>>>> >>>>>>
>>>> ---------------------------------------------------------------------
>>>> >>>>>> > To unsubscribe, e-mail:
>>>> user-unsubscribe@(protected)
>>>> >>>>>> > For additional commands,
>>>> e-mail: user-help@(protected)
>>>> >>>>>> >
>>>> >>>>>> >
>>>> >>>>>>
>>>> >>>>>>
>>>> ---------------------------------------------------------------------
>>>> >>>>>> To unsubscribe, e-mail:
>>>> user-unsubscribe@(protected)
>>>> >>>>>> For additional commands, e-mail:
>>>> user-help@(protected)
>>>> >>>>>>
>>>> >>>>>>
>>>> >>>>>
>>>> >>>>>
>>>> >>>>> --
>>>> >>>>> Jim Kiley
>>>> >>>>> Technical Consultant | Summa
>>>> >>>>> [p] 412.258.3346 [m] 412.445.1729
>>>> >>>>> http://www.summa-tech.com
>>>> >>>>>
>>>> >>>>>
>>>> >>>>
>>>> >>>> --
>>>> >>>> View this message in context:
>>>> >>>>
>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18633474.html
>>>> >>>> Sent from the Struts - User mailing list
>>>> archive at Nabble.com.
>>>> >>>>
>>>> >>>>
>>>> >>>>
>>>> ---------------------------------------------------------------------
>>>> >>>> To unsubscribe, e-mail:
>>>> user-unsubscribe@(protected)
>>>> >>>> For additional commands, e-mail:
>>>> user-help@(protected)
>>>> >>>>
>>>> >>>>
>>>> >>>
>>>> >>>
>>>> ---------------------------------------------------------------------
>>>> >>> To unsubscribe, e-mail:
>>>> user-unsubscribe@(protected)
>>>> >>> For additional commands, e-mail:
>>>> user-help@(protected)
>>>> >>>
>>>> >>>
>>>> >>>
>>>> >>
>>>> >> --
>>>> >> View this message in context:
>>>> >>
>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18633888.html
>>>> >> Sent from the Struts - User mailing list archive
>>>> at Nabble.com.
>>>> >>
>>>> >>
>>>> >>
>>>> ---------------------------------------------------------------------
>>>> >> To unsubscribe, e-mail:
>>>> user-unsubscribe@(protected)
>>>> >> For additional commands, e-mail:
>>>> user-help@(protected)
>>>> >>
>>>> >>
>>>> >
>>>> >
>>>> ---------------------------------------------------------------------
>>>> > To unsubscribe, e-mail:
>>>> user-unsubscribe@(protected)
>>>> > For additional commands, e-mail:
>>>> user-help@(protected)
>>>> >
>>>> >
>>>> >
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18634541.html
>>>> Sent from the Struts - User mailing list archive at
>>>> Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>>> For additional commands, e-mail:
>>>> user-help@(protected)
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>> For additional commands, e-mail: user-help@(protected)
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18634840.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_189290.ezm (zipped)You don't need to modify your model, just delegate to it:
public void setValue(String s) {
if (!StringUtils.isBlank(s)) {
try {
model.setValue(new BigDecimal(s));
catch(NumberFormatException e) {
model.setValue(null);
}
}
}
2008/7/24 Milan Milanovic <milanmilanovich@(protected)>:
>
> Dear Gabriel,
>
> thank you. I tried without my Converter class for BigDecimal and it is the
> same, when user doesn't enter value I got that error in a log.
>
> I'm using S2 2.0.11.1. This solution is good, but my value that is set comes
> from model where I have class and attribute (BigDecimal) with its get/set
> methods, by putting this set(String) instead of set(BigDecimal) I'm
> violating class semantics ?
>
> The other solution is O.K., but I've already used it with Dates and
> datetimepicker. Can I change in some way this BigDecimal converter to avoid
> this error:
> http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html
> http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html
>
> --
> Regards, Milan.
>
>
>
>
> Gabriel Belingueres-2 wrote:
>>
>> I'm using S2.1.2 (are you using the same version?), and it will throw
>> a NumberFormatException when setting an empty string, but this
>> workaround will make ParameterInterceptor to think it is setting a
>> String parameter:
>>
>> public void setValue(String s) {
>> if (!StringUtils.isBlank(s)) {
>> try {
>> this.value= new BigDecimal(s);
>> catch(NumberFormatException e) {
>> this.value = null;
>> }
>> }
>> }
>>
>> of course you still need a validator so that the string doesn't
>> violate the BigDecimal grammar.
>>
>> Other option (may be more clean) is the action having both the string
>> instance and the real BigDecimal instance, then the form will only set
>> the string instance.
>>
>> 2008/7/24 Milan Milanovic <milanmilanovich@(protected)>:
>>>
>>> Dear Newton,
>>>
>>> Yes, I'm using BigDecimal type converter given here:
>>> http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html
>>> http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html .
>>>
>>> --
>>> Thx, Milan
>>>
>>>
>>> newton.dave wrote:
>>>>
>>>> Are you using a BigDecimal type converter (one of which was just
>>>> posted)?
>>>>
>>>> AFAIK it won't work w/o the converter, but I could be remembering
>>>> incorrectly.
>>>>
>>>> Dave
>>>>
>>>> --- On Thu, 7/24/08, Milan Milanovic <milanmilanovich@(protected):
>>>>
>>>>> From: Milan Milanovic <milanmilanovich@(protected)>
>>>>> Subject: Re: [s2] Making textfield input optional
>>>>> To: user@(protected)
>>>>> Date: Thursday, July 24, 2008, 11:36 AM
>>>>> Dear Gabriel,
>>>>>
>>>>> no, my actual question is related to the issue when user
>>>>> doesn't enter
>>>>> anything to the textfield which is connected to BigDecimal
>>>>> in my action
>>>>> class.
>>>>>
>>>>> --
>>>>> Thx, Milan
>>>>>
>>>>>
>>>>>
>>>>> Gabriel Belingueres-2 wrote:
>>>>> >
>>>>> > Please make sure that the input string is according
>>>>> the BigDecimal format:
>>>>> >
>>>>> http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#BigDecimal(
java.lang.String)
>>>>> >
>>>>> > 2008/7/24 Milan Milanovic
>>>>> <milanmilanovich@(protected)>:
>>>>> >>
>>>>> >> Hi Gabriel,
>>>>> >>
>>>>> >> no I cannot do this because my field is of type
>>>>> BigDecimal and I must
>>>>> >> have
>>>>> >> get/set methods for it.
>>>>> >>
>>>>> >> --
>>>>> >> Thx, Milan
>>>>> >>
>>>>> >>
>>>>> >> Gabriel Belingueres-2 wrote:
>>>>> >>>
>>>>> >>> instead of:
>>>>> >>>
>>>>> >>> public vlid setInValue(BigDecimal x) {
>>>>> >>> this.x = x;
>>>>> >>> }
>>>>> >>>
>>>>> >>> test with this:
>>>>> >>>
>>>>> >>> public vlid setInValue(String s) {
>>>>> >>> this.x = new BigDecimal(s);
>>>>> >>> }
>>>>> >>>
>>>>> >>>
>>>>> >>> 2008/7/24 Milan Milanovic
>>>>> <milanmilanovich@(protected)>:
>>>>> >>>>
>>>>> >>>> Hi Jim,
>>>>> >>>>
>>>>> >>>> no, I have that method.
>>>>> >>>>
>>>>> >>>> --
>>>>> >>>> Thx, Milan
>>>>> >>>>
>>>>> >>>>
>>>>> >>>> Jim Kiley wrote:
>>>>> >>>>>
>>>>> >>>>> Doesn't that exception usually get
>>>>> thrown when, in this case,
>>>>> >>>>> ViewAction
>>>>> >>>>> doesn't have a setInValue()
>>>>> method?
>>>>> >>>>>
>>>>> >>>>> jk
>>>>> >>>>>
>>>>> >>>>> On Thu, Jul 24, 2008 at 10:31 AM,
>>>>> Gabriel Belingueres
>>>>> >>>>> <belingueres@(protected)>
>>>>> >>>>> wrote:
>>>>> >>>>>
>>>>> >>>>>> Which is the data type of inValue?
>>>>> >>>>>>
>>>>> >>>>>> 2008/7/24 Milan Milanovic
>>>>> <milanmilanovich@(protected)>:
>>>>> >>>>>> >
>>>>> >>>>>> > Hi,
>>>>> >>>>>> >
>>>>> >>>>>> > I have one form with multiple
>>>>> textfields, and I want to one of that
>>>>> >>>>>> > textfield be optional for
>>>>> user, i.e., he doesn't need to enter
>>>>> >>>>>> information
>>>>> >>>>>> > in that particular field.
>>>>> Now, when user don't enter I get this in
>>>>> >>>>>> my
>>>>> >>>>>> log:
>>>>> >>>>>> >
>>>>> >>>>>> > ERROR
>>>>>
com.opensymphony.xwork2.interceptor.ParametersInterceptor:204
>>>>> >>>>>> -
>>>>> >>>>>> > ParametersInterceptor -
>>>>> [setParameters]: Unexpected Exception
>>>>> >>>>>> caught
>>>>> >>>>>> setting
>>>>> >>>>>> > 'inValue' on
>>>>> 'class com.myProject.action.ViewAction: Error setting
>>>>> >>>>>> > expression 'inValue'
>>>>> with value '[Ljava.lang.String;@(protected)'
>>>>> >>>>>> >
>>>>> >>>>>> > How can I enable this but
>>>>> without getting this error ?
>>>>> >>>>>> >
>>>>> >>>>>> > --
>>>>> >>>>>> > Thx, Milan
>>>>> >>>>>> > --
>>>>> >>>>>> > View this message in context:
>>>>> >>>>>>
>>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18632806.html
>>>>> >>>>>> > Sent from the Struts - User
>>>>> mailing list archive at Nabble.com.
>>>>> >>>>>> >
>>>>> >>>>>> >
>>>>> >>>>>> >
>>>>> >>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> >>>>>> > To unsubscribe, e-mail:
>>>>> user-unsubscribe@(protected)
>>>>> >>>>>> > For additional commands,
>>>>> e-mail: user-help@(protected)
>>>>> >>>>>> >
>>>>> >>>>>> >
>>>>> >>>>>>
>>>>> >>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> >>>>>> To unsubscribe, e-mail:
>>>>> user-unsubscribe@(protected)
>>>>> >>>>>> For additional commands, e-mail:
>>>>> user-help@(protected)
>>>>> >>>>>>
>>>>> >>>>>>
>>>>> >>>>>
>>>>> >>>>>
>>>>> >>>>> --
>>>>> >>>>> Jim Kiley
>>>>> >>>>> Technical Consultant | Summa
>>>>> >>>>> [p] 412.258.3346 [m] 412.445.1729
>>>>> >>>>> http://www.summa-tech.com
>>>>> >>>>>
>>>>> >>>>>
>>>>> >>>>
>>>>> >>>> --
>>>>> >>>> View this message in context:
>>>>> >>>>
>>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18633474.html
>>>>> >>>> Sent from the Struts - User mailing list
>>>>> archive at Nabble.com.
>>>>> >>>>
>>>>> >>>>
>>>>> >>>>
>>>>> ---------------------------------------------------------------------
>>>>> >>>> To unsubscribe, e-mail:
>>>>> user-unsubscribe@(protected)
>>>>> >>>> For additional commands, e-mail:
>>>>> user-help@(protected)
>>>>> >>>>
>>>>> >>>>
>>>>> >>>
>>>>> >>>
>>>>> ---------------------------------------------------------------------
>>>>> >>> To unsubscribe, e-mail:
>>>>> user-unsubscribe@(protected)
>>>>> >>> For additional commands, e-mail:
>>>>> user-help@(protected)
>>>>> >>>
>>>>> >>>
>>>>> >>>
>>>>> >>
>>>>> >> --
>>>>> >> View this message in context:
>>>>> >>
>>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18633888.html
>>>>> >> Sent from the Struts - User mailing list archive
>>>>> at Nabble.com.
>>>>> >>
>>>>> >>
>>>>> >>
>>>>> ---------------------------------------------------------------------
>>>>> >> To unsubscribe, e-mail:
>>>>> user-unsubscribe@(protected)
>>>>> >> For additional commands, e-mail:
>>>>> user-help@(protected)
>>>>> >>
>>>>> >>
>>>>> >
>>>>> >
>>>>> ---------------------------------------------------------------------
>>>>> > To unsubscribe, e-mail:
>>>>> user-unsubscribe@(protected)
>>>>> > For additional commands, e-mail:
>>>>> user-help@(protected)
>>>>> >
>>>>> >
>>>>> >
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18634541.html
>>>>> Sent from the Struts - User mailing list archive at
>>>>> Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>>>> For additional commands, e-mail:
>>>>> user-help@(protected)
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>>> For additional commands, e-mail: user-help@(protected)
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18634840.html
>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>> For additional commands, e-mail: user-help@(protected)
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18635312.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment:
user_189291.ezm (zipped)Dear Gabriel,
You mean in my action class ?
--
Milan
Gabriel Belingueres-2 wrote:
>
> You don't need to modify your model, just delegate to it:
> public void setValue(String s) {
> if (!StringUtils.isBlank(s)) {
> try {
> model.setValue(new BigDecimal(s));
> catch(NumberFormatException e) {
> model.setValue(null);
> }
> }
> }
>
> 2008/7/24 Milan Milanovic <milanmilanovich@(protected)>:
>>
>> Dear Gabriel,
>>
>> thank you. I tried without my Converter class for BigDecimal and it is
>> the
>> same, when user doesn't enter value I got that error in a log.
>>
>> I'm using S2 2.0.11.1. This solution is good, but my value that is set
>> comes
>> from model where I have class and attribute (BigDecimal) with its get/set
>> methods, by putting this set(String) instead of set(BigDecimal) I'm
>> violating class semantics ?
>>
>> The other solution is O.K., but I've already used it with Dates and
>> datetimepicker. Can I change in some way this BigDecimal converter to
>> avoid
>> this error:
>> http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html
>> http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html
>>
>> --
>> Regards, Milan.
>>
>>
>>
>>
>> Gabriel Belingueres-2 wrote:
>>>
>>> I'm using S2.1.2 (are you using the same version?), and it will throw
>>> a NumberFormatException when setting an empty string, but this
>>> workaround will make ParameterInterceptor to think it is setting a
>>> String parameter:
>>>
>>> public void setValue(String s) {
>>> if (!StringUtils.isBlank(s)) {
>>> try {
>>> this.value= new BigDecimal(s);
>>> catch(NumberFormatException e) {
>>> this.value = null;
>>> }
>>> }
>>> }
>>>
>>> of course you still need a validator so that the string doesn't
>>> violate the BigDecimal grammar.
>>>
>>> Other option (may be more clean) is the action having both the string
>>> instance and the real BigDecimal instance, then the form will only set
>>> the string instance.
>>>
>>> 2008/7/24 Milan Milanovic <milanmilanovich@(protected)>:
>>>>
>>>> Dear Newton,
>>>>
>>>> Yes, I'm using BigDecimal type converter given here:
>>>> http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html
>>>> http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html
>>>> .
>>>>
>>>> --
>>>> Thx, Milan
>>>>
>>>>
>>>> newton.dave wrote:
>>>>>
>>>>> Are you using a BigDecimal type converter (one of which was just
>>>>> posted)?
>>>>>
>>>>> AFAIK it won't work w/o the converter, but I could be remembering
>>>>> incorrectly.
>>>>>
>>>>> Dave
>>>>>
>>>>> --- On Thu, 7/24/08, Milan Milanovic <milanmilanovich@(protected)>
>>>>> wrote:
>>>>>
>>>>>> From: Milan Milanovic <milanmilanovich@(protected)>
>>>>>> Subject: Re: [s2] Making textfield input optional
>>>>>> To: user@(protected)
>>>>>> Date: Thursday, July 24, 2008, 11:36 AM
>>>>>> Dear Gabriel,
>>>>>>
>>>>>> no, my actual question is related to the issue when user
>>>>>> doesn't enter
>>>>>> anything to the textfield which is connected to BigDecimal
>>>>>> in my action
>>>>>> class.
>>>>>>
>>>>>> --
>>>>>> Thx, Milan
>>>>>>
>>>>>>
>>>>>>
>>>>>> Gabriel Belingueres-2 wrote:
>>>>>> >
>>>>>> > Please make sure that the input string is according
>>>>>> the BigDecimal format:
>>>>>> >
>>>>>> http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#BigDecimal(
java.lang.String)
>>>>>> >
>>>>>> > 2008/7/24 Milan Milanovic
>>>>>> <milanmilanovich@(protected)>:
>>>>>> >>
>>>>>> >> Hi Gabriel,
>>>>>> >>
>>>>>> >> no I cannot do this because my field is of type
>>>>>> BigDecimal and I must
>>>>>> >> have
>>>>>> >> get/set methods for it.
>>>>>> >>
>>>>>> >> --
>>>>>> >> Thx, Milan
>>>>>> >>
>>>>>> >>
>>>>>> >> Gabriel Belingueres-2 wrote:
>>>>>> >>>
>>>>>> >>> instead of:
>>>>>> >>>
>>>>>> >>> public vlid setInValue(BigDecimal x) {
>>>>>> >>> this.x = x;
>>>>>> >>> }
>>>>>> >>>
>>>>>> >>> test with this:
>>>>>> >>>
>>>>>> >>> public vlid setInValue(String s) {
>>>>>> >>> this.x = new BigDecimal(s);
>>>>>> >>> }
>>>>>> >>>
>>>>>> >>>
>>>>>> >>> 2008/7/24 Milan Milanovic
>>>>>> <milanmilanovich@(protected)>:
>>>>>> >>>>
>>>>>> >>>> Hi Jim,
>>>>>> >>>>
>>>>>> >>>> no, I have that method.
>>>>>> >>>>
>>>>>> >>>> --
>>>>>> >>>> Thx, Milan
>>>>>> >>>>
>>>>>> >>>>
>>>>>> >>>> Jim Kiley wrote:
>>>>>> >>>>>
>>>>>> >>>>> Doesn't that exception usually get
>>>>>> thrown when, in this case,
>>>>>> >>>>> ViewAction
>>>>>> >>>>> doesn't have a setInValue()
>>>>>> method?
>>>>>> >>>>>
>>>>>> >>>>> jk
>>>>>> >>>>>
>>>>>> >>>>> On Thu, Jul 24, 2008 at 10:31 AM,
>>>>>> Gabriel Belingueres
>>>>>> >>>>> <belingueres@(protected)>
>>>>>> >>>>> wrote:
>>>>>> >>>>>
>>>>>> >>>>>> Which is the data type of inValue?
>>>>>> >>>>>>
>>>>>> >>>>>> 2008/7/24 Milan Milanovic
>>>>>> <milanmilanovich@(protected)>:
>>>>>> >>>>>> >
>>>>>> >>>>>> > Hi,
>>>>>> >>>>>> >
>>>>>> >>>>>> > I have one form with multiple
>>>>>> textfields, and I want to one of that
>>>>>> >>>>>> > textfield be optional for
>>>>>> user, i.e., he doesn't need to enter
>>>>>> >>>>>> information
>>>>>> >>>>>> > in that particular field.
>>>>>> Now, when user don't enter I get this in
>>>>>> >>>>>> my
>>>>>> >>>>>> log:
>>>>>> >>>>>> >
>>>>>> >>>>>> > ERROR
>>>>>>
com.opensymphony.xwork2.interceptor.ParametersInterceptor:204
>>>>>> >>>>>> -
>>>>>> >>>>>> > ParametersInterceptor -
>>>>>> [setParameters]: Unexpected Exception
>>>>>> >>>>>> caught
>>>>>> >>>>>> setting
>>>>>> >>>>>> > 'inValue' on
>>>>>> 'class com.myProject.action.ViewAction: Error setting
>>>>>> >>>>>> > expression 'inValue'
>>>>>> with value '[Ljava.lang.String;@(protected)'
>>>>>> >>>>>> >
>>>>>> >>>>>> > How can I enable this but
>>>>>> without getting this error ?
>>>>>> >>>>>> >
>>>>>> >>>>>> > --
>>>>>> >>>>>> > Thx, Milan
>>>>>> >>>>>> > --
>>>>>> >>>>>> > View this message in context:
>>>>>> >>>>>>
>>>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18632806.html
>>>>>> >>>>>> > Sent from the Struts - User
>>>>>> mailing list archive at Nabble.com.
>>>>>> >>>>>> >
>>>>>> >>>>>> >
>>>>>> >>>>>> >
>>>>>> >>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> >>>>>> > To unsubscribe, e-mail:
>>>>>> user-unsubscribe@(protected)
>>>>>> >>>>>> > For additional commands,
>>>>>> e-mail: user-help@(protected)
>>>>>> >>>>>> >
>>>>>> >>>>>> >
>>>>>> >>>>>>
>>>>>> >>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> >>>>>> To unsubscribe, e-mail:
>>>>>> user-unsubscribe@(protected)
>>>>>> >>>>>> For additional commands, e-mail:
>>>>>> user-help@(protected)
>>>>>> >>>>>>
>>>>>> >>>>>>
>>>>>> >>>>>
>>>>>> >>>>>
>>>>>> >>>>> --
>>>>>> >>>>> Jim Kiley
>>>>>> >>>>> Technical Consultant | Summa
>>>>>> >>>>> [p] 412.258.3346 [m] 412.445.1729
>>>>>> >>>>> http://www.summa-tech.com
>>>>>> >>>>>
>>>>>> >>>>>
>>>>>> >>>>
>>>>>> >>>> --
>>>>>> >>>> View this message in context:
>>>>>> >>>>
>>>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18633474.html
>>>>>> >>>> Sent from the Struts - User mailing list
>>>>>> archive at Nabble.com.
>>>>>> >>>>
>>>>>> >>>>
>>>>>> >>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> >>>> To unsubscribe, e-mail:
>>>>>> user-unsubscribe@(protected)
>>>>>> >>>> For additional commands, e-mail:
>>>>>> user-help@(protected)
>>>>>> >>>>
>>>>>> >>>>
>>>>>> >>>
>>>>>> >>>
>>>>>> ---------------------------------------------------------------------
>>>>>> >>> To unsubscribe, e-mail:
>>>>>> user-unsubscribe@(protected)
>>>>>> >>> For additional commands, e-mail:
>>>>>> user-help@(protected)
>>>>>> >>>
>>>>>> >>>
>>>>>> >>>
>>>>>> >>
>>>>>> >> --
>>>>>> >> View this message in context:
>>>>>> >>
>>>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18633888.html
>>>>>> >> Sent from the Struts - User mailing list archive
>>>>>> at Nabble.com.
>>>>>> >>
>>>>>> >>
>>>>>> >>
>>>>>> ---------------------------------------------------------------------
>>>>>> >> To unsubscribe, e-mail:
>>>>>> user-unsubscribe@(protected)
>>>>>> >> For additional commands, e-mail:
>>>>>> user-help@(protected)
>>>>>> >>
>>>>>> >>
>>>>>> >
>>>>>> >
>>>>>> ---------------------------------------------------------------------
>>>>>> > To unsubscribe, e-mail:
>>>>>> user-unsubscribe@(protected)
>>>>>> > For additional commands, e-mail:
>>>>>> user-help@(protected)
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18634541.html
>>>>>> Sent from the Struts - User mailing list archive at
>>>>>> Nabble.com.
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>>>>> For additional commands, e-mail:
>>>>>> user-help@(protected)
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>>>> For additional commands, e-mail: user-help@(protected)
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18634840.html
>>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>>> For additional commands, e-mail: user-help@(protected)
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>> For additional commands, e-mail: user-help@(protected)
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18635312.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_189292.ezm (zipped)Yes, you need to write this setter in your action class.
2008/7/24 Milan Milanovic <milanmilanovich@(protected)>:
>
> Dear Gabriel,
>
> You mean in my action class ?
>
> --
> Milan
>
>
> Gabriel Belingueres-2 wrote:
>>
>> You don't need to modify your model, just delegate to it:
>> public void setValue(String s) {
>> if (!StringUtils.isBlank(s)) {
>> try {
>> model.setValue(new BigDecimal(s));
>> catch(NumberFormatException e) {
>> model.setValue(null);
>> }
>> }
>> }
>>
>> 2008/7/24 Milan Milanovic <milanmilanovich@(protected)>:
>>>
>>> Dear Gabriel,
>>>
>>> thank you. I tried without my Converter class for BigDecimal and it is
>>> the
>>> same, when user doesn't enter value I got that error in a log.
>>>
>>> I'm using S2 2.0.11.1. This solution is good, but my value that is set
>>> comes
>>> from model where I have class and attribute (BigDecimal) with its get/set
>>> methods, by putting this set(String) instead of set(BigDecimal) I'm
>>> violating class semantics ?
>>>
>>> The other solution is O.K., but I've already used it with Dates and
>>> datetimepicker. Can I change in some way this BigDecimal converter to
>>> avoid
>>> this error:
>>> http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html
>>> http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html
>>>
>>> --
>>> Regards, Milan.
>>>
>>>
>>>
>>>
>>> Gabriel Belingueres-2 wrote:
>>>>
>>>> I'm using S2.1.2 (are you using the same version?), and it will throw
>>>> a NumberFormatException when setting an empty string, but this
>>>> workaround will make ParameterInterceptor to think it is setting a
>>>> String parameter:
>>>>
>>>> public void setValue(String s) {
>>>> if (!StringUtils.isBlank(s)) {
>>>> try {
>>>> this.value= new BigDecimal(s);
>>>> catch(NumberFormatException e) {
>>>> this.value = null;
>>>> }
>>>> }
>>>> }
>>>>
>>>> of course you still need a validator so that the string doesn't
>>>> violate the BigDecimal grammar.
>>>>
>>>> Other option (may be more clean) is the action having both the string
>>>> instance and the real BigDecimal instance, then the form will only set
>>>> the string instance.
>>>>
>>>> 2008/7/24 Milan Milanovic <milanmilanovich@(protected)>:
>>>>>
>>>>> Dear Newton,
>>>>>
>>>>> Yes, I'm using BigDecimal type converter given here:
>>>>> http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html
>>>>> http://www.nabble.com/-s2--Formatting-input-textfields-tt18593985.html
>>>>> .
>>>>>
>>>>> --
>>>>> Thx, Milan
>>>>>
>>>>>
>>>>> newton.dave wrote:
>>>>>>
>>>>>> Are you using a BigDecimal type converter (one of which was just
>>>>>> posted)?
>>>>>>
>>>>>> AFAIK it won't work w/o the converter, but I could be remembering
>>>>>> incorrectly.
>>>>>>
>>>>>> Dave
>>>>>>
>>>>>> --- On Thu, 7/24/08, Milan Milanovic <milanmilanovich@(protected)>
>>>>>> wrote:
>>>>>>
>>>>>>> From: Milan Milanovic <milanmilanovich@(protected)>
>>>>>>> Subject: Re: [s2] Making textfield input optional
>>>>>>> To: user@(protected)
>>>>>>> Date: Thursday, July 24, 2008, 11:36 AM
>>>>>>> Dear Gabriel,
>>>>>>>
>>>>>>> no, my actual question is related to the issue when user
>>>>>>> doesn't enter
>>>>>>> anything to the textfield which is connected to BigDecimal
>>>>>>> in my action
>>>>>>> class.
>>>>>>>
>>>>>>> --
>>>>>>> Thx, Milan
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Gabriel Belingueres-2 wrote:
>>>>>>> >
>>>>>>> > Please make sure that the input string is according
>>>>>>> the BigDecimal format:
>>>>>>> >
>>>>>>> http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#BigDecimal(
java.lang.String)
>>>>>>> >
>>>>>>> > 2008/7/24 Milan Milanovic
>>>>>>> <milanmilanovich@(protected)>:
>>>>>>> >>
>>>>>>> >> Hi Gabriel,
>>>>>>> >>
>>>>>>> >> no I cannot do this because my field is of type
>>>>>>> BigDecimal and I must
>>>>>>> >> have
>>>>>>> >> get/set methods for it.
>>>>>>> >>
>>>>>>> >> --
>>>>>>> >> Thx, Milan
>>>>>>> >>
>>>>>>> >>
>>>>>>> >> Gabriel Belingueres-2 wrote:
>>>>>>> >>>
>>>>>>> >>> instead of:
>>>>>>> >>>
>>>>>>> >>> public vlid setInValue(BigDecimal x) {
>>>>>>> >>> this.x = x;
>>>>>>> >>> }
>>>>>>> >>>
>>>>>>> >>> test with this:
>>>>>>> >>>
>>>>>>> >>> public vlid setInValue(String s) {
>>>>>>> >>> this.x = new BigDecimal(s);
>>>>>>> >>> }
>>>>>>> >>>
>>>>>>> >>>
>>>>>>> >>> 2008/7/24 Milan Milanovic
>>>>>>> <milanmilanovich@(protected)>:
>>>>>>> >>>>
>>>>>>> >>>> Hi Jim,
>>>>>>> >>>>
>>>>>>> >>>> no, I have that method.
>>>>>>> >>>>
>>>>>>> >>>> --
>>>>>>> >>>> Thx, Milan
>>>>>>> >>>>
>>>>>>> >>>>
>>>>>>> >>>> Jim Kiley wrote:
>>>>>>> >>>>>
>>>>>>> >>>>> Doesn't that exception usually get
>>>>>>> thrown when, in this case,
>>>>>>> >>>>> ViewAction
>>>>>>> >>>>> doesn't have a setInValue()
>>>>>>> method?
>>>>>>> >>>>>
>>>>>>> >>>>> jk
>>>>>>> >>>>>
>>>>>>> >>>>> On Thu, Jul 24, 2008 at 10:31 AM,
>>>>>>> Gabriel Belingueres
>>>>>>> >>>>> <belingueres@(protected)>
>>>>>>> >>>>> wrote:
>>>>>>> >>>>>
>>>>>>> >>>>>> Which is the data type of inValue?
>>>>>>> >>>>>>
>>>>>>> >>>>>> 2008/7/24 Milan Milanovic
>>>>>>> <milanmilanovich@(protected)>:
>>>>>>> >>>>>> >
>>>>>>> >>>>>> > Hi,
>>>>>>> >>>>>> >
>>>>>>> >>>>>> > I have one form with multiple
>>>>>>> textfields, and I want to one of that
>>>>>>> >>>>>> > textfield be optional for
>>>>>>> user, i.e., he doesn't need to enter
>>>>>>> >>>>>> information
>>>>>>> >>>>>> > in that particular field.
>>>>>>> Now, when user don't enter I get this in
>>>>>>> >>>>>> my
>>>>>>> >>>>>> log:
>>>>>>> >>>>>> >
>>>>>>> >>>>>> > ERROR
>>>>>>>
com.opensymphony.xwork2.interceptor.ParametersInterceptor:204
>>>>>>> >>>>>> -
>>>>>>> >>>>>> > ParametersInterceptor -
>>>>>>> [setParameters]: Unexpected Exception
>>>>>>> >>>>>> caught
>>>>>>> >>>>>> setting
>>>>>>> >>>>>> > 'inValue' on
>>>>>>> 'class com.myProject.action.ViewAction: Error setting
>>>>>>> >>>>>> > expression 'inValue'
>>>>>>> with value '[Ljava.lang.String;@(protected)'
>>>>>>> >>>>>> >
>>>>>>> >>>>>> > How can I enable this but
>>>>>>> without getting this error ?
>>>>>>> >>>>>> >
>>>>>>> >>>>>> > --
>>>>>>> >>>>>> > Thx, Milan
>>>>>>> >>>>>> > --
>>>>>>> >>>>>> > View this message in context:
>>>>>>> >>>>>>
>>>>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18632806.html
>>>>>>> >>>>>> > Sent from the Struts - User
>>>>>>> mailing list archive at Nabble.com.
>>>>>>> >>>>>> >
>>>>>>> >>>>>> >
>>>>>>> >>>>>> >
>>>>>>> >>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> >>>>>> > To unsubscribe, e-mail:
>>>>>>> user-unsubscribe@(protected)
>>>>>>> >>>>>> > For additional commands,
>>>>>>> e-mail: user-help@(protected)
>>>>>>> >>>>>> >
>>>>>>> >>>>>> >
>>>>>>> >>>>>>
>>>>>>> >>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> >>>>>> To unsubscribe, e-mail:
>>>>>>> user-unsubscribe@(protected)
>>>>>>> >>>>>> For additional commands, e-mail:
>>>>>>> user-help@(protected)
>>>>>>> >>>>>>
>>>>>>> >>>>>>
>>>>>>> >>>>>
>>>>>>> >>>>>
>>>>>>> >>>>> --
>>>>>>> >>>>> Jim Kiley
>>>>>>> >>>>> Technical Consultant | Summa
>>>>>>> >>>>> [p] 412.258.3346 [m] 412.445.1729
>>>>>>> >>>>> http://www.summa-tech.com
>>>>>>> >>>>>
>>>>>>> >>>>>
>>>>>>> >>>>
>>>>>>> >>>> --
>>>>>>> >>>> View this message in context:
>>>>>>> >>>>
>>>>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18633474.html
>>>>>>> >>>> Sent from the Struts - User mailing list
>>>>>>> archive at Nabble.com.
>>>>>>> >>>>
>>>>>>> >>>>
>>>>>>> >>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> >>>> To unsubscribe, e-mail:
>>>>>>> user-unsubscribe@(protected)
>>>>>>> >>>> For additional commands, e-mail:
>>>>>>> user-help@(protected)
>>>>>>> >>>>
>>>>>>> >>>>
>>>>>>> >>>
>>>>>>> >>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> >>> To unsubscribe, e-mail:
>>>>>>> user-unsubscribe@(protected)
>>>>>>> >>> For additional commands, e-mail:
>>>>>>> user-help@(protected)
>>>>>>> >>>
>>>>>>> >>>
>>>>>>> >>>
>>>>>>> >>
>>>>>>> >> --
>>>>>>> >> View this message in context:
>>>>>>> >>
>>>>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18633888.html
>>>>>>> >> Sent from the Struts - User mailing list archive
>>>>>>> at Nabble.com.
>>>>>>> >>
>>>>>>> >>
>>>>>>> >>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> >> To unsubscribe, e-mail:
>>>>>>> user-unsubscribe@(protected)
>>>>>>> >> For additional commands, e-mail:
>>>>>>> user-help@(protected)
>>>>>>> >>
>>>>>>> >>
>>>>>>> >
>>>>>>> >
>>>>>>> ---------------------------------------------------------------------
>>>>>>> > To unsubscribe, e-mail:
>>>>>>> user-unsubscribe@(protected)
>>>>>>> > For additional commands, e-mail:
>>>>>>> user-help@(protected)
>>>>>>> >
>>>>>>> >
>>>>>>> >
>>>>>>>
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18634541.html
>>>>>>> Sent from the Struts - User mailing list archive at
>>>>>>> Nabble.com.
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>>>>>> For additional commands, e-mail:
>>>>>>> user-help@(protected)
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>>>>> For additional commands, e-mail: user-help@(protected)
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/-s2--Making-textfield-input-optional-tp18632806p18634840.html
>>>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>>>> For additional commands, e-mail: user-help@(protected)
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>>> For additional commands, e-mail: user-help@(protected)
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/-s2--Making-textfield-input-optional