Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/src/org/labkey/api/data/MVDisplayColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void renderGridCellContents(RenderContext ctx, Writer out) throws IOExcep
.unsafeAppend("'.</p>");

out.write("<font class=\"labkey-mv\">");
PageFlowUtil.popupHelp(popupText.getHtmlString(), "Missing Value Indicator: " + mvIndicator).link(HtmlString.of(mvIndicator)).appendTo(out);
PageFlowUtil.popupHelp(popupText, "Missing Value Indicator: " + mvIndicator).link(HtmlString.of(mvIndicator)).appendTo(out);
out.write("</font>");
}
else
Expand Down
7 changes: 4 additions & 3 deletions api/src/org/labkey/api/jsp/JspBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.labkey.api.data.Container;
import org.labkey.api.security.User;
import org.labkey.api.util.Button.ButtonBuilder;
import org.labkey.api.util.DOM.Renderable;
import org.labkey.api.util.DateUtil;
import org.labkey.api.util.DemoMode;
import org.labkey.api.util.HelpTopic;
Expand Down Expand Up @@ -434,7 +435,7 @@ public LinkBuilder link(String text)
return new LinkBuilder(text);
}

public LinkBuilder link(HtmlString html)
public LinkBuilder link(Renderable html)
{
return new LinkBuilder(html);
}
Expand All @@ -456,7 +457,7 @@ public LinkBuilder link(String text, @NotNull String url)
return link(text).href(url);
}

public LinkBuilder link(HtmlString html, @NotNull String url)
public LinkBuilder link(Renderable html, @NotNull String url)
{
return new LinkBuilder(html).href(url);
}
Expand All @@ -481,7 +482,7 @@ public ButtonBuilder button(String text)
return new ButtonBuilder(text);
}

public ButtonBuilder button(HtmlString html)
public ButtonBuilder button(Renderable html)
{
return new ButtonBuilder(html);
}
Expand Down
3 changes: 2 additions & 1 deletion api/src/org/labkey/api/security/PasswordValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.util.DOM;
import org.labkey.api.util.DOM.Renderable;
import org.labkey.api.util.HtmlString;

import java.util.Collection;

public interface PasswordValidator
{
DOM.Renderable PREVIOUS_PASSWORD_BULLET = DOM.LI("Must not match any of the user's 10 previously used passwords.");
Renderable PREVIOUS_PASSWORD_BULLET = DOM.LI("Must not match any of the user's 10 previously used passwords.");

@NotNull HtmlString getFullRuleHtml();
@NotNull HtmlString getSummaryRuleHtml();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ protected RuleBasedPasswordValidator()
builder.append(" and cannot include portions of your personal information.");
_summaryRuleHtml = HtmlString.of(builder);

_fullRuleHtml = DOM.createHtml(DOM.createHtmlFragment(
_fullRuleHtml = DOM.createHtml(
DOM.UL(
DOM.LI("Must be " + getMinimumLengthText() + " non-whitespace characters or more."),
_patternRequirement != null ? DOM.LI("Must " + _patternRequirement) : null,
DOM.LI(getPersonalInfoRule()),
isPreviousPasswordForbidden() ? PREVIOUS_PASSWORD_BULLET : null,
isDeprecated() ? DOM.LI(cl("labkey-error"), "This password strength is not appropriate for production deployments and will be removed in the next major release.") : null
)
));
);
}

private void addPattern(List<Pattern> patterns, Pattern pattern, List<String> patternDescriptions, String patternDescription)
Expand Down
8 changes: 4 additions & 4 deletions api/src/org/labkey/api/security/StrongPasswordValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class StrongPasswordValidator extends EntropyPasswordValidator

public StrongPasswordValidator()
{
_fullRuleHtml = DOM.createHtml(DOM.createHtmlFragment(
_fullRuleHtml = DOM.createHtml(
DOM.UL(
DOM.LI("Evaluate passwords using a modern scoring approach based on entropy, a measure of the password's " +
"inherent randomness. Long passwords that use multiple character types (upper case, lower case, digits, " +
Expand All @@ -29,7 +29,7 @@ public StrongPasswordValidator()
getCharacterCountEstimate() + " or more characters without any easy-to-guess sequences."),
PREVIOUS_PASSWORD_BULLET
)
));
);
}

@Override
Expand Down Expand Up @@ -61,7 +61,7 @@ protected int getRequiredBitsOfEntropy()
.onClick(_tipsLinkOnClick)
.clearClasses();

private final HtmlString _tips = DOM.createHtml(DOM.createHtmlFragment(
private final HtmlString _tips = DOM.createHtml(
DIV(id("passwordTips").at(DOM.Attribute.style, "display:none;"),
DOM.UL(
DOM.LI("Use " + getCharacterCountEstimate() + " characters or more"),
Expand All @@ -71,7 +71,7 @@ protected int getRequiredBitsOfEntropy()
),
"We recommend using a password manager to generate a unique password for every website."
)
));
);

@Override
public @NotNull HtmlString getSummaryRuleHtml()
Expand Down
18 changes: 9 additions & 9 deletions api/src/org/labkey/api/util/Button.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.labkey.api.data.RenderContext;
import org.labkey.api.util.DOM.Renderable;
import org.labkey.api.view.DisplayElement;
import org.labkey.api.view.HttpView;

Expand All @@ -40,20 +41,19 @@

/**
* Basic button UI element. Might be a simple link, have a JavaScript handler, etc.
* Created by Nick Arnold on 2/27/14.
* Testing of this class can be found in the Core module's TestController.ButtonAction
*/
public class Button extends DisplayElement implements HasHtmlString, SafeToRender
{
// Button constants
private static final String CLS = "labkey-button";
private static final String DISABLEDCLS = "labkey-disabled-button";
private static final String DISABLED_CLS = "labkey-disabled-button";
private static final String PRIMARY_CLS = "primary";

// Composable members
private final String cssClass;
private final String iconCls;
private final HtmlString html; // required
private final Renderable html; // required
private final String href;
private final String onClick;
private final String id;
Expand Down Expand Up @@ -171,7 +171,7 @@ public boolean isSubmit()
char quote = PageFlowUtil.getUsedQuoteSymbol(onClick);

// quoted CSS classes used in scripting
final String qDisabledCls = quote + DISABLEDCLS + quote;
final String qDisabledCls = quote + DISABLED_CLS + quote;

// check if the disabled class is applied, if so, do nothing onclick
String onClickMethod = "if(this.className.indexOf(" + qDisabledCls + ")!=-1)return false;";
Expand Down Expand Up @@ -235,7 +235,7 @@ public HtmlString getHtmlString()
boolean iconOnly = getIconCls() != null;
String submitId = page.makeId("submit_");
// In the icon-only button case, use caption as tooltip. This avoids having to set both caption and tooltip
final HtmlString tip = (null != tooltip ? HtmlString.of(tooltip) : (!iconOnly ? null : html));
final Renderable tip = (null != tooltip ? HtmlString.of(tooltip) : (!iconOnly ? null : html));
String clickHandler = generateOnClick();

var attrs = at(attributes)
Expand All @@ -245,10 +245,10 @@ public HtmlString getHtmlString()
.data(usePost, "href", this.href)
.data(usePost, "confirmmessage", confirmMessage)
.data("submitid", submitId) // this id is used by the event handler, stash in a data attribute rather than hard-coding in the handler source
.data("tt", (HtmlString.isBlank(tip) ? null : "tooltip"))
.data("tt", null == tip ? null : "tooltip")
.data("placement", "top")
.cl(CLS, typeCls, getCssClass())
.cl(!isEnabled(), DISABLEDCLS)
.cl(!isEnabled(), DISABLED_CLS)
.cl(isDropdown(), "labkey-down-arrow")
.cl(isDropdown(), "dropdown-toggle")
.cl(iconOnly, "icon-only");
Expand All @@ -263,7 +263,7 @@ public HtmlString getHtmlString()

public static class ButtonBuilder extends DisplayElementBuilder<Button, ButtonBuilder>
{
private final HtmlString html;
private final Renderable html;

private String typeCls;
private boolean disableOnClick;
Expand All @@ -276,7 +276,7 @@ public ButtonBuilder(@NotNull String text)
this.html = HtmlString.of(text);
}

public ButtonBuilder(@NotNull HtmlString html)
public ButtonBuilder(@NotNull Renderable html)
{
this.html = html;
}
Expand Down
3 changes: 2 additions & 1 deletion api/src/org/labkey/api/util/DisplayElementBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.data.Container;
import org.labkey.api.util.DOM.Renderable;
import org.labkey.api.view.ActionURL;
import org.labkey.api.view.DisplayElement;
import org.springframework.web.servlet.mvc.Controller;
Expand All @@ -28,7 +29,7 @@

public abstract class DisplayElementBuilder<T extends DisplayElement & HasHtmlString, BUILDER extends DisplayElementBuilder<T, BUILDER>> implements HasHtmlString, SafeToRender
{
HtmlString html;
Renderable html;
String href;
String id;
String onClick;
Expand Down
3 changes: 2 additions & 1 deletion api/src/org/labkey/api/util/Link.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.jetbrains.annotations.NotNull;
import org.labkey.api.data.RenderContext;
import org.labkey.api.util.DOM.Renderable;
import org.labkey.api.view.DisplayElement;
import org.labkey.api.view.HttpView;

Expand Down Expand Up @@ -123,7 +124,7 @@ public LinkBuilder(@NotNull String text)
this(HtmlString.of(text));
}

public LinkBuilder(@NotNull HtmlString html)
public LinkBuilder(@NotNull Renderable html)
{
this();
this.html = html;
Expand Down
11 changes: 6 additions & 5 deletions api/src/org/labkey/api/util/PageFlowUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import org.labkey.api.stats.AnalyticsProvider;
import org.labkey.api.stats.AnalyticsProviderRegistry;
import org.labkey.api.util.Button.ButtonBuilder;
import org.labkey.api.util.DOM.Renderable;
import org.labkey.api.util.Link.LinkBuilder;
import org.labkey.api.util.logging.LogHelper;
import org.labkey.api.view.ActionURL;
Expand Down Expand Up @@ -1434,7 +1435,7 @@ public static HelpPopupBuilder popupHelp(@NotNull String helpText)
return new HelpPopupBuilder(helpText);
}

public static HelpPopupBuilder popupHelp(@NotNull HtmlString helpHtml, String titleText)
public static HelpPopupBuilder popupHelp(@NotNull Renderable helpHtml, String titleText)
{
return new HelpPopupBuilder(helpHtml, titleText);
}
Expand All @@ -1447,8 +1448,8 @@ public static class HelpPopupBuilder implements SafeToRender, HasHtmlString
{
final String helpText;
final String titleText;
final HtmlString helpHtml;
HtmlString linkHtml = HtmlString.unsafe("<span class=\"labkey-help-pop-up\">?</span>");
final Renderable helpHtml;
Renderable linkHtml = HtmlString.unsafe("<span class=\"labkey-help-pop-up\">?</span>");
int width = 0;
String onClickScript = null;

Expand All @@ -1459,14 +1460,14 @@ public static class HelpPopupBuilder implements SafeToRender, HasHtmlString
this.titleText = null;
}

HelpPopupBuilder(@NotNull HtmlString helpHtml, String titleText)
HelpPopupBuilder(@NotNull Renderable helpHtml, String titleText)
{
this.helpHtml = helpHtml;
this.helpText = null;
this.titleText = titleText;
}

public HelpPopupBuilder link(HtmlString linkHtml)
public HelpPopupBuilder link(Renderable linkHtml)
{
this.linkHtml = linkHtml;
return this;
Expand Down
18 changes: 4 additions & 14 deletions api/src/org/labkey/api/view/DisplayElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.labkey.api.view;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.data.RenderContext;
import org.labkey.api.security.permissions.Permission;
Expand All @@ -26,8 +28,6 @@
import org.labkey.api.util.StringExpressionFactory;
import org.springframework.web.servlet.View;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
Expand All @@ -36,9 +36,8 @@
import java.util.Set;

/**
* An element that can be displayed within a page. Handles showing/hiding based
* on the permissions of the current user, so that the same element can be reused
* and rendered appropriately for different users.
* An element that can be displayed within a page. Handles showing/hiding based on the permissions of the current user,
* so that the same element can be reused and rendered appropriately for different users.
*/
public abstract class DisplayElement implements View, Cloneable
{
Expand Down Expand Up @@ -85,7 +84,6 @@ public boolean isVisible(RenderContext ctx)
return _visible;
}


public void setVisible(boolean visible)
{
checkLocked();
Expand All @@ -112,28 +110,24 @@ public String getOutput(RenderContext ctx)
return writer.toString();
}


public String getCaption(RenderContext ctx)
{
return null == _caption ? null : _caption.eval(ctx);
}


@Nullable
public String getCaption()
{
return null == _caption ? null : _caption.getSource();
}


public void setCaption(String caption)
{
checkLocked();
_caption = caption == null ? null : StringExpressionFactory.create(caption);
assert (_caption == null && caption == null) || (_caption != null && _caption.toString().equals(caption)) : "Caption expression '" + _caption + "' doesn't match caption '" + caption + "'";
}


public String getCaptionExpr()
{
return _caption == null ? null : _caption.toString();
Expand All @@ -149,7 +143,6 @@ public final void render(Map map, HttpServletRequest request, HttpServletRespons
render((RenderContext)map, request, response);
}


/**
* org.springframework.framework.web.View
*/
Expand All @@ -158,7 +151,6 @@ public void render(RenderContext ctx, HttpServletRequest request, HttpServletRes
render(ctx, response.getWriter());
}


// This is not WebPartView.renderView() */
public void renderView(Map model, Writer out) throws IOException
{
Expand All @@ -173,10 +165,8 @@ else if (model instanceof ViewContext)
render(ctx, out);
}


public abstract void render(RenderContext ctx, Writer out) throws IOException;


public void lock()
{
_locked = true;
Expand Down
2 changes: 1 addition & 1 deletion api/src/org/labkey/api/view/Portal.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.labkey.api.view;

import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.collections4.Factory;
import org.apache.commons.collections4.MultiValuedMap;
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;
Expand Down Expand Up @@ -79,7 +80,6 @@
import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;

import jakarta.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Loading