/** * Parse the grid component to a {@link Sheet} object * * @param workbook * @throws IOException * @throws ResourceStreamNotFoundException * @throws ParseException */ public void parse(Component tableComponent) throws IOException, ResourceStreamNotFoundException, ParseException { try { BufferedWebResponse mockResponse = doRequest(tableComponent); doParse(mockResponse.getText(), tableComponent); } finally { afterParse(tableComponent); } }
/** * Collects the html generated by rendering a page. * * @param page * supplier of the page * @return the html rendered by the panel */ public CharSequence renderPage(final Supplier<? extends Page> page) { return inThreadContext(() -> { Request request = newRequest(); BufferedWebResponse response = new BufferedWebResponse(null); RequestCycle cycle = application.createRequestCycle(request, response); ThreadContext.setRequestCycle(cycle); page.get().renderPage(); return response.getText(); }); }
/** * Collects the html generated by rendering a page. * * @param page * supplier of the page * @return the html rendered by the panel */ public CharSequence renderPage(final Supplier<? extends Page> page) { return inThreadContext(() -> { Request request = newRequest(); BufferedWebResponse response = new BufferedWebResponse(null); RequestCycle cycle = application.createRequestCycle(request, response); ThreadContext.setRequestCycle(cycle); page.get().renderPage(); return response.getText(); }); }
@Override public void afterRender(final Component component) { final RequestCycle requestCycle = RequestCycle.get(); try { BufferedWebResponse tempResponse = (BufferedWebResponse)requestCycle.getResponse(); if (component instanceof Page && originalResponse instanceof WebResponse) { tempResponse.writeMetaData((WebResponse) originalResponse); } // Transform the data CharSequence output = transform(component, tempResponse.getText()); originalResponse.write(output); } catch (Exception ex) { throw new WicketRuntimeException("Error while transforming the output of component: " + component, ex); } finally { // Restore the original response object requestCycle.setResponse(originalResponse); } }
@Override public void afterRender(final Component component) { final RequestCycle requestCycle = RequestCycle.get(); try { BufferedWebResponse tempResponse = (BufferedWebResponse)requestCycle.getResponse(); if (component instanceof Page && originalResponse instanceof WebResponse) { tempResponse.writeMetaData((WebResponse) originalResponse); } // Transform the data CharSequence output = transform(component, tempResponse.getText()); originalResponse.write(output); } catch (Exception ex) { throw new WicketRuntimeException("Error while transforming the output of component: " + component, ex); } finally { // Restore the original response object requestCycle.setResponse(originalResponse); } }
return tempResponse.getText();
return tempResponse.getText();
/** * Collects the Html generated by the rendering a page. * <p> * Important note: Must be called on a thread bound to an application's {@link ThreadContext}! * * @param pageProvider * the provider of the page class/instance and its parameters * @return the html rendered by a page * * @see ThreadContext */ public static CharSequence renderPage(final PageProvider pageProvider) { Application application = Application.get(); RequestCycle originalRequestCycle = RequestCycle.get(); BufferedWebResponse tempResponse = new BufferedWebResponse(null); RequestCycle tempRequestCycle = application .createRequestCycle(originalRequestCycle.getRequest(), tempResponse); try { ThreadContext.setRequestCycle(tempRequestCycle); pageProvider.getPageInstance().renderPage(); } finally { ThreadContext.setRequestCycle(originalRequestCycle); } return tempResponse.getText(); }
/** * Collects the Html generated by the rendering a page. * <p> * Important note: Must be called on a thread bound to an application's {@link ThreadContext}! * * @param pageProvider * the provider of the page class/instance and its parameters * @return the html rendered by a page * * @see ThreadContext */ public static CharSequence renderPage(final PageProvider pageProvider) { Application application = Application.get(); RequestCycle originalRequestCycle = RequestCycle.get(); BufferedWebResponse tempResponse = new BufferedWebResponse(null); RequestCycle tempRequestCycle = application .createRequestCycle(originalRequestCycle.getRequest(), tempResponse); try { ThreadContext.setRequestCycle(tempRequestCycle); pageProvider.getPageInstance().renderPage(); } finally { ThreadContext.setRequestCycle(originalRequestCycle); } return tempResponse.getText(); }