You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by TonyD <an...@eunics.it> on 2007/07/12 14:23:24 UTC

How to display the ' character from a .properties file

If in my .properties file I have text with the ' character 

my.properties (file)
 
mylabel=I don't know how
...


The output doesn't display the ' character

I dont know how

Do I need a special character before the ' character?
Which one?

Thanks.

-- 
View this message in context: http://www.nabble.com/How-to-display-the-%27-character-from-a-.properties-file-tf4067655.html#a11558490
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to display the ' character from a .properties file

Posted by TonyD <an...@eunics.it>.
I wrote my string in my .properties file

mylabel=Now it''s working 

and then a got it

in my .jsp with

<s:text name="mylabel"/>


Antonio Petrelli-3 wrote:
> 
> 2007/7/12, TonyD <an...@eunics.it>:
>>
>>
>> Thanks it works!
> 
> 
> 
> 
> Mmm... this means that there's something wrong when you display the text.
> I think that, before writing the string, you have to escape it.
> How, and where, do you write the string?
> 
> Antonio
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-display-the-%27-character-from-a-.properties-file-tf4067655.html#a11562104
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to display the ' character from a .properties file

Posted by Josh Vickery <jo...@vickeryj.com>.
On 7/12/07, Niall Pemberton <ni...@gmail.com> wrote:
> I don't use Struts2 - but my guess is that this is down to a single
> quote being an escape character in MessageFormat:
>
> http://java.sun.com/j2se/1.4.2/docs/api/java/text/MessageFormat.html
>
> So its probably not a bug - just need to escape single quotes (with a
> single quote) in any messages.

Well perhaps not a bug exactly, but since the ' character is valid in
properties files, and since some I8n code handles them when found in
properties files, the Struts 2 requirement of escaping them within the
.properties file could cause problems when the same .properties file
is used by multiple I8n implementations.

Josh

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


[S2] SUGESTION=

Posted by Luciano Costa <mo...@gmail.com>.
I'd like to suggest the implementation of this simple but great-to-use
feature.

I've made hard use of textarea tag and it's boring to re-code it ever and
ever.

This sample code prevents use of javascript block in head section.

Once "<s:textarea>" already has "onKeyDown" and "onKeyUp" properties, I
think this js code could be added to these properties, in case of "maxlength
> 0".


tag code:

<s:textarea name="txt_1" maxlength="50"></s:textarea>


result code:

<textarea name="txt_1" onKeyDown="this.value=this.value.substring(0,50);"
onKeyUp="this.value=this.value.substring(0,50);"></textarea>


taglib:

<attribute>
  <name>maxlength</name>
  <required>false</required>
  <rtexprvalue>true</rtexprvalue>
  <description><![CDATA[HTML maxlength handling via
javascript]]></description>
</attribute>



Att,

Luciano Costa


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


Re: How to display the ' character from a .properties file

Posted by Niall Pemberton <ni...@gmail.com>.
On 7/12/07, Josh Vickery <jo...@vickeryj.com> wrote:
> Actually, I think this is a bug in the handling of MessageResources in
> Struts 2.  Not only do ' characters in properties files fail to
> display, they cause parameter substitution to fail.  For example, if
> you have a properties file:

I don't use Struts2 - but my guess is that this is down to a single
quote being an escape character in MessageFormat:

http://java.sun.com/j2se/1.4.2/docs/api/java/text/MessageFormat.html

So its probably not a bug - just need to escape single quotes (with a
single quote) in any messages.

Struts1 message resources automatically escaped quotes (which
sometimes caused problems in itself - and theres now an option to turn
if off)

Niall

> foo=Message's for {0}
>
> and you attempt to display it in a jsp like so:
>
> <s:text name="foo"><param name="value" value="${user.firstname}"></s:text>
>
> the displayed text is
>
> Messages for {0}
>
> if you double the ' (foo=Messages''s for {0}) you get:
>
> Messages for Josh
>
> On 7/12/07, Antonio Petrelli <an...@gmail.com> wrote:
> > 2007/7/12, TonyD <an...@eunics.it>:
> > >
> > >
> > > Thanks it works!
> >
> > Mmm... this means that there's something wrong when you display the text.
> > I think that, before writing the string, you have to escape it.
> > How, and where, do you write the string?
> >
> > Antonio

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


Re: How to display the ' character from a .properties file

Posted by Josh Vickery <jo...@vickeryj.com>.
Actually, I think this is a bug in the handling of MessageResources in
Struts 2.  Not only do ' characters in properties files fail to
display, they cause parameter substitution to fail.  For example, if
you have a properties file:

foo=Message's for {0}

and you attempt to display it in a jsp like so:

<s:text name="foo"><param name="value" value="${user.firstname}"></s:text>

the displayed text is

Messages for {0}

if you double the ' (foo=Messages''s for {0}) you get:

Messages for Josh

On 7/12/07, Antonio Petrelli <an...@gmail.com> wrote:
> 2007/7/12, TonyD <an...@eunics.it>:
> >
> >
> > Thanks it works!
>
>
>
>
> Mmm... this means that there's something wrong when you display the text.
> I think that, before writing the string, you have to escape it.
> How, and where, do you write the string?
>
> Antonio
>

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


Re: How to display the ' character from a .properties file

Posted by Antonio Petrelli <an...@gmail.com>.
2007/7/12, TonyD <an...@eunics.it>:
>
>
> Thanks it works!




Mmm... this means that there's something wrong when you display the text.
I think that, before writing the string, you have to escape it.
How, and where, do you write the string?

Antonio

Re: How to display the ' character from a .properties file

Posted by TonyD <an...@eunics.it>.
Thanks it works!


Pascal Lalonde-4 wrote:
> 
> This should be the good solution, that's what we do ...
> 
> acogoluegnes@sqli.com wrote:
>> try to double the '
>>
>> ex.:
>>
>> mylabel=I don''t know how
>>
>>   
>>> If in my .properties file I have text with the ' character
>>>
>>> my.properties (file)
>>>
>>> mylabel=I don't know how
>>> ...
>>>
>>>
>>> The output doesn't display the ' character
>>>
>>> I dont know how
>>>
>>> Do I need a special character before the ' character?
>>> Which one?
>>>
>>> Thanks.
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/How-to-display-the-%27-character-from-a-.properties-file-tf4067655.html#a11558490
>>> Sent from the Struts - User mailing list archive at Nabble.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
>>
>>
>>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-display-the-%27-character-from-a-.properties-file-tf4067655.html#a11561307
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to display the ' character from a .properties file

Posted by Pascal Lalonde <eu...@yahoo.ca>.
This should be the good solution, that's what we do ...

acogoluegnes@sqli.com wrote:
> try to double the '
>
> ex.:
>
> mylabel=I don''t know how
>
>   
>> If in my .properties file I have text with the ' character
>>
>> my.properties (file)
>>
>> mylabel=I don't know how
>> ...
>>
>>
>> The output doesn't display the ' character
>>
>> I dont know how
>>
>> Do I need a special character before the ' character?
>> Which one?
>>
>> Thanks.
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-display-the-%27-character-from-a-.properties-file-tf4067655.html#a11558490
>> Sent from the Struts - User mailing list archive at Nabble.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: How to display the ' character from a .properties file

Posted by ac...@sqli.com.
try to double the '

ex.:

mylabel=I don''t know how

>
> If in my .properties file I have text with the ' character
>
> my.properties (file)
>
> mylabel=I don't know how
> ...
>
>
> The output doesn't display the ' character
>
> I dont know how
>
> Do I need a special character before the ' character?
> Which one?
>
> Thanks.
>
> --
> View this message in context:
> http://www.nabble.com/How-to-display-the-%27-character-from-a-.properties-file-tf4067655.html#a11558490
> Sent from the Struts - User mailing list archive at Nabble.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: How to display the ' character from a .properties file

Posted by Antonio Petrelli <an...@gmail.com>.
2007/7/12, TonyD <an...@eunics.it>:
>
> Do I need a special character before the ' character?
> Which one?



I could say the backslash ( \ ) but the apostrophe is not a special
character to be escaped (such as = ! ) so I wonder why you cannot see it...

Antonio

RE How to display the ' character from a .properties file

Posted by ML...@abusinessware.com.
I had the same problem, and I put &#146; instead of ' in my .properties.


Ragards,

Michaël




TonyD <an...@eunics.it> 
12/07/2007 14:29
Veuillez répondre à
"Struts Users Mailing List" <us...@struts.apache.org>


A
user@struts.apache.org
cc

Objet
How to display the ' character from a .properties file







If in my .properties file I have text with the ' character 

my.properties (file)
 
mylabel=I don't know how
...


The output doesn't display the ' character

I dont know how

Do I need a special character before the ' character?
Which one?

Thanks.

-- 
View this message in context: 
http://www.nabble.com/How-to-display-the-%27-character-from-a-.properties-file-tf4067655.html#a11558490

Sent from the Struts - User mailing list archive at Nabble.com.


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