cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <>
Subject Re: Show Formatted message
Date Thu, 14 Jun 2007 20:55:04 GMT
On 14.06.2007 17:57, njko wrote:

> I'm newbie in cocoon 

Welcome :)

> I have an Action that return a message.
> I want show this message a the end of execution in a web page.

> If I want show this 
> message = "aaa... \n bbb... \n ccc..."
> like this 
> aaa...
> bbb...
> ccc...
> what I have to do ?

If it becomes HTML at the end you need to replace the encoded line break 
characters with <br>. You can do that either with Java in XSP or with a 
recursive template in XSLT.

> Is this a good way for do that? Alternative?

Adding I18nTransformer [1] to your setup is probably a good choice. Let 
your action only return a message key and use this key to add an i18n 
element in the appropriate namespace:

<i18n:text i18n:key="key_from_action">Default value</i18n:text>

The I18nTransformer will replace it with the actual message. Since it's 
also markup aware you can add the <br>s directly into it. Externalizing 
message to I18nTransformer is nearly always a good choice even if you 
don't need to support multiple localizations.

As a general remark to your setup: Both actions and XSP are not 
necessarily the recommended techniques in Cocoon. For actions it heavily 
depends on what you actually want to do, there are still reasonable use 
cases for them. But for "real" controllers in the MVC sense you should 
consider flow [2].

And XSP is really near to deprecation (but not removal for sure). The 
recommended technique here is the JXTemplateGenerator (or FileGenerator 
+ JXTemplateTransformer) [3, 4, 5]. But please take care of using the 
most recent version of it in the template block, not from core.  The 
functionality is the same, the linked documentation should still be 
correct for nearly all cases. The difference between the two versions is 
the package: org.apache.cocoon.generation.JXTemplateGenerator (old core 
version) vs. org.apache.cocoon.template.JXTemplateGenerator (new 
refactored version in template block).

Hope this helps,


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message