List of usage examples for org.apache.wicket Component getRenderBodyOnly
public final boolean getRenderBodyOnly()
From source file:com.evolveum.midpoint.web.util.SchrodingerComponentInitListener.java
License:Apache License
private void writeDataAttribute(Component component, String key, String value) { if (!component.getRenderBodyOnly()) { component.add(AttributeModifier.append(ATTR_DATA_PREFIX + key, value)); return;//from w w w .j ava 2 s.c om } if ("title".equals(component.getId()) && component.getParent() instanceof Page) { // we don't want to alter <title> element return; } component.add(new Behavior() { @Override public void afterRender(Component component) { Response resp = component.getResponse(); resp.write("<schrodinger " + ATTR_DATA_PREFIX + key + "=\"" + value + "\"></schrodinger>"); } }); }
From source file:com.googlecode.wicketwebbeans.containers.BeanForm.java
License:Apache License
private void refreshComponent(final AjaxRequestTarget target, Component targetComponent) { // Refresh this field. We have to find the parent Field to do this. MarkupContainer field;/* w ww .ja va 2 s .com*/ if (targetComponent instanceof Field) { field = (MarkupContainer) targetComponent; } else { field = targetComponent.findParent(AbstractField.class); } if (field != null) { if (!field.getRenderBodyOnly()) { target.addComponent(field); } else { // Field is RenderBodyOnly, have to add children individually field.visitChildren(new IVisitor<Component>() { public Object component(Component component) { if (!component.getRenderBodyOnly()) { target.addComponent(component); } return IVisitor.CONTINUE_TRAVERSAL; } }); } } else { target.addComponent(targetComponent); } }
From source file:com.wiquery.plugins.jqgrid.component.XMLDataRequestTarget.java
License:Apache License
/** * /*from w w w . jav a2s .c o m*/ * @param response * @param markupId * id of client-side dom element * @param component * component to render */ private void respondComponent(final Response response, final String markupId, final Component component, StringBuffer writer) { if (component.getRenderBodyOnly() == true) { throw new IllegalStateException( "Ajax render cannot be called on component that has setRenderBodyOnly enabled. Component: " + component.toString()); } component.setOutputMarkupId(true); // substitute our encoding response for the real one so we can capture // component's markup in a manner safe for transport inside CDATA block final Response originalResponse = response; encodingBodyResponse.reset(); RequestCycle.get().setResponse(encodingBodyResponse); // Initialize temporary variables final Page page = component.findParent(Page.class); if (page == null) { // dont throw an exception but just ignore this component, somehow // it got // removed from the page. // throw new IllegalStateException( // "Ajax request attempted on a component that is not associated // with a Page"); LOG.debug("component: " + component + " with markupid: " + markupId + " not rendered because it was already removed from page"); return; } page.startComponentRender(component); try { component.prepareForRender(); // render any associated headers of the component respondHeaderContribution(response, component, writer); } catch (RuntimeException e) { try { component.afterRender(); } catch (RuntimeException e2) { // ignore this one could be a result off. } // Restore original response RequestCycle.get().setResponse(originalResponse); encodingBodyResponse.reset(); throw e; } try { component.renderComponent(); } catch (RuntimeException e) { RequestCycle.get().setResponse(originalResponse); encodingBodyResponse.reset(); throw e; } page.endComponentRender(component); // Restore original response RequestCycle.get().setResponse(originalResponse); writer.append("<component id=\""); writer.append(markupId); writer.append("\" "); if (encodingBodyResponse.isContentsEncoded()) { writer.append(" encoding=\""); writer.append(getEncodingName()); writer.append("\" "); } writer.append("><![CDATA["); writer.append(encodingBodyResponse.getContents()); writer.append("]]></component>"); encodingBodyResponse.reset(); }
From source file:sf.wicklet.gwt.server.ajax.impl.GwtAjaxWickletResponse.java
License:Apache License
@Override protected void writeComponent(final Response response, final String markupId, final Component component, final String encoding) { if (component.getRenderBodyOnly() == true) { throw new IllegalStateException( "Ajax render cannot be called on component that has setRenderBodyOnly enabled. Component: " + component.toString()); }/* w w w . j a v a 2 s . com*/ component.setOutputMarkupId(true); // substitute our encoding response for the real one so we can capture // component's markup in a manner safe for transport inside CDATA block encodingBodyResponse.reset(); RequestCycle.get().setResponse(encodingBodyResponse); // Initialize temporary variables final Page page = component.findParent(Page.class); if (page == null) { // dont throw an exception but just ignore this component, somehow // it got removed from the page. AbstractGwtAjaxResponse.LOG.debug("component: " + component + " with markupid: " + markupId + " not rendered because it was already removed from page"); return; } page.startComponentRender(component); try { component.prepareForRender(); // render any associated headers of the component writeHeaderContribution(response, component); } catch (final RuntimeException e) { try { component.afterRender(); } catch (final RuntimeException e2) { // ignore this one could be a result off. } // Restore original response RequestCycle.get().setResponse(response); encodingBodyResponse.reset(); throw e; } try { component.render(); } catch (final RuntimeException e) { RequestCycle.get().setResponse(response); encodingBodyResponse.reset(); throw e; } page.endComponentRender(component); // Restore original response RequestCycle.get().setResponse(response); response.write("<component id=\""); response.write(markupId); response.write("\" "); // if (encodingBodyResponse.isContentsEncoded()) { // response.write(" encoding=\""); // response.write(getEncodingName()); // response.write("\" "); // } response.write(" encoding=\"escaped-xml\" >"); response.write(XmlUtil.escXml(encodingBodyResponse.getContents())); response.write("</component>"); encodingBodyResponse.reset(); }