Commit bafb0c49 by Jan Hrabal

templates

parent ca44afd2
...@@ -33,7 +33,9 @@ public class HibernateLoaderTemplateService implements TemplateService { ...@@ -33,7 +33,9 @@ public class HibernateLoaderTemplateService implements TemplateService {
if (valuesConfig != null) { if (valuesConfig != null) {
values.putAll(valuesConfig.getValues()); values.putAll(valuesConfig.getValues());
} }
if (data != null) {
values.putAll(data); values.putAll(data);
}
String content = t.getTemplate(); String content = t.getTemplate();
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
......
...@@ -4,6 +4,7 @@ import java.util.Locale; ...@@ -4,6 +4,7 @@ import java.util.Locale;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
public class HibernateTemplateLoader implements TemplateLoader { public class HibernateTemplateLoader implements TemplateLoader {
...@@ -14,12 +15,15 @@ public class HibernateTemplateLoader implements TemplateLoader { ...@@ -14,12 +15,15 @@ public class HibernateTemplateLoader implements TemplateLoader {
@Override @Override
@Transactional @Transactional
public Template loadTemplate(String code, Locale locale) { public Template loadTemplate(String code, Locale locale) {
String l = locale == null ? null : (locale.getLanguage() + "-" + locale.getCountry()); Template t = null;
Template t = repository.loadTemplate(code, l); if (locale != null) {
//TODO refactor if (StringUtils.hasText(locale.getCountry())) {
t = repository.loadTemplate(code, locale.getLanguage() + "-" + locale.getCountry());
}
if (t == null) { if (t == null) {
t = repository.loadTemplate(code, locale.getLanguage()); t = repository.loadTemplate(code, locale.getLanguage());
} }
}
if (t == null) { if (t == null) {
t = repository.loadTemplate(code, null); t = repository.loadTemplate(code, null);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment