You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2016/01/27 20:25:09 UTC

[tools] Problems using struts.MessageTool

All,

Using Velocity-Tools 2.0.

I've got a resource bundle with the following message in it:

text.patient.questionnaires.available=There {0,choice,0#are no
questionnaires|1#is one questionnaire|1<are '<b>'{0}'<b>'
questionnaires} ready to take

(That's all on one single line, in case my emailer wraps it, or maybe
yours does.)

I have a problem where the <b> HTML markup is making ChoiceFormat angry:

Caused by: java.lang.IllegalArgumentException: Choice Pattern incorrect:
0#are no questionnaires|1#is one questionnaire|1<are ''<b>''{0}''<b>''
questionnaires
        at java.text.MessageFormat.makeFormat(MessageFormat.java:1519)
        at java.text.MessageFormat.applyPattern(MessageFormat.java:479)
        at java.text.MessageFormat.<init>(MessageFormat.java:362)
        at
org.apache.struts.util.MessageResources.getMessage(MessageResources.java:305)
        at
org.apache.velocity.tools.struts.MessageTool.get(MessageTool.java:157)
        at
org.apache.velocity.tools.struts.MessageTool.get(MessageTool.java:125)
        at
org.apache.velocity.tools.struts.MessageTool.get(MessageTool.java:191)
[...]

Note that the pattern for the ChoiceFormat has been modified: there are
extra single-quote characters in the format that ChoiceFormat complains
about.

I haven't yet read through all the code, but if this jogs anyone's
memory for why something like this might happen, it would be very
helpful to me.

A couple of notes:

1. I have a custom build of Velocity-Tools, so the line numbers are not
always correct. I have confirmed that my changes do not modify the
message key's value.

2. It looks like in MessageTool.java:157, the value has the expected ...
umm  ... value. That is, it does not have doubled single quotes. So I
think this is almost certainly not Velocity Tools's fault. I may have to
give into the Struts code.

Thanks,
-chris

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


Re: [tools] Problems using struts.MessageTool

Posted by Nathan Bubna <nb...@gmail.com>.
Yeah, MessageTool wouldn't make a transformation like that. Pretty sure
this is a Struts issue. Good luck! :)

On Wed, Jan 27, 2016 at 11:25 AM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> All,
>
> Using Velocity-Tools 2.0.
>
> I've got a resource bundle with the following message in it:
>
> text.patient.questionnaires.available=There {0,choice,0#are no
> questionnaires|1#is one questionnaire|1<are '<b>'{0}'<b>'
> questionnaires} ready to take
>
> (That's all on one single line, in case my emailer wraps it, or maybe
> yours does.)
>
> I have a problem where the <b> HTML markup is making ChoiceFormat angry:
>
> Caused by: java.lang.IllegalArgumentException: Choice Pattern incorrect:
> 0#are no questionnaires|1#is one questionnaire|1<are ''<b>''{0}''<b>''
> questionnaires
>         at java.text.MessageFormat.makeFormat(MessageFormat.java:1519)
>         at java.text.MessageFormat.applyPattern(MessageFormat.java:479)
>         at java.text.MessageFormat.<init>(MessageFormat.java:362)
>         at
>
> org.apache.struts.util.MessageResources.getMessage(MessageResources.java:305)
>         at
> org.apache.velocity.tools.struts.MessageTool.get(MessageTool.java:157)
>         at
> org.apache.velocity.tools.struts.MessageTool.get(MessageTool.java:125)
>         at
> org.apache.velocity.tools.struts.MessageTool.get(MessageTool.java:191)
> [...]
>
> Note that the pattern for the ChoiceFormat has been modified: there are
> extra single-quote characters in the format that ChoiceFormat complains
> about.
>
> I haven't yet read through all the code, but if this jogs anyone's
> memory for why something like this might happen, it would be very
> helpful to me.
>
> A couple of notes:
>
> 1. I have a custom build of Velocity-Tools, so the line numbers are not
> always correct. I have confirmed that my changes do not modify the
> message key's value.
>
> 2. It looks like in MessageTool.java:157, the value has the expected ...
> umm  ... value. That is, it does not have doubled single quotes. So I
> think this is almost certainly not Velocity Tools's fault. I may have to
> give into the Struts code.
>
> Thanks,
> -chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>