List of usage examples for org.apache.wicket Page setMarkup
public final Component setMarkup(final IMarkupFragment markup)
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>//from w w w.j a v a2 s.c o m * <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; }