Skip to content
Snippets Groups Projects
Commit 7366d847 authored by srosse's avatar srosse
Browse files

OO-1658: solve NPE in context helper component render

parent 588428e9
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,8 @@
* <p>
*/
package org.olat.core.commons.contextHelp;
import java.util.Locale;
/**
* OpenOLAT - Online Learning and Training</a><br>
......@@ -40,6 +42,8 @@ package org.olat.core.commons.contextHelp;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.AbstractComponent;
import org.olat.core.gui.components.ComponentRenderer;
import org.olat.core.gui.translator.Translator;
import org.olat.core.util.Util;
/**
*
......@@ -52,11 +56,26 @@ import org.olat.core.gui.components.ComponentRenderer;
public class ContextHelpComponent extends AbstractComponent {
private static ComponentRenderer RENDERER ;
private final Locale locale;
public ContextHelpComponent(String name) {
public ContextHelpComponent(String name, Locale locale) {
super(name);
this.locale = locale;
setTranslator(Util.createPackageTranslator(ContextHelpComponent.class, locale));
RENDERER = new ContextHelpComponentRenderer(name);
}
public Locale getLocale() {
return locale;
}
public void setTranslator(Translator translator) {
if(translator == null) {
System.out.println();
}
super.setTranslator(translator);
}
/**
*
......
......@@ -19,9 +19,6 @@
*/
package org.olat.core.commons.contextHelp;
import java.util.Locale;
import org.apache.commons.lang.StringEscapeUtils;
import org.olat.core.CoreSpringFactory;
import org.olat.core.commons.services.help.HelpModule;
import org.olat.core.gui.components.Component;
......@@ -31,6 +28,7 @@ import org.olat.core.gui.render.Renderer;
import org.olat.core.gui.render.StringOutput;
import org.olat.core.gui.render.URLBuilder;
import org.olat.core.gui.translator.Translator;
import org.olat.core.util.StringHelper;
/**
* Draw the link to the context help.
......@@ -53,12 +51,11 @@ public class ContextHelpComponentRenderer extends DefaultComponentRenderer {
Translator translator, RenderResult renderResult, String[] args) {
HelpModule helpModule = CoreSpringFactory.getImpl(HelpModule.class);
Locale locale = renderer.getTranslator().getLocale();
String title = StringEscapeUtils.escapeHtml(renderer.getTranslator().translate("help.button"));
String url = helpModule.getHelpProvider().getURL(locale, page);
sb.append("<a href=\"").append(url)
String title = StringHelper.escapeHtml(source.getTranslator().translate("help.button"));
String url = helpModule.getHelpProvider().getURL(source.getTranslator().getLocale(), page);
sb.append("<a href=\"").append(url)
.append("\" class=\"o_chelp\" target=\"_blank\" title=\"").append(title).append("\"><i class='o_icon o_icon_help'></i> ")
.append(renderer.getTranslator().translate("help"))
.append(source.getTranslator().translate("help"))
.append("</a>");
}
......
......@@ -105,7 +105,7 @@ public class CPContentController extends BasicController {
previewLink.setTooltip(translate("contentcontroller.previewlink_title"));
toolbar.addTool(previewLink, Align.right);
ContextHelpComponent contextHelp = new ContextHelpComponent("CP Editor");
ContextHelpComponent contextHelp = new ContextHelpComponent("cpHelp", getLocale());
toolbar.addTool(contextHelp, Align.right);
}
......
......@@ -159,6 +159,7 @@
position: relative;
top: -1em;
vertical-align: top;
color: $o-chelp-color;
}
}
......
This diff is collapsed.
source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment