Example usage for org.apache.wicket.markup.html.basic Label setEscapeModelStrings

List of usage examples for org.apache.wicket.markup.html.basic Label setEscapeModelStrings

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.basic Label setEscapeModelStrings.

Prototype

public final Component setEscapeModelStrings(final boolean escapeMarkup) 

Source Link

Document

Sets whether model strings should be escaped.

Usage

From source file:$.BootstrapFeedbackPanel.java

License:Apache License

/**
     * Generates a component that is used to display the message inside the
     * feedback panel. This component must handle being attached to
     * <code>span</code> tags.
     * /*from  w w  w  .j a v  a  2  s .  c o m*/
     * By default a {@link Label} is used.
     * 
     * Note that the created component is expected to respect feedback panel's
     * {@link #getEscapeModelStrings()} value
     * 
     * @param id
     *            parent id
     * @param message
     *            feedback message
     * @return component used to display the message
     */
    protected Component newMessageDisplayComponent(String id, FeedbackMessage message) {
        Serializable serializable = message.getMessage();
        Label label = new Label(id, (serializable == null) ? "" : serializable.toString());
        label.setEscapeModelStrings(BootstrapFeedbackPanel.this.getEscapeModelStrings());
        return label;
    }

From source file:au.org.theark.lims.web.component.button.PrinterListPanel.java

License:Open Source License

private void initPanel() {
    DropDownChoice<String> printerListDdc = new DropDownChoice<String>("printerList",
            new PropertyModel<String>(this, "selected"), PRINTERLIST);
    printerListDdc.add(new AttributeModifier("name", "printerList"));
    printerListDdc.add(new AttributeModifier("onchange", "changeHiddenInput(this)"));
    printerListDdc.setOutputMarkupPlaceholderTag(true);
    this.add(printerListDdc);

    selectedPrinter = new HiddenField<String>("selectedPrinter", new PropertyModel<String>(this, "selected"));
    selectedPrinter.setOutputMarkupPlaceholderTag(true);
    selectedPrinter.add(new AttributeModifier("name", "selectedPrinter"));
    selectedPrinter.add(new AbstractDefaultAjaxBehavior() {
        private static final long serialVersionUID = 1L;

        @Override//from  w  w  w .  j  a  va2 s.  co m
        protected void respond(AjaxRequestTarget arg0) {
            StringValue selectedPrinter = RequestCycle.get().getRequest().getQueryParameters()
                    .getParameterValue("selectedPrinter");
            selected = selectedPrinter.toString();
        }
    });
    this.add(selectedPrinter);

    StringBuilder javaScript = new StringBuilder();
    javaScript.append("function findPrinters() {");
    javaScript.append("\n");
    javaScript.append("   var applet = document.jZebra;");
    javaScript.append("\n");
    javaScript.append("   if (applet != null) {");
    javaScript.append("\n");
    javaScript.append("      document.getElementById('");
    javaScript.append(printerListDdc.getMarkupId());
    javaScript.append("').disabled = false;");
    javaScript.append("\n");
    javaScript.append("      var listing = applet.getPrinters();");
    javaScript.append("\n");
    javaScript.append("      var printers = listing.split(',');\n");
    javaScript.append("      var objHidden = document.getElementById('");
    javaScript.append(selectedPrinter.getMarkupId());
    javaScript.append("');\n");
    javaScript.append("\n");
    javaScript.append("      for ( var i in printers) {");
    javaScript.append("\n");
    javaScript.append("         if(objHidden.value == printers[i]) {\n");
    javaScript.append("            document.getElementById('");
    javaScript.append(printerListDdc.getMarkupId());
    javaScript.append("').options[i] = new Option(printers[i], printers[i], true, true);\n");
    javaScript.append("         } else {\n");
    javaScript.append("            document.getElementById('");
    javaScript.append(printerListDdc.getMarkupId());
    javaScript.append("').options[i] = new Option(printers[i], printers[i], false, false);\n");
    javaScript.append("         }\n");
    javaScript.append("      }");
    javaScript.append("\n");
    javaScript.append("   } else {");
    javaScript.append("\n");
    javaScript.append("      document.getElementById('");
    javaScript.append(printerListDdc.getMarkupId());
    javaScript.append("').options[i] = new Option('N/A');");
    javaScript.append("\n");
    javaScript.append("      document.getElementById('");
    javaScript.append(printerListDdc.getMarkupId());
    javaScript.append("').disabled = true;");
    javaScript.append("\n");
    javaScript.append("   }");
    javaScript.append("\n");
    javaScript.append("}");
    javaScript.append("\n");
    javaScript.append("\n");
    javaScript.append("function changeHiddenInput (objDropDown) {");
    javaScript.append("\n");
    javaScript.append("   var objHidden = document.getElementById('");
    javaScript.append(selectedPrinter.getMarkupId());
    javaScript.append("');\n");
    javaScript.append("   objHidden.value = objDropDown.value;");
    javaScript.append("\n");
    javaScript.append("   callWicket(objDropDown.value);");
    javaScript.append("}");

    final Label script = new Label("script", javaScript.toString());
    script.setOutputMarkupPlaceholderTag(true);
    script.add(new AttributeModifier("onload", "findPrinters()"));
    script.setEscapeModelStrings(false); // do not HTML escape JavaScript code
    this.add(script);
}

From source file:biz.turnonline.ecosystem.origin.frontend.page.DecoratedPage.java

License:Apache License

protected Component newHeader(String componentId) {
    Label header = new Label(componentId, new I18NResourceModel("header." + getClass().getSimpleName()));
    header.setEscapeModelStrings(false);
    return header;
}

From source file:ch.qos.mistletoe.wicket.TestReportPanel.java

License:Open Source License

void handle_NOT_OK_Description() {
    Throwable t = testReport.getThrowable();

    ExceptionHelper ex = new ExceptionHelper(t);

    final WebMarkupContainer parent = new WebMarkupContainer(Constants.PAYLOAD_ID);
    add(parent);// w  ww  .  j av a2s  . c o m
    Label exception = new Label(Constants.NODE_ID, ex.asString());
    exception.setEscapeModelStrings(false);
    exception.add(new AttributeModifier("class", "exception"));
    parent.add(exception);
    if (ex.getLines() > 50) {
        System.out.println("ex.getLines() > 50");
        AttributeModifier sam = new AttributeModifier("style", "height: 40em; overflow: scroll;");
        exception.add(sam);
    }
}

From source file:com.aipo.mobycket.wicket.markup.html.panel.CssFeedbackPanel.java

License:Apache License

/**
 * Generates a component that is used to display the message inside the
 * feedback panel. This component must handle being attached to
 * <code>span</code> tags./*from  w ww  . j a  v a2 s.  c  om*/
 * 
 * By default a {@link Label} is used.
 * 
 * Note that the created component is expected to respect feedback panel's
 * {@link #getEscapeModelStrings()} value
 * 
 * @param id
 *          parent id
 * @param message
 *          feedback message
 * @return component used to display the message
 */
protected Component newMessageDisplayComponent(String id, FeedbackMessage message) {
    Serializable serializable = message.getMessage();
    Label label = new Label(id, (serializable == null) ? "" : serializable.toString());
    label.setEscapeModelStrings(CssFeedbackPanel.this.getEscapeModelStrings());
    return label;
}

From source file:com.axway.ats.testexplorer.pages.model.BaseCopyPage.java

License:Apache License

public BaseCopyPage(PageParameters parameters) {

    super(parameters);

    this.form = new Form<Object>("form");
    addCopyButton(form);/* w w w . jav  a 2 s . com*/
    addCopyHiddenButton(form);
    add(form);

    IModel<List<String>> consoleModel = new LoadableDetachableModel<List<String>>() {

        private static final long serialVersionUID = 1L;

        protected List<String> load() {

            int size = webConsole.size();
            if (size > MAX_CONSOLE_LINES) {
                webConsole.subList(0, size - MAX_CONSOLE_LINES).clear();
            }
            return webConsole;
        }
    };

    ListView<String> messages = new ListView<String>("messages", consoleModel) {

        private static final long serialVersionUID = 1L;

        protected void populateItem(ListItem<String> item) {

            Label label = new Label("message", item.getModelObject());
            label.setEscapeModelStrings(false);
            item.add(label);
        }
    };
    messages.setOutputMarkupId(true);

    consoleContainer = new WebMarkupContainer("webConsole");
    consoleContainer.setOutputMarkupId(true);
    consoleContainer.add(messages);

    add(consoleContainer);
}

From source file:com.axway.ats.testexplorer.pages.model.ScenarioDescriptionColumn.java

License:Apache License

@Override
public Component newCell(WebMarkupContainer parent, String componentId, IModel rowModel) {

    final Scenario scenario = (Scenario) rowModel.getObject();
    String description = scenario.description;
    if (description == null) {
        description = "";
    }/* w w w.ja va  2s.c o m*/
    IModel<String> labelModel = new Model<String>(description);
    Label label = new Label(componentId, labelModel);
    if (description.length() > 0 && description.contains("://")) {

        description = description.replace("<", "&lt;").replace(">", "&gt;");

        // search for links with wiki syntax eg. [Link text|http://some.rul.com/test.html]
        StringBuffer sb = new StringBuffer(description.length());
        Matcher wikiUrlMatcher = wikiUrlPattern.matcher(description);
        while (wikiUrlMatcher.find()) {
            wikiUrlMatcher.appendReplacement(sb, "<a href=\"$2\" class=\"linkInTable\">$1</a>");
        }
        wikiUrlMatcher.appendTail(sb);
        description = sb.toString();

        // search for quoted links eg. "http://some.rul.com/read me/test spaces.html"
        sb = new StringBuffer(description.length());
        Matcher quotedUrlMatcher = quotedUrlPattern.matcher(description);
        while (quotedUrlMatcher.find()) {
            quotedUrlMatcher.appendReplacement(sb, "<a href=\"$1\" class=\"linkInTable\">$1</a>");
        }
        quotedUrlMatcher.appendTail(sb);
        description = sb.toString();

        // search for regular links(without spaces) eg. http://some.rul.com/read_me.txt
        sb = new StringBuffer(description.length());
        Matcher withoutSpaceMatcher = withoutSpaceUrlPattern.matcher(description);
        while (withoutSpaceMatcher.find()) {
            withoutSpaceMatcher.appendReplacement(sb, "<a href=\"$1\" class=\"linkInTable\">$1</a>");
        }
        withoutSpaceMatcher.appendTail(sb);

        labelModel.setObject(sb.toString());
        label.setEscapeModelStrings(false);
    }

    return label;
}

From source file:com.axway.ats.testexplorer.pages.reports.compare.CompareRunsPage.java

License:Apache License

private ListView<List<TestcasesTableCell>> getTestcasesTable(
        List<List<TestcasesTableCell>> testcasesTableModel) {

    ListView<List<TestcasesTableCell>> statisticDetailsTable = new ListView<List<TestcasesTableCell>>(
            "runsDetailsRows", testcasesTableModel) {

        private static final long serialVersionUID = 1L;

        @Override// w  w w . jav a  2 s.c om
        protected void populateItem(ListItem<List<TestcasesTableCell>> item) {

            // table TR
            List<TestcasesTableCell> tdObjects = item.getModelObject();
            final int columnsCount = tdObjects.size();

            if (item.getIndex() == 0) {
                item.add(AttributeModifier.append("class", "runName"));
            } else if (item.getIndex() == 1) {
                item.add(AttributeModifier.append("class", "runDuration"));
            } else if (item.getIndex() == 2) {
                item.add(AttributeModifier.append("class", "testStateFilter"));
            } else if (item.getIndex() == 3 || item.getIndex() == 4) {
                // this is the Apply Filter Button row, we will use colspan, so we need only one column
                tdObjects = item.getModelObject().subList(0, 1);
            } else if (item.getIndex() % 2 != 0) {
                item.add(AttributeModifier.append("class", "oddRow"));
            } else {
                item.add(AttributeModifier.append("class", "evenRow"));
            }

            item.add(new ListView<TestcasesTableCell>("runsDetailsColumns", tdObjects) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void populateItem(ListItem<TestcasesTableCell> item) {

                    // table TD
                    if (item.getIndex() == 0) {
                        item.add(AttributeModifier.append("class", "compareTest_firstCell"));
                    }
                    TestcasesTableCell cell = item.getModelObject();
                    if (cell.isFilter) {

                        item.add(new CheckBox("showOnlyTestsPresentInAllRuns").setVisible(false));
                        item.add(new Label("label", "").setVisible(false));
                        item.add(getTestStateChoices(cell.labelText));

                    } else if (cell.isShowOnlyTestsPresentInAllRunsCheckbox) {

                        item.add(AttributeModifier.replace("class", "compareTest_checkboxCell"));
                        item.add(AttributeModifier.replace("colspan", columnsCount));

                        item.add(new CheckBox("showOnlyTestsPresentInAllRuns",
                                showOnlyTestsPresentInAllRunsModel).setOutputMarkupId(true)
                                        .setMarkupId("showOnlyTestsPresentInAllRuns"));
                        item.add(new Label("label",
                                "<label for=\"showOnlyTestsPresentInAllRuns\">Show only tests present in all runs</label>")
                                        .setEscapeModelStrings(false));
                        item.add(getTestStateChoices(null).setVisible(false));
                    } else if (cell.isFilterButton) {

                        item.add(AttributeModifier.replace("class", "compareTest_applyFilterButtonCell"));
                        item.add(AttributeModifier.replace("colspan", columnsCount));

                        item.add(new CheckBox("showOnlyTestsPresentInAllRuns").setVisible(false));
                        Label label = new Label("label",
                                "<a href=\"#\" class=\"button applyFilterButton\" onclick=\"document.getElementById('applyFilterButton').click();\"><span>Apply Filter</span></a>");
                        label.setEscapeModelStrings(false);
                        item.add(label);
                        item.add(getTestStateChoices(null).setVisible(false));
                    } else {

                        if (cell.cssClass != null) {
                            item.add(AttributeModifier.append("class", cell.cssClass));
                        }
                        item.add(new CheckBox("showOnlyTestsPresentInAllRuns").setVisible(false));
                        Label label = null;
                        if (cell.url != null) {
                            label = new Label("label", "<a href=\"" + cell.url + "\" target=\"_blank\">"
                                    + cell.labelText + "</a>");
                        } else {
                            label = new Label("label", cell.labelText);
                        }
                        label.setEscapeModelStrings(false);
                        item.add(label);
                        item.add(getTestStateChoices(null).setVisible(false));
                    }
                }
            });
        }
    };

    statisticDetailsTable.setOutputMarkupId(true);
    return statisticDetailsTable;
}

From source file:com.axway.ats.testexplorer.pages.testcase.statistics.charts.ChartsPanel.java

License:Apache License

private ListView getChartListViewComponent() {

    // update the content of the ListView container
    refreshDiagramContent();/*  w ww.j  a  va 2  s  . c  o  m*/

    final List<String> charts = new ArrayList<String>(diagramContent.keySet());

    return new ListView("chartsListView", charts) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem item) {

            String diagramName = charts.get(item.getIndex());
            List<ChartData> chartData = new ArrayList<ChartData>();
            for (DbStatisticDescription stat : diagramContent.get(diagramName)) {
                chartData.add(stat.getChartData());
            }

            Label chartTitle = new Label("chartTitle", diagramName);
            item.add(chartTitle);

            final String chartScript = getChartScript(chartData, chartId++);
            final Label chart = new Label("chartScriptContainer", chartScript);
            chart.setEscapeModelStrings(false);

            CsvWriter csvWriter = new CsvWriter(chartData);
            DownloadLink downloadChartDataLink = csvWriter.getDownloadChartDataLink();

            AjaxLink refreshButton = getRefreshChartLink(charts.get(item.getIndex()));

            item.add(chart);
            item.add(downloadChartDataLink);
            item.add(refreshButton);
        }
    };
}

From source file:com.axway.ats.testexplorer.pages.testcase.statistics.charts.ChartsPanel.java

License:Apache License

/**
* @return statistic details component with all Min, Avg and Max values
*//* w w w.j  a  v  a2s .c om*/
private Component getStatisticsDetailsComponent() {

    List<List<StatisticsTableCell>> rows = new ArrayList<List<StatisticsTableCell>>();
    List<StatisticsTableCell> columns = new ArrayList<StatisticsTableCell>();

    // add title
    columns.add(new StatisticsTableCell(
            "<img class=\"arrowUD\" src=\"images/up.png\"> System statistic details", false));

    // add machine value columns
    List<MachineDescription> mergedMachineDescriptions = getMergedMachineDescriptions();
    columns.add(new StatisticsTableCell(true, getMachineAliasModel("Values")));
    rows.add(columns);

    rows.addAll(systemStatisticsPanel.generateStatisticDetailRows(mergedMachineDescriptions, diagramContent));
    rows.addAll(userStatisticsPanel.generateStatisticDetailRows(mergedMachineDescriptions, diagramContent));
    rows.addAll(actionStatisticsPanel.generateStatisticDetailRows(mergedMachineDescriptions, diagramContent));

    ListView<List<StatisticsTableCell>> statisticDetailsTable = new ListView<List<StatisticsTableCell>>(
            "statDetailsRows", rows) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<List<StatisticsTableCell>> item) {

            // table TR
            if (item.getIndex() == 0) {
                item.add(AttributeModifier.replace("class", "statDetailsHeaderRow"));
                item.add(AttributeModifier.replace("onclick",
                        "showOrHideTableRows('statDetailsTable',1,false);"));
            } else if (item.getIndex() > 1 && item.getModelObject().get(0).labelText.contains("statUnit")) {
                item.add(AttributeModifier.replace("class", "statDetailsStatNameRow"));
            }
            item.add(new ListView<StatisticsTableCell>("statDetailsColumns", item.getModelObject()) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void populateItem(ListItem<StatisticsTableCell> item) {

                    // table TD
                    if (item.getIndex() > 0) { // skip the first column
                        item.add(AttributeModifier.replace("class", "statDetailsCenCol"));
                    }
                    StatisticsTableCell cell = item.getModelObject();
                    Label label = null;
                    if (cell.isInputText) {
                        label = new Label("label", cell.getMachineLabelModel());
                        if (cell.getMachineLabelModel() != null) {
                            rememberMachineAliasLabel(label);
                        }
                    } else {
                        label = new Label("label", cell.labelText);
                    }
                    label.setEscapeModelStrings(false);
                    item.add(label);
                }
            });
        }
    };

    return statisticDetailsTable;
}