You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Arpan <ar...@gmail.com> on 2011/10/20 15:04:40 UTC

adding style for the message in properties file.

Hi All,

I have the requirement to show a message depending on some condition.

My approach is to check the condition in the action class and add action
message.

The message is written in the resource.properties file. But the problem is
that some part of the message should be bold or colored.
Is there anyway I can add styling in the properties file?

Thanks

Re: adding style for the message in properties file.

Posted by Jeff Black <je...@yahoo.com>.
FWIW -- You can also craft your own UI Components using Freemarker by extending the Struts 2 Components to achieve what you're after.

This is a pretty good example.



________________________________
From: Arpan <ar...@gmail.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Thursday, October 20, 2011 9:21 AM
Subject: Re: adding style for the message in properties file.

The actionmessage code written in a common jsp being used for other pages
also.So I would prefer not to touch that.
Is there any other alternative way for this.

On Thu, Oct 20, 2011 at 7:42 PM, Carl Ballantyne
<ca...@gmail.com>wrote:

> Sounds like you need to escape the HTML.
>
> For example if you are using actionmessage have a look at the escape
> attribute. http://struts.apache.org/2.x/docs/actionmessage.html
>
>
> On Thu, Oct 20, 2011 at 4:06 PM, Arpan <ar...@gmail.com> wrote:
>
> > If I add any html tags such as <b>, <div> etc., all these tags gets
> > displayed in the screen, instead of changing the style of text.
> >
> > For example in propertie file I write:
> >
> > My device color is <div style="font-weight: bold">RED</div>.
> >
> > It will display as it is. No style change.
> >
> >
> > On Thu, Oct 20, 2011 at 7:21 PM, Maurizio Cucchiara
> > <mc...@apache.org>wrote:
> >
> > > There are no many options,  What happen if you include your marker tag
> > > inside your resource properties file?
> > >
> > > Twitter     :http://www.twitter.com/m_cucchiara
> > > G+          :https://plus.google.com/107903711540963855921
> > > Linkedin    :http://www.linkedin.com/in/mauriziocucchiara
> > >
> > > Maurizio Cucchiara
> > >
> > >
> > >
> > > On 20 October 2011 15:04, Arpan <ar...@gmail.com> wrote:
> > > > Hi All,
> > > >
> > > > I have the requirement to show a message depending on some condition.
> > > >
> > > > My approach is to check the condition in the action class and add
> > action
> > > > message.
> > > >
> > > > The message is written in the resource.properties file. But the
> problem
> > > is
> > > > that some part of the message should be bold or colored.
> > > > Is there anyway I can add styling in the properties file?
> > > >
> > > > Thanks
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
>

Re: adding style for the message in properties file.

Posted by Jeff Black <je...@yahoo.com>.
FWIW -- You could dress up <s:actionmessage/> with css.
http://struts.apache.org/2.x/docs/actionmessage.html

jb

@jeffblack360



________________________________
From: Maurizio Cucchiara <mc...@apache.org>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Thursday, October 20, 2011 9:29 AM
Subject: Re: adding style for the message in properties file.

Sorry,
I'm not sure I understand you correctly: according with what explained
here (http://struts.apache.org/2.x/docs/actionmessage.html) the only
thing you have to do is:
<s:actionmessage escape="false" />


Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara

Maurizio Cucchiara



On 20 October 2011 16:21, Arpan <ar...@gmail.com> wrote:
> The actionmessage code written in a common jsp being used for other pages
> also.So I would prefer not to touch that.
> Is there any other alternative way for this.
>
> On Thu, Oct 20, 2011 at 7:42 PM, Carl Ballantyne
> <ca...@gmail.com>wrote:
>
>> Sounds like you need to escape the HTML.
>>
>> For example if you are using actionmessage have a look at the escape
>> attribute. http://struts.apache.org/2.x/docs/actionmessage.html
>>
>>
>> On Thu, Oct 20, 2011 at 4:06 PM, Arpan <ar...@gmail.com> wrote:
>>
>> > If I add any html tags such as <b>, <div> etc., all these tags gets
>> > displayed in the screen, instead of changing the style of text.
>> >
>> > For example in propertie file I write:
>> >
>> > My device color is <div style="font-weight: bold">RED</div>.
>> >
>> > It will display as it is. No style change.
>> >
>> >
>> > On Thu, Oct 20, 2011 at 7:21 PM, Maurizio Cucchiara
>> > <mc...@apache.org>wrote:
>> >
>> > > There are no many options,  What happen if you include your marker tag
>> > > inside your resource properties file?
>> > >
>> > > Twitter     :http://www.twitter.com/m_cucchiara
>> > > G+          :https://plus.google.com/107903711540963855921
>> > > Linkedin    :http://www.linkedin.com/in/mauriziocucchiara
>> > >
>> > > Maurizio Cucchiara
>> > >
>> > >
>> > >
>> > > On 20 October 2011 15:04, Arpan <ar...@gmail.com> wrote:
>> > > > Hi All,
>> > > >
>> > > > I have the requirement to show a message depending on some condition.
>> > > >
>> > > > My approach is to check the condition in the action class and add
>> > action
>> > > > message.
>> > > >
>> > > > The message is written in the resource.properties file. But the
>> problem
>> > > is
>> > > > that some part of the message should be bold or colored.
>> > > > Is there anyway I can add styling in the properties file?
>> > > >
>> > > > Thanks
>> > > >
>> > >
>> > > ---------------------------------------------------------------------
>> > > 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: adding style for the message in properties file.

Posted by Maurizio Cucchiara <mc...@apache.org>.
Sorry,
I'm not sure I understand you correctly: according with what explained
here (http://struts.apache.org/2.x/docs/actionmessage.html) the only
thing you have to do is:
<s:actionmessage escape="false" />


Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara

Maurizio Cucchiara



On 20 October 2011 16:21, Arpan <ar...@gmail.com> wrote:
> The actionmessage code written in a common jsp being used for other pages
> also.So I would prefer not to touch that.
> Is there any other alternative way for this.
>
> On Thu, Oct 20, 2011 at 7:42 PM, Carl Ballantyne
> <ca...@gmail.com>wrote:
>
>> Sounds like you need to escape the HTML.
>>
>> For example if you are using actionmessage have a look at the escape
>> attribute. http://struts.apache.org/2.x/docs/actionmessage.html
>>
>>
>> On Thu, Oct 20, 2011 at 4:06 PM, Arpan <ar...@gmail.com> wrote:
>>
>> > If I add any html tags such as <b>, <div> etc., all these tags gets
>> > displayed in the screen, instead of changing the style of text.
>> >
>> > For example in propertie file I write:
>> >
>> > My device color is <div style="font-weight: bold">RED</div>.
>> >
>> > It will display as it is. No style change.
>> >
>> >
>> > On Thu, Oct 20, 2011 at 7:21 PM, Maurizio Cucchiara
>> > <mc...@apache.org>wrote:
>> >
>> > > There are no many options,  What happen if you include your marker tag
>> > > inside your resource properties file?
>> > >
>> > > Twitter     :http://www.twitter.com/m_cucchiara
>> > > G+          :https://plus.google.com/107903711540963855921
>> > > Linkedin    :http://www.linkedin.com/in/mauriziocucchiara
>> > >
>> > > Maurizio Cucchiara
>> > >
>> > >
>> > >
>> > > On 20 October 2011 15:04, Arpan <ar...@gmail.com> wrote:
>> > > > Hi All,
>> > > >
>> > > > I have the requirement to show a message depending on some condition.
>> > > >
>> > > > My approach is to check the condition in the action class and add
>> > action
>> > > > message.
>> > > >
>> > > > The message is written in the resource.properties file. But the
>> problem
>> > > is
>> > > > that some part of the message should be bold or colored.
>> > > > Is there anyway I can add styling in the properties file?
>> > > >
>> > > > Thanks
>> > > >
>> > >
>> > > ---------------------------------------------------------------------
>> > > 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: adding style for the message in properties file.

Posted by Eric Lentz <Er...@sherwin.com>.
> Is there any other alternative way for this

Break the message up?

If your message is "My device color is <div style="font-weight: 
bold">RED</div>." then write something like this:

<s:text  name="device.preamble">&nbsp;<div style="font-weight: bold">
<s:text  name="device.red"></div>.

where your properties file contains:
device.preamble=My device color is
device.red=RED


Re: adding style for the message in properties file.

Posted by Carl Ballantyne <ca...@gmail.com>.
I actually meant before you need to put escape="false" but I am sure you
understood that anyway.

As far as I know there is no other way. Maybe you could escape other text
in the properties file if you need to display them that way. And then enter
the html markup as normal. And then put the escape false attribute. I have
not tried this but just an idea.

On Thu, Oct 20, 2011 at 4:21 PM, Arpan <ar...@gmail.com> wrote:

> The actionmessage code written in a common jsp being used for other pages
> also.So I would prefer not to touch that.
> Is there any other alternative way for this.
>
> On Thu, Oct 20, 2011 at 7:42 PM, Carl Ballantyne
> <ca...@gmail.com>wrote:
>
> > Sounds like you need to escape the HTML.
> >
> > For example if you are using actionmessage have a look at the escape
> > attribute. http://struts.apache.org/2.x/docs/actionmessage.html
> >
> >
> > On Thu, Oct 20, 2011 at 4:06 PM, Arpan <ar...@gmail.com> wrote:
> >
> > > If I add any html tags such as <b>, <div> etc., all these tags gets
> > > displayed in the screen, instead of changing the style of text.
> > >
> > > For example in propertie file I write:
> > >
> > > My device color is <div style="font-weight: bold">RED</div>.
> > >
> > > It will display as it is. No style change.
> > >
> > >
> > > On Thu, Oct 20, 2011 at 7:21 PM, Maurizio Cucchiara
> > > <mc...@apache.org>wrote:
> > >
> > > > There are no many options,  What happen if you include your marker
> tag
> > > > inside your resource properties file?
> > > >
> > > > Twitter     :http://www.twitter.com/m_cucchiara
> > > > G+          :https://plus.google.com/107903711540963855921
> > > > Linkedin    :http://www.linkedin.com/in/mauriziocucchiara
> > > >
> > > > Maurizio Cucchiara
> > > >
> > > >
> > > >
> > > > On 20 October 2011 15:04, Arpan <ar...@gmail.com> wrote:
> > > > > Hi All,
> > > > >
> > > > > I have the requirement to show a message depending on some
> condition.
> > > > >
> > > > > My approach is to check the condition in the action class and add
> > > action
> > > > > message.
> > > > >
> > > > > The message is written in the resource.properties file. But the
> > problem
> > > > is
> > > > > that some part of the message should be bold or colored.
> > > > > Is there anyway I can add styling in the properties file?
> > > > >
> > > > > Thanks
> > > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail: user-help@struts.apache.org
> > > >
> > > >
> > >
> >
>

Re: adding style for the message in properties file.

Posted by Arpan <ar...@gmail.com>.
The actionmessage code written in a common jsp being used for other pages
also.So I would prefer not to touch that.
Is there any other alternative way for this.

On Thu, Oct 20, 2011 at 7:42 PM, Carl Ballantyne
<ca...@gmail.com>wrote:

> Sounds like you need to escape the HTML.
>
> For example if you are using actionmessage have a look at the escape
> attribute. http://struts.apache.org/2.x/docs/actionmessage.html
>
>
> On Thu, Oct 20, 2011 at 4:06 PM, Arpan <ar...@gmail.com> wrote:
>
> > If I add any html tags such as <b>, <div> etc., all these tags gets
> > displayed in the screen, instead of changing the style of text.
> >
> > For example in propertie file I write:
> >
> > My device color is <div style="font-weight: bold">RED</div>.
> >
> > It will display as it is. No style change.
> >
> >
> > On Thu, Oct 20, 2011 at 7:21 PM, Maurizio Cucchiara
> > <mc...@apache.org>wrote:
> >
> > > There are no many options,  What happen if you include your marker tag
> > > inside your resource properties file?
> > >
> > > Twitter     :http://www.twitter.com/m_cucchiara
> > > G+          :https://plus.google.com/107903711540963855921
> > > Linkedin    :http://www.linkedin.com/in/mauriziocucchiara
> > >
> > > Maurizio Cucchiara
> > >
> > >
> > >
> > > On 20 October 2011 15:04, Arpan <ar...@gmail.com> wrote:
> > > > Hi All,
> > > >
> > > > I have the requirement to show a message depending on some condition.
> > > >
> > > > My approach is to check the condition in the action class and add
> > action
> > > > message.
> > > >
> > > > The message is written in the resource.properties file. But the
> problem
> > > is
> > > > that some part of the message should be bold or colored.
> > > > Is there anyway I can add styling in the properties file?
> > > >
> > > > Thanks
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
>

Re: adding style for the message in properties file.

Posted by Carl Ballantyne <ca...@gmail.com>.
Sounds like you need to escape the HTML.

For example if you are using actionmessage have a look at the escape
attribute. http://struts.apache.org/2.x/docs/actionmessage.html


On Thu, Oct 20, 2011 at 4:06 PM, Arpan <ar...@gmail.com> wrote:

> If I add any html tags such as <b>, <div> etc., all these tags gets
> displayed in the screen, instead of changing the style of text.
>
> For example in propertie file I write:
>
> My device color is <div style="font-weight: bold">RED</div>.
>
> It will display as it is. No style change.
>
>
> On Thu, Oct 20, 2011 at 7:21 PM, Maurizio Cucchiara
> <mc...@apache.org>wrote:
>
> > There are no many options,  What happen if you include your marker tag
> > inside your resource properties file?
> >
> > Twitter     :http://www.twitter.com/m_cucchiara
> > G+          :https://plus.google.com/107903711540963855921
> > Linkedin    :http://www.linkedin.com/in/mauriziocucchiara
> >
> > Maurizio Cucchiara
> >
> >
> >
> > On 20 October 2011 15:04, Arpan <ar...@gmail.com> wrote:
> > > Hi All,
> > >
> > > I have the requirement to show a message depending on some condition.
> > >
> > > My approach is to check the condition in the action class and add
> action
> > > message.
> > >
> > > The message is written in the resource.properties file. But the problem
> > is
> > > that some part of the message should be bold or colored.
> > > Is there anyway I can add styling in the properties file?
> > >
> > > Thanks
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>

Re: adding style for the message in properties file.

Posted by Arpan <ar...@gmail.com>.
If I add any html tags such as <b>, <div> etc., all these tags gets
displayed in the screen, instead of changing the style of text.

For example in propertie file I write:

My device color is <div style="font-weight: bold">RED</div>.

It will display as it is. No style change.


On Thu, Oct 20, 2011 at 7:21 PM, Maurizio Cucchiara
<mc...@apache.org>wrote:

> There are no many options,  What happen if you include your marker tag
> inside your resource properties file?
>
> Twitter     :http://www.twitter.com/m_cucchiara
> G+          :https://plus.google.com/107903711540963855921
> Linkedin    :http://www.linkedin.com/in/mauriziocucchiara
>
> Maurizio Cucchiara
>
>
>
> On 20 October 2011 15:04, Arpan <ar...@gmail.com> wrote:
> > Hi All,
> >
> > I have the requirement to show a message depending on some condition.
> >
> > My approach is to check the condition in the action class and add action
> > message.
> >
> > The message is written in the resource.properties file. But the problem
> is
> > that some part of the message should be bold or colored.
> > Is there anyway I can add styling in the properties file?
> >
> > Thanks
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: adding style for the message in properties file.

Posted by Maurizio Cucchiara <mc...@apache.org>.
There are no many options,  What happen if you include your marker tag
inside your resource properties file?

Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara

Maurizio Cucchiara



On 20 October 2011 15:04, Arpan <ar...@gmail.com> wrote:
> Hi All,
>
> I have the requirement to show a message depending on some condition.
>
> My approach is to check the condition in the action class and add action
> message.
>
> The message is written in the resource.properties file. But the problem is
> that some part of the message should be bold or colored.
> Is there anyway I can add styling in the properties file?
>
> Thanks
>

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