diff --git a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/DefaultFlexiColumnModel.java b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/DefaultFlexiColumnModel.java index 692ffdedaac636f849e10735de2be28eb6228610..d295116f132d49b4d618e2faada70606fd736d79 100644 --- a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/DefaultFlexiColumnModel.java +++ b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/DefaultFlexiColumnModel.java @@ -123,7 +123,17 @@ public class DefaultFlexiColumnModel implements FlexiColumnModel { * @param action */ public DefaultFlexiColumnModel(String headerKey, String label, String action) { - this(true, true, headerKey, -1, action, false, null, FlexiColumnModel.ALIGNMENT_LEFT, new StaticFlexiCellRenderer(label, action)); + this(headerKey, label, action, false); + } + + /** + * Always visible + * @param headerKey + * @param label + * @param action + */ + public DefaultFlexiColumnModel(String headerKey, String label, String action, boolean newWindow) { + this(true, true, headerKey, -1, action, false, null, FlexiColumnModel.ALIGNMENT_LEFT, new StaticFlexiCellRenderer(label, action, newWindow)); } public DefaultFlexiColumnModel(String headerKey, int columnIndex, boolean sortable, String sortKey) { diff --git a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/StaticFlexiCellRenderer.java b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/StaticFlexiCellRenderer.java index 669bc341a0ae2f5078d04b38c5975222f67e847d..f94dfe44c613ccb6f491c1ab07d01f55fee03ecb 100644 --- a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/StaticFlexiCellRenderer.java +++ b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/table/StaticFlexiCellRenderer.java @@ -20,14 +20,19 @@ package org.olat.core.gui.components.form.flexible.impl.elements.table; +import java.io.IOException; + import org.apache.commons.lang.StringEscapeUtils; import org.olat.core.gui.components.form.flexible.impl.Form; import org.olat.core.gui.components.form.flexible.impl.FormJSHelper; import org.olat.core.gui.components.form.flexible.impl.NameValuePair; +import org.olat.core.gui.control.winmgr.AJAXFlags; 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.logging.OLog; +import org.olat.core.logging.Tracing; import org.olat.core.util.StringHelper; /** @@ -37,33 +42,45 @@ import org.olat.core.util.StringHelper; * */ public class StaticFlexiCellRenderer implements FlexiCellRenderer { + + private static final OLog log = Tracing.createLoggerFor(StaticFlexiCellRenderer.class); private String label; private String action; private String iconLeftCSS; private String iconRightCSS; private String linkCSS; - private String linkTitle; + private String linkTitle; + private boolean newWindow = false; private FlexiCellRenderer labelDelegate; public StaticFlexiCellRenderer(String label, String action) { - this(label, action, null, null, null); + this(label, action, false, null, null, null); + } + + public StaticFlexiCellRenderer(String label, String action, boolean newWindow) { + this(label, action, newWindow, null, null, null); } public StaticFlexiCellRenderer(String label, String action, String linkCSS) { - this(label, action, linkCSS, null, null); + this(label, action, false, linkCSS, null, null); } public StaticFlexiCellRenderer(String label, String action, String linkCSS, String iconLeftCSS) { - this(label, action, linkCSS, iconLeftCSS, null); + this(label, action, false, linkCSS, iconLeftCSS, null); } public StaticFlexiCellRenderer(String label, String action, String linkCSS, String iconLeftCSS, String linkTitle) { + this(label, action, false, linkCSS, iconLeftCSS, linkTitle); + } + + public StaticFlexiCellRenderer(String label, String action, boolean newWindow, String linkCSS, String iconLeftCSS, String linkTitle) { this.label = label; this.action = action; this.linkCSS = linkCSS; this.iconLeftCSS = iconLeftCSS; this.linkTitle = linkTitle; + this.newWindow = newWindow; } public StaticFlexiCellRenderer(String action, FlexiCellRenderer labelDelegate) { @@ -111,6 +128,14 @@ public class StaticFlexiCellRenderer implements FlexiCellRenderer { this.action = action; } + public boolean isNewWindow() { + return newWindow; + } + + public void setNewWindow(boolean newWindow) { + this.newWindow = newWindow; + } + @Override public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator translator) { @@ -121,7 +146,24 @@ public class StaticFlexiCellRenderer implements FlexiCellRenderer { String id = source.getFormDispatchId(); Form rootForm = ftE.getRootForm(); NameValuePair pair = new NameValuePair(cellAction, Integer.toString(row)); - String jsCode = FormJSHelper.getXHRFnCallFor(rootForm, id, 1, true, true, pair); + String jsCode; + if(newWindow) { + URLBuilder subu = ubu.createCopyFor(ftE.getRootForm().getInitialComponent()); + try(StringOutput href = new StringOutput()) { + href.append("o_openTab('"); + subu.buildURI(href, AJAXFlags.MODE_NORMAL, + new NameValuePair("dispatchuri", ftE.getFormDispatchId()), + new NameValuePair("dispatchevent", "1"), + pair); + href.append("')"); + jsCode = href.toString(); + } catch(IOException e) { + log.error("", e); + jsCode = ""; + } + } else { + jsCode = FormJSHelper.getXHRFnCallFor(rootForm, id, 1, true, true, pair); + } target.append("<a href=\"javascript:").append(jsCode).append(";\""); if(StringHelper.containsNonWhitespace(linkTitle)) { target.append(" title=\"").append(StringEscapeUtils.escapeHtml(linkTitle)).append("\"");