Search in sources :

Example 1 with StrippedText

use of com.servoy.j2db.server.headlessclient.dataui.StripHTMLTagsConverter.StrippedText in project servoy-client by Servoy.

the class WebDataSubmitLink method onBeforeRender.

/**
 * @see org.apache.wicket.markup.html.link.AbstractLink#onBeforeRender()
 */
@Override
protected void onBeforeRender() {
    super.onBeforeRender();
    strippedText = new StripHTMLTagsConverter.StrippedText();
    IModel<?> model = getInnermostModel();
    hasHTML = false;
    bodyText = null;
    if (needEntireState && model instanceof RecordItemModel) {
        if (dataProviderID != null) {
            Object value = getDefaultModelObject();
            if (value instanceof byte[]) {
                setIcon((byte[]) value);
                if (model instanceof RecordItemModel) {
                    ((RecordItemModel) model).updateRenderedValue(this);
                }
                return;
            }
            if (icon != null)
                setIcon(null);
            if (value instanceof String) {
                ComponentFormat cf = getComponentFormat();
                if (cf == null) {
                    bodyText = Text.processTags((String) value, resolver);
                } else {
                    try {
                        bodyText = Text.processTags(TagResolver.formatObject(value, application.getLocale(), cf.parsedFormat, (cf.parsedFormat.getDisplayFormat() != null ? new ServoyMaskFormatter(cf.parsedFormat.getDisplayFormat(), true) : null)), resolver);
                    } catch (ParseException e) {
                        Debug.error(e);
                    }
                }
            } else {
                bodyText = getDefaultModelObjectAsString();
            }
        } else {
            bodyText = Text.processTags(tagText, resolver);
        }
    } else {
        Object modelObject = getDefaultModelObject();
        if (modelObject instanceof byte[]) {
            setIcon((byte[]) modelObject);
        } else if (icon != null) {
            setIcon(null);
        } else {
            ComponentFormat cf = getComponentFormat();
            if (cf == null) {
                bodyText = Text.processTags(getDefaultModelObjectAsString(), resolver);
            } else {
                try {
                    bodyText = TagResolver.formatObject(modelObject, application.getLocale(), cf.parsedFormat, (cf.parsedFormat.getDisplayFormat() != null ? new ServoyMaskFormatter(cf.parsedFormat.getDisplayFormat(), true) : null));
                } catch (ParseException e) {
                    Debug.error(e);
                }
            }
        }
    }
    if (HtmlUtils.startsWithHtml(bodyText)) {
        strippedText = StripHTMLTagsConverter.convertBodyText(this, bodyText, getScriptObject().trustDataAsHtml(), application.getFlattenedSolution());
        hasHTML = true;
    } else {
        strippedText.setBodyTxt(bodyText);
    }
    if (model instanceof RecordItemModel) {
        ((RecordItemModel) model).updateRenderedValue(this);
    }
}
Also used : StrippedText(com.servoy.j2db.server.headlessclient.dataui.StripHTMLTagsConverter.StrippedText) ServoyMaskFormatter(com.servoy.j2db.util.text.ServoyMaskFormatter) ParseException(java.text.ParseException) ComponentFormat(com.servoy.j2db.component.ComponentFormat)

Aggregations

ComponentFormat (com.servoy.j2db.component.ComponentFormat)1 StrippedText (com.servoy.j2db.server.headlessclient.dataui.StripHTMLTagsConverter.StrippedText)1 ServoyMaskFormatter (com.servoy.j2db.util.text.ServoyMaskFormatter)1 ParseException (java.text.ParseException)1