You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Neil Aggarwal <ne...@JAMMConsulting.com> on 2007/08/01 21:19:54 UTC

[S2] How to apply formatting to s:property?

Hello:

I am trying to apply formatting to a value
from s:property.

I tried this:

<s:text name="format.currency"><s:property
value="retailProductsCount"/></s:text>

but that did not format the value.  It only outputs
it unchanged.

Any ideas how to do this?

Thanks,	
	Neil


--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] How to apply formatting to s:property?

Posted by Dave Newton <ne...@yahoo.com>.
--- Neil Aggarwal <ne...@JAMMConsulting.com> wrote:
> I am trying to apply formatting to a value
> from s:property.
> 
> I tried this:
> 
> <s:text name="format.currency"><s:property
> value="retailProductsCount"/></s:text>
> 
> but that did not format the value.  It only outputs
> it unchanged.

What does your format.currency property look like?

d.



      ____________________________________________________________________________________
Shape Yahoo! in your own image.  Join our Network Research Panel today!   http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE [S2] Bug v2.1.0 for double and int validation

Posted by ML...@abusinessware.com.
Same with int validation.

        <field name="familleProduit.chargeTravail">
        <field-validator type="int">
            <message key="errors.int"/>
        </field-validator>
    </field>

generates :
        // field name: familleProduit.chargeTravail
        // validator name: int
        if (form.elements['familleProduit.chargeTravail']) {
            field = form.elements['familleProduit.chargeTravail'];
            var error = "Le champ doit être un entier";
            if (field.value != null) {
                var value = parseFloat(field.value);
                if (false ||
                        false) {
                    addError(field, error);
                    errors = true;
                }
            }
        }





MLENEVEUT@abusinessware.com 
02/08/2007 16:52
Veuillez répondre à
"Struts Users Mailing List" <us...@struts.apache.org>


A
"Struts Users Mailing List" <us...@struts.apache.org>
cc

Objet
[S2] Bug v2.1.0 double validation






Hi,

I try to validate a double, but it generates this in my JSP :

        // field name: familleProduit.chargeTravail
        // validator name: double
        if (form.elements['familleProduit.chargeTravail']) {
            field = form.elements['familleProduit.chargeTravail'];
            var error = "Le champ doit être un décimal";
            if (field.value != null) {
                var value = parseFloat(field.value);
                if (false ||
                        false ||
                        false ||
                        false) {
                    addError(field, error);
                    errors = true;
                }
            }
        }

So the double is not tested.

my xxAction-validation.xml :
<validators>
    <field name="familleProduit.nomFamille">
        <field-validator type="requiredstring">
                        <param name="trim">true</param>
            <message key="errors.required"/>
        </field-validator>
    </field>
    <field name="familleProduit.chargeTravail">
        <field-validator type="double">
            <message key="errors.double"/>
        </field-validator>
    </field>
    <field name="familleProduit.gamme.idGamme">
        <field-validator type="requiredstring">
                        <param name="trim">true</param>
            <message key="errors.required"/>
        </field-validator>
    </field>
</validators>


[S2] Bug v2.1.0 double validation

Posted by ML...@abusinessware.com.
Hi,

I try to validate a double, but it generates this in my JSP :

        // field name: familleProduit.chargeTravail
        // validator name: double
        if (form.elements['familleProduit.chargeTravail']) {
            field = form.elements['familleProduit.chargeTravail'];
            var error = "Le champ doit être un décimal";
            if (field.value != null) {
                var value = parseFloat(field.value);
                if (false ||
                        false ||
                        false ||
                        false) {
                    addError(field, error);
                    errors = true;
                }
            }
        }

So the double is not tested.

my xxAction-validation.xml :
<validators>
    <field name="familleProduit.nomFamille">
        <field-validator type="requiredstring">
                        <param name="trim">true</param>
            <message key="errors.required"/>
        </field-validator>
    </field>
    <field name="familleProduit.chargeTravail">
        <field-validator type="double">
            <message key="errors.double"/>
        </field-validator>
    </field>
    <field name="familleProduit.gamme.idGamme">
        <field-validator type="requiredstring">
                        <param name="trim">true</param>
            <message key="errors.required"/>
        </field-validator>
    </field>
</validators>

RE: [S2] How to apply formatting to s:property?

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Dave:

Arrgh.  I just figured it out.

I need to set the constant to the name of
the file *without* the .properties extension.

So, in struts.xml, I put this:

<constant name="struts.custom.i18n.resources" value="application"/>

and it loads application.properties just fine.

Thank you for your help on this.

Thanks,
	Neil


--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.

-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Thursday, August 02, 2007 10:55 AM
To: Struts Users Mailing List
Subject: RE: [S2] How to apply formatting to s:property?

I'm not sure why the global resources property setting
doesn't work, although I would suspect a property file
naming / location / packaging issue. Comments on
https://issues.apache.org/struts/browse/WW-1647
suggests that it works.

d.



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: [S2] How to apply formatting to s:property?

Posted by Dave Newton <ne...@yahoo.com>.
--- Neil Aggarwal <ne...@JAMMConsulting.com> wrote:
> I tried moving the package.properties to
> WEB-INF/classes so it would be application
> wide but that seems to be ignored.

Hmm, I guess I would have thought that would work, but
I've never tried.

> I would still really like a way to make a global
> properties file if possible.  Any suggestions on how

> to do that?

If everything extends ActionSupport (my actions do,
out of convenience) you can put it in the
com.opensymphony.xwork2.ActionSupport package.

I'm not sure why the global resources property setting
doesn't work, although I would suspect a property file
naming / location / packaging issue. Comments on
https://issues.apache.org/struts/browse/WW-1647
suggests that it works.

d.



      ____________________________________________________________________________________
Shape Yahoo! in your own image.  Join our Network Research Panel today!   http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: [S2] How to apply formatting to s:property?

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Dave:

Thanks for getting back to me.  I was not
assuming you were available 24x7.  I just
wondered if you were frustrated by my
inexperience.   

I put a package.properties file in my
WEB-INF/classes/page directory since that
is the package that contains the action class.
It works perfectly!  Thanks for that.

I tried moving the package.properties to
WEB-INF/classes so it would be application
wide but that seems to be ignored.

I would still really like a way to make a global
properties file if possible.  Any
suggestions on how to do that?

Thanks,
	Neil

--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.

-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Thursday, August 02, 2007 9:12 AM
To: Struts Users Mailing List
Subject: RE: [S2] How to apply formatting to s:property?

I haven't done anything with setting the
i18n.resources property, so I can't help you with
that. I'm not sure why you don't just put something in
to a package.properties (it's hierarchical, you can
put it anywhere) or ActionSupport.properties, etc.

I've never run an app w/o the i18n interceptor so I
don't know what effect (if any) that would have.

I would start by doing what it says on the
localization page as a sanity check *then* start to
play configuration / etc. games.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: [S2] How to apply formatting to s:property?

Posted by Dave Newton <ne...@yahoo.com>.
--- Neil Aggarwal <ne...@JAMMConsulting.com> wrote:
> Did you give up on this?

No, I'm just not actually physically attached to my
computer and teh intarwebs 24/7 and the boss keeps
blathering on and on about some sort of "do stuff for
me" BS.

I haven't done anything with setting the
i18n.resources property, so I can't help you with
that. I'm not sure why you don't just put something in
to a package.properties (it's hierarchical, you can
put it anywhere) or ActionSupport.properties, etc.

I've never run an app w/o the i18n interceptor so I
don't know what effect (if any) that would have.

I would start by doing what it says on the
localization page as a sanity check *then* start to
play configuration / etc. games.

d.

> From: Neil Aggarwal [mailto:neil@jammconsulting.com]
> Sent: Wednesday, August 01, 2007 3:23 PM
> Subject: RE: [S2] How to apply formatting to
> s:property?
> 
> Dave:
> 
> OK, so I added this to my struts.xml:
> 
> <constant name="struts.custom.i18n.resources"
> value="application.properties"/>
> 
> and I defined application.properties with this
> content:
> 
> format.money={0,number,currency} 
> 
> But, I still get format.money for the output.
> 
> Do I need to use the Il8n interceptor somewhere?
> 
> Thanks,
> 	Neil
> 
> --
> Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
> FREE! Eliminate junk email and reclaim your inbox.
> Visit http://www.spammilter.com for details.
> 
> -----Original Message-----
> From: Dave Newton [mailto:newton.dave@yahoo.com] 
> Sent: Wednesday, August 01, 2007 3:10 PM
> To: Struts Users Mailing List
> Subject: RE: [S2] How to apply formatting to
> s:property?
> 
> --- Neil Aggarwal <ne...@JAMMConsulting.com> wrote:
> > So, is there no way to define a global format
> > for currency?
> 
> http://struts.apache.org/2.x/docs/localization.html
> 
> d.
> 
> 
> 
>  
>
____________________________________________________________________________
> ________
> Fussy? Opinionated? Impossible to please? Perfect. 
> Join Yahoo!'s user panel
> and lay it on us.
>
http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org
> 
> 



      ____________________________________________________________________________________
Shape Yahoo! in your own image.  Join our Network Research Panel today!   http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: [S2] How to apply formatting to s:property?

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Dave:

Did you give up on this?

	Neil 


--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.

-----Original Message-----
From: Neil Aggarwal [mailto:neil@jammconsulting.com] 
Sent: Wednesday, August 01, 2007 3:23 PM
To: 'Struts Users Mailing List'
Subject: RE: [S2] How to apply formatting to s:property?

Dave:

OK, so I added this to my struts.xml:

<constant name="struts.custom.i18n.resources"
value="application.properties"/>

and I defined application.properties with this
content:

format.money={0,number,currency} 

But, I still get format.money for the output.

Do I need to use the Il8n interceptor somewhere?

Thanks,
	Neil

--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.

-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Wednesday, August 01, 2007 3:10 PM
To: Struts Users Mailing List
Subject: RE: [S2] How to apply formatting to s:property?

--- Neil Aggarwal <ne...@JAMMConsulting.com> wrote:
> So, is there no way to define a global format
> for currency?

http://struts.apache.org/2.x/docs/localization.html

d.



 
____________________________________________________________________________
________
Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel
and lay it on us.
http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: [S2] How to apply formatting to s:property?

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Dave:

OK, so I added this to my struts.xml:

<constant name="struts.custom.i18n.resources"
value="application.properties"/>

and I defined application.properties with this
content:

format.money={0,number,currency} 

But, I still get format.money for the output.

Do I need to use the Il8n interceptor somewhere?

Thanks,
	Neil

--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.

-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Wednesday, August 01, 2007 3:10 PM
To: Struts Users Mailing List
Subject: RE: [S2] How to apply formatting to s:property?

--- Neil Aggarwal <ne...@JAMMConsulting.com> wrote:
> So, is there no way to define a global format
> for currency?

http://struts.apache.org/2.x/docs/localization.html

d.



 
____________________________________________________________________________
________
Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel
and lay it on us.
http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: [S2] How to apply formatting to s:property?

Posted by Dave Newton <ne...@yahoo.com>.
--- Neil Aggarwal <ne...@JAMMConsulting.com> wrote:
> So, is there no way to define a global format
> for currency?

http://struts.apache.org/2.x/docs/localization.html

d.



      ____________________________________________________________________________________
Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: [S2] How to apply formatting to s:property?

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Dave:

So, is there no way to define a global format
for currency?

Thanks,
	Neil 

--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.

-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Wednesday, August 01, 2007 2:56 PM
To: Struts Users Mailing List
Subject: RE: [S2] How to apply formatting to s:property?

--- Neil Aggarwal <ne...@JAMMConsulting.com> wrote:
> I moved it to a struts.properties file:
> 
> format.money={0,number,currency}
> 
> with no change to the output.
> 
> Also, according to this page, I should be able
> to put it in either struts.xml or struts.properties:
> 
>
http://struts.apache.org/2.x/docs/constant-configuration.html
> 
> Any ideas?

Yes.

Put it in a properties file used by an *action*, not
an *S2 configuration file*. See, the point of putting
a format into a properties file is so it can be
locale-specific. AFAIK config files are not
localization files.

d.



       
____________________________________________________________________________
________
Choose the right car based on your needs.  Check out Yahoo! Autos new Car
Finder tool.
http://autos.yahoo.com/carfinder/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: [S2] How to apply formatting to s:property?

Posted by Dave Newton <ne...@yahoo.com>.
--- Neil Aggarwal <ne...@JAMMConsulting.com> wrote:
> I moved it to a struts.properties file:
> 
> format.money={0,number,currency}
> 
> with no change to the output.
> 
> Also, according to this page, I should be able
> to put it in either struts.xml or struts.properties:
> 
>
http://struts.apache.org/2.x/docs/constant-configuration.html
> 
> Any ideas?

Yes.

Put it in a properties file used by an *action*, not
an *S2 configuration file*. See, the point of putting
a format into a properties file is so it can be
locale-specific. AFAIK config files are not
localization files.

d.



       
____________________________________________________________________________________
Choose the right car based on your needs.  Check out Yahoo! Autos new Car Finder tool.
http://autos.yahoo.com/carfinder/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: [S2] How to apply formatting to s:property?

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Dave:

I moved it to a struts.properties file:

format.money={0,number,currency}

with no change to the output.

Also, according to this page, I should be able
to put it in either struts.xml or struts.properties:

http://struts.apache.org/2.x/docs/constant-configuration.html

Any ideas?

Thanks,
	Neil 

--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.

-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Wednesday, August 01, 2007 2:42 PM
To: Struts Users Mailing List
Subject: RE: [S2] How to apply formatting to s:property?

--- Neil Aggarwal <ne...@JAMMConsulting.com> wrote:
> <s:text name="format.money"><s:param name="value"
> value="12345"/></s:text>
> 
> The outputs format.money instead of $12.345.00 which
> I expected.
> 
> I defined the format in the struts.xml file like
> this:
> 
> <constant name="format.money"
> value="{0,number,currency}" /> 
> 
> Any ideas?

Try putting it in a properties file.

http://struts.apache.org/2.x/docs/text.html

d.



       
____________________________________________________________________________
________Ready for the edge of your seat? 
Check out tonight's top picks on Yahoo! TV. 
http://tv.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: [S2] How to apply formatting to s:property?

Posted by Dave Newton <ne...@yahoo.com>.
--- Neil Aggarwal <ne...@JAMMConsulting.com> wrote:
> <s:text name="format.money"><s:param name="value"
> value="12345"/></s:text>
> 
> The outputs format.money instead of $12.345.00 which
> I expected.
> 
> I defined the format in the struts.xml file like
> this:
> 
> <constant name="format.money"
> value="{0,number,currency}" /> 
> 
> Any ideas?

Try putting it in a properties file.

http://struts.apache.org/2.x/docs/text.html

d.



       
____________________________________________________________________________________Ready for the edge of your seat? 
Check out tonight's top picks on Yahoo! TV. 
http://tv.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: [S2] How to apply formatting to s:property?

Posted by Neil Aggarwal <ne...@JAMMConsulting.com>.
Hello:

I did some more testing.

I tried this:

<s:text name="format.money"><s:param name="value" value="12345"/></s:text>

The outputs format.money instead of $12.345.00 which
I expected.

I defined the format in the struts.xml file like
this:

<constant name="format.money" value="{0,number,currency}" /> 

Any ideas?

Thanks,
	Neil


--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.
-----Original Message-----
From: Neil Aggarwal [mailto:neil@jammconsulting.com] 
Sent: Wednesday, August 01, 2007 2:20 PM
To: 'Struts Users Mailing List'
Subject: [S2] How to apply formatting to s:property?

Hello:

I am trying to apply formatting to a value
from s:property.

I tried this:

<s:text name="format.currency"><s:property
value="retailProductsCount"/></s:text>

but that did not format the value.  It only outputs
it unchanged.

Any ideas how to do this?

Thanks,	
	Neil


--
Neil Aggarwal, (832)245-7314, www.JAMMConsulting.com
FREE! Eliminate junk email and reclaim your inbox.
Visit http://www.spammilter.com for details.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org