Example usage for org.apache.wicket.util.resource StringResourceStream StringResourceStream

List of usage examples for org.apache.wicket.util.resource StringResourceStream StringResourceStream

Introduction

In this page you can find the example usage for org.apache.wicket.util.resource StringResourceStream StringResourceStream.

Prototype

public StringResourceStream(final CharSequence string) 

Source Link

Document

Construct.

Usage

From source file:com.aplombee.TestQuickGridViewContainer.java

License:Apache License

@Override
public IResourceStream getMarkupResourceStream(MarkupContainer container, Class<?> containerClass) {
    return new StringResourceStream("<wicket:panel> " + "<table wicket:id=\"" + getQuickViewParent().getId()
            + "\">" + "<tr wicket:id=\"" + getQuickViewParent().getChild().getId() + "\"> "
            + "<td wicket:id=\"cols\"> </td>" + "</tr>" + "</table>" + " <div wicket:id=\""
            + getNavigator().getId() + "\"></div>" + "<a wicket:id= \"" + getLink().getId() + "\" > </a>"
            + "</wicket:panel>"

    );// ww  w  .ja va 2  s. co  m
}

From source file:com.aplombee.TestQuickViewContainer.java

License:Apache License

@Override
public IResourceStream getMarkupResourceStream(MarkupContainer container, Class<?> containerClass) {
    return new StringResourceStream(
            "<wicket:panel> " + "<div wicket:id=\"" + getQuickViewParent().getId() + "\">" +

                    "<div wicket:id=\"" + getQuickViewParent().getChild().getId() + "\"> </div>" +

                    "</div>" +

                    " <div wicket:id=\"" + getNavigator().getId() + "\"></div>" +

                    "<a wicket:id= \"" + getLink().getId() + "\" > </a>" +

                    "</wicket:panel>"

    );/* w  ww.j  a v a2  s  . c o  m*/
}

From source file:com.gitblit.wicket.freemarker.FreemarkerPanel.java

License:Apache License

/**
 * @see org.apache.wicket.markup.IMarkupResourceStreamProvider#getMarkupResourceStream(org.apache
 *      .wicket.MarkupContainer, java.lang.Class)
 *///  ww w  .  j a  va  2s.  c o  m
@Override
public final IResourceStream getMarkupResourceStream(MarkupContainer container, Class<?> containerClass) {
    Template template = getTemplate();
    if (template == null) {
        throw new WicketRuntimeException("could not find Freemarker template for panel: " + this);
    }

    // evaluate the template and return a new StringResourceStream
    StringBuffer sb = new StringBuffer();
    sb.append("<wicket:panel>");
    sb.append(evaluateFreemarkerTemplate(template));
    sb.append("</wicket:panel>");
    return new StringResourceStream(sb.toString());
}

From source file:com.googlecode.ounit.HtmlFile.java

License:Open Source License

@Override
public Markup getAssociatedMarkup() {
    File f = getFile();//from w  w w  . ja  v a2  s  .co  m

    if (!getFile().canRead()) {
        //return Markup.NO_MARKUP;
        return Markup.of("<wicket:panel></wicket:panel>");
    }

    final AppendingStringBuffer sb = new AppendingStringBuffer("<wicket:panel>");
    try {
        sb.append(f.readString());
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    sb.append("</wicket:panel>");
    InvalidMarkupFilter.removeInvalidMarkup(sb);

    return MarkupFactory.get().loadMarkup(this, new MarkupResourceStream(new StringResourceStream(sb)), false);
}

From source file:com.premiumminds.webapp.wicket.testing.ExtendedWicketTester.java

License:Open Source License

/**
 * Process a component. A web page will be automatically created with the {@code pageMarkup}
 * provided. In case {@code pageMarkup} is null, the markup will be automatically created with
 * {@link #createFormPageMarkup(String)}.
 * <p>/*ww  w . j a  v  a  2 s.com*/
 *     <strong>Note</strong>: the component id is set by the user. To
 *     reach any of its children use this id + their relative path to the component itself. For example
 *     if the started component has id <em>compId</em> and a Link child component component with id "link"
 *     then after starting the component you can click it with: <code>tester.clickLink("compId:link")</code>
 * </p>
 * 
 * @param <C>
 *            the type of the component
 * @param component
 *            the component to be tested
 * @param inputType
 *            the type of HTML input to be associated with the component to be tested
 * @param pageMarkup
 *            the markup for the Page that will be automatically created. May be {@code null}.
 * @return The component processed
 */
@SuppressWarnings("deprecation")
public final <C extends Component> C startComponentInForm(final C component, final String inputType,
        IMarkupFragment pageMarkup) {
    Args.notNull(component, "component");

    // Create a page object and assign the markup
    Page page = createFormPage();
    if (page == null) {
        fail("The automatically created page should not be null.");
    }

    // Automatically create the page markup if not provided
    if (pageMarkup == null) {
        String markup = createFormPageMarkup(component.getId(), inputType);
        if (markup == null) {
            fail("The markup for the automatically created page should not be null.");
        }

        try {
            // set a ContainerInfo to be able to use HtmlHeaderContainer so header contribution
            // still work. WICKET-3700
            ContainerInfo containerInfo = new ContainerInfo(page);
            MarkupResourceStream markupResourceStream = new MarkupResourceStream(
                    new StringResourceStream(markup), containerInfo, page.getClass());

            MarkupParser markupParser = getApplication().getMarkupSettings().getMarkupFactory()
                    .newMarkupParser(markupResourceStream);
            pageMarkup = markupParser.parse();
        } catch (Exception e) {
            fail("Error while parsing the markup for the autogenerated page: " + e.getMessage());
        }
    }

    if (page instanceof StartComponentInForm) {
        ((StartComponentInForm) page).setPageMarkup(pageMarkup);
    } else {
        page.setMarkup(pageMarkup);
    }

    // Add the child component
    Form<Void> form = new Form<Void>("form");
    page.add(form);
    form.add(component);

    // Preserve 'componentInForm' because #startPage() needs to null-fy it
    ComponentInForm oldComponentInForm = componentInForm;

    // Process the page
    startPage(page);

    // Remember the "root" component processes and return it
    if (oldComponentInForm != null) {
        componentInForm = oldComponentInForm;
    } else {
        componentInForm = new ComponentInForm();
        componentInForm.component = component;
    }
    return component;
}

From source file:de.alpharogroup.wicket.components.velocity.VelocityFieldsPanel.java

License:Apache License

/**
 * Instantiates a new {@link VelocityFieldsPanel}.
 *
 * @param id//from w w w.j  a  v a  2 s  .  c  o m
 *            the id
 * @param model
 *            the model
 */
public VelocityFieldsPanel(final String id, final IModel<List<WicketField<?>>> model) {
    super(id, model);
    final Map<String, List<WicketField<?>>> map = new HashMap<>();
    map.put("fields", model.getObject());
    final StringBuilder sb = new StringBuilder();

    for (final SimpleTag tag : model.getObject()) {
        sb.append(tag.toString());
    }
    final String tmp = sb.toString();

    final IResourceStream template = new StringResourceStream(tmp);
    final VelocityPanel velocityPanel = new VelocityPanel("velocityPanel", new MapModel<>(map)) {

        /** The Constant serialVersionUID. */
        private static final long serialVersionUID = 1L;

        /**
         * {@inheritDoc}
         */
        @Override
        protected IResourceStream getTemplateResource() {
            return template;
        }

        /**
         * {@inheritDoc}
         */
        @Override
        protected boolean parseGeneratedMarkup() {
            return true;
        }
    };
    add(velocityPanel);
    for (final WicketField<?> field : model.getObject()) {
        addChildComponent(field);
        velocityPanel.add(field.getComponent());
    }
}

From source file:fiftyfive.wicket.test.PageWithInlineMarkup.java

License:Apache License

@Override
public IMarkupFragment getMarkup() {
    StringResourceStream stream = new StringResourceStream(this.htmlMarkup);
    MarkupResourceStream mrs = new MarkupResourceStream(stream, new ContainerInfo(this), null);
    return MarkupFactory.get().loadMarkup(this, mrs, false);
}

From source file:gr.abiss.calipso.wicket.BasePanel.java

License:Open Source License

/**
 * &lt;div wicket:id="velocityPanelContainer"&gt;
 *      &lt;div wicket:id="velocityPanel"&gt;&lt;/div&gt;
 * &lt;/div&gt;/*from   www .  j  av  a  2 s  .  c o m*/
 * @param tmpl
 * @param context
 * @param parseGeneratedMarkup 
 */
protected void addVelocityTemplatePanel(WebMarkupContainer container, String containerId, String panelId,
        final String tmpl, HashMap<String, Object> context, final boolean parseGeneratedMarkup) {
    WebMarkupContainer velocityPanelContainer = new WebMarkupContainer(containerId);
    Panel velocityPanel;
    if (StringUtils.isNotBlank(tmpl)) {
        if (context == null) {
            context = new HashMap<String, Object>();
        }
        context.put("DateUtils", DateUtils.class);

        //context.put("dateTool", new new org.apache.velocity.tools.generic.DateTool());
        velocityPanel = new VelocityPanel(panelId, new Model(context)) {
            @Override
            protected IStringResourceStream getTemplateResource() {
                return new StringResourceStream(tmpl);
            }

            @Override
            protected boolean parseGeneratedMarkup() {
                return parseGeneratedMarkup;
            }
        };
    } else {
        velocityPanel = new EmptyPanel(panelId);
    }
    velocityPanelContainer.add(velocityPanel);
    container.add(velocityPanelContainer.setRenderBodyOnly(true));

}

From source file:jdave.wicket.ComponentSpecification.java

License:Apache License

/**
 * Start component for context, using page with given markup.
 * //www.  j av  a  2 s  . c  o m
 * @param model The model passed to component that is used for context.
 * @param pageMarkup Markup (as <code>java.lang.CharSequence</code>) of
 *            the page created to host the specified component.
 * @param rootComponentId Wicket id of the root component in the component
 *            markup hierarchy given by the <code>pageMarkup</code>
 *            parameter. This is the id of the component returned from
 *            <code>newComponent</code> method and used as context, often
 *            a MarkupContainer or Form.
 */
public C startComponent(final IModel<M> model, final CharSequence pageMarkup, final String rootComponentId) {
    return startComponent(model, new StringResourceStream(pageMarkup), rootComponentId);
}

From source file:org.apache.syncope.fit.console.TestPage.java

License:Apache License

@Override
public IResourceStream getMarkupResourceStream(final MarkupContainer container, final Class<?> containerClass) {
    return new StringResourceStream(
            "<html><body>" + "<form wicket:id=\"form\"><span wicket:id=\"field\"></span></form></body></html>");
}