struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Huber <gregh3...@gmail.com>
Subject Re: Struts 2.6
Date Tue, 28 Nov 2017 09:40:39 GMT
... String convertToString(Map arg0, Object arg1) {

Possibly will look into something like this, but its easier for now to use:

value="%{getText('format.double',{bean.size})}"

where

format.double={0,number,##0.0}

ie
<s:textfield accesskey="v" name="bean.size"
value="%{getText('format.double',{bean.size})}" size="5" maxlength="5"
readonly="#readonly" />

Thanks.


On 28 November 2017 at 09:15, Yasser Zamani <yasser.zamani@live.com> wrote:

>
>
> On 11/28/2017 12:36 PM, Greg Huber wrote:
> > where do these live now? does not compile for me.
> >
> > *ThemeDescriptorConverter.java*
> >
> > import org.apache.struts.model.ThemeDescriptor;
> > import org.apache.struts.model.Themes;
>
> No I mentioned those as examples. You instead should write your own,
> like below:
>
> package com.mycompany.blahblah /*update this to your one*/
>
> public class MyDoubleWithDotZeroStringConverter extends
> com.opensymphony.xwork2.conversion.impl.StringConverter
> {
> @Override
>      protected String convertToString(Locale locale, Object value) {
>          if (Double.class.isInstance(value)) {
>              NumberFormat format = NumberFormat.getNumberInstance(locale);
>              format.setGroupingUsed(false);
>              format.setMinimumFractionDigits(1);
>              format.setMaximumFractionDigits(Integer.MAX_VALUE);
>              return format.format(value);
>          } else {
>              return super.convertToString(locale, value);
>          }
>      }
>
> }
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message