Java Code Examples for org.apache.wicket.util.resource.StringResourceStream

The following examples show how to use org.apache.wicket.util.resource.StringResourceStream. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private IMarkupFragment createFormPageMarkup(final String componentId) {
	String markup = /*"<html><head></head>" +*/ "<body><form wicket:id='form'><select wicket:id='" + componentId
			+ "' /></form></body>" /*+ "</html>"*/;

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

		MarkupParser markupParser = getTester().getApplication().getMarkupSettings().getMarkupFactory()
				.newMarkupParser(markupResourceStream);
		return markupParser.parse();
	} catch (Exception e) {
		fail("Error while parsing the markup for the autogenerated page: " + e.getMessage());
		return null;
	}
}
 
Example 2
Source Project: openmeetings   Source File: ChatToolbar.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected IResourceStream getResourceStream(Attributes attributes) {
	final boolean admin = hasAdminLevel(getRights());
	final StringBuilder sb = new StringBuilder();
	chatForm.process(
			() -> {
				if (admin) {
					setFileName(String.format(CHAT_FNAME_TMPL, "global"));
					export(chatDao.getGlobal(0, Integer.MAX_VALUE), sb);
				}
				return true;
			}
			, r -> {
				if (admin || isModerator(cm, getUserId(), r.getId())) {
					setFileName(String.format(CHAT_FNAME_TMPL, "room_" + r.getId()));
					export(chatDao.getRoom(r.getId(), 0, Integer.MAX_VALUE, true), sb);
				}
				return true;
			}, u -> {
				setFileName(String.format(CHAT_FNAME_TMPL, "user_" + u.getId()));
				export(chatDao.getUser(u.getId(), 0, Integer.MAX_VALUE), sb);
				return true;
			});
	StringResourceStream srs = new StringResourceStream(sb, "text/csv");
	srs.setCharset(UTF_8);
	return srs;
}
 
Example 3
Source Project: inception   Source File: WebSocketTestPage.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public IResourceStream getMarkupResourceStream(MarkupContainer aContainer,
        Class<?> aContainerClass)
{
    return new StringResourceStream("<html><body></body></html>");
}
 
Example 4
Source Project: onedev   Source File: AbstractWebSocketProcessor.java    License: MIT License 4 votes vote down vote up
@Override
public IResourceStream getMarkupResourceStream(MarkupContainer container, Class<?> containerClass)
{
	return new StringResourceStream("");
}
 
Example 5
/**
 * 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, String)}.
 * <p>
 *     <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;
}
 
Example 6
Source Project: syncope   Source File: TestPage.java    License: Apache License 2.0 4 votes vote down vote up
@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>");
}