Magnolia override i18n in Freemarker Renderer - freemarker

We have the problem that by default single quotes in i18n are not escaped in the magnolia freemarker renderer. That leads to the problem that our i18n string is too early closed in the html. As a simple fix we want to extend the i18n function provided in the Freemarker Template.
I have seen that it is possible to override the freemarker renderer with a decorator in decorations/rendering/renderers/freemarker.yaml but it seems that the contextAttributes doesn't include i18n. So the question is where does i18n come from and how can I extend it?

It's sadly not very easy to extend the default i18n mechanism. You might experiment with remapping the info.magnolia.i18nsystem.TranslationService to your custom implementation via component mappings in the module descriptor.
However, it seems that i18n messages with single (or double) quotes work fine.

Related

How do you use TinyMCE in ASP.NET Boilerplate?

I'm using ABP 2.1.2 with the AdminBSB theme. I see the theme incorporates both TinyMCE and CKEditor, either of which I want to use in a form.
Have these been created as Angular modules in ABP or must I create them myself? If they are already supported, how do I use them?
ABP doesn't have implementation of those Angular modules. You have to create yourself.

How to use Spring to back Freemarker "?new" built in?

Currently we have a number of classes that extend TemplateMethodModelEx which we construct using Spring and then inject into the Freemarker Configuration as shared variables so they are available as functions to all of our templates.
However, it would be nicer to have more fine grained control and make these methods available on demand in individual templates. One can instantiate them using the ?new built in, but internally that uses the general Java reflection mechanism for instantiating the class, and these models need to be constructed via Spring to get their dependencies.
In a perfect world, I'd like to make it so that the ?new built in use Spring to construct the class. It looks like to do that I would need to find a way to overload BeansWrapper.newInstance(Class, List) to use Spring, but I'm unclear on the best way to accomplish that.
Note that we are currently using Freemarker 2.3.23

spring view template skinning

How can I implement a css based template skin for spring MVC app. Also, is it possible to change the template path for spring MVC file at runtime to load completely different theme based on user selection or url called?
Take a look at Spring Themes. Also, there are other options:
You may change class of <body>, for example, and have different themes as it is done in Dojo.
You may load stylesheets as alternate and switch them with JS.

where is #Equals annotation in playframework 2.0?

I am trying to validate the equality of password with confirmPassword field in a registration form.
I am aware that in v.1(precisely v.1.2.4), you can do this using #Equals("confirmPassword") annotation.
However the same functionality seems to be missing in v2.0.
Am I missing out on something or v2.0 doesn't implement this anymore?
Have a look at Forms Validation for Play 2.0, specifically the Constraints section. The play.data.validation.Constraints class contains several built-in validation annotations according to the documentation. They made a lot of changes between the 1.* and 2.* versions.

Spring MVC View

What are you guys using for your view in Spring MVC.
I know Spring MVC has a wide support for views but I'm having trouble finding what works well, what view to use when, etc.
Any insight would be great!
JSP, of course.
Sometimes PDF; Excel when necessary.
BlazeDS makes Flex integration with Spring possible. That's a great way to go if you use Flex.
"...I'm having trouble finding what works well..." - they all work well from Spring's point of view.
What to use when? Use the technology that you know best. Spring can deal with all of them just fine.
UPDATE: Since this was written three years ago, I'll amend it by saying that I would recommend just using Velocity templates to marry with dynamic data. Templates should use HTML, CSS, JavaScript, and jQuery. I think that provides the best flexibility you can have. You "future proof" your design if you can generate responsive HTML 5 pages.
We are using the following templating languages
Apache Velocity: Most of our old projects are using apache velocity to render the view. This is a very easy to learn and use language. But here xml operations are very limited.
Freemarker: Now we are migrating our project to Freemarker. This is a very good templating language. Advantage over velocity is that it has a very good support for xml data processing
You can use jsp with struts tiles to give good and uniform experience. You can refer to "Spring in Action" Book to find out how to do it. I have used this combination for developing my website www.propertymela.net. Have a look.
I am using Thymeleaf, because it has static prototyping which is very useful when there are two teams doing web design and server side development. I believe JSP is a fairly old technology, and I've had some problems with using HTML5 with it, which is why I opted to use a different view technology.
Also, Velocity is a competitor of Thymeleaf but I haven't really touched on Velocity aside from creating email templates.
JSTL is my option. JSTL has all the functional component which we can achieve through the use of scriplets in JSP. The avoidance of the scriptlet code in JSP is key to move into JSTL
In scriplet code if anything wrong whole page breaks. But it is not in the case of JSTL

Resources