use of org.apache.wicket.request.Response in project midpoint by Evolveum.
the class Form method onComponentTagBody.
@Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
super.onComponentTagBody(markupStream, openTag);
if (addFakeInputFields) {
final Response response = getResponse();
response.write("<input style=\"display:none\">\n" + "<input type=\"password\" style=\"display:none\">");
}
}
use of org.apache.wicket.request.Response in project wicket by apache.
the class HtmlHeaderContainer method onComponentTagBody.
/**
* First render the body of the component. And if it is the header component of a Page (compared
* to a Panel or Border), then get the header sections from all component in the hierarchy and
* render them as well.
*/
@Override
public final void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
// We are able to automatically add <head> to the page if it is
// missing. But we only want to add it, if we have content to be
// written to its body. Thus we first write the output into a
// StringResponse and if not empty, we copy it to the original
// web response.
// Temporarily replace the web response with a String response
final Response webResponse = getResponse();
try {
// Create a (string) response for all headers contributed by any component on the Page.
final StringResponse response = new StringResponse();
getRequestCycle().setResponse(response);
IHeaderResponse headerResponse = getHeaderResponse();
if (!response.equals(headerResponse.getResponse())) {
getRequestCycle().setResponse(headerResponse.getResponse());
}
// Render the header sections of all components on the page
AbstractHeaderRenderStrategy.get().renderHeader(this, new HeaderStreamState(markupStream, openTag), getPage());
// Close the header response before rendering the header container itself
// See https://issues.apache.org/jira/browse/WICKET-3728
headerResponse.close();
// Cleanup extraneous CR and LF from the response
CharSequence output = getCleanResponse(response);
// Automatically add <head> if necessary
if (output.length() > 0) {
if (renderOpenAndCloseTags()) {
webResponse.write("<head>");
}
webResponse.write(output);
if (renderOpenAndCloseTags()) {
webResponse.write("</head>");
}
}
} finally {
// Restore the original response
getRequestCycle().setResponse(webResponse);
}
}
use of org.apache.wicket.request.Response in project wicket by apache.
the class HtmlHeaderContainer method renderHeaderTagBody.
/**
* Renders the content of the <head> section of the page, including <wicket:head>
* sections in subclasses of the page. For every child-component, the content is rendered to a
* string and passed to {@link IHeaderResponse}.
*
* @param headerStreamState
*/
public void renderHeaderTagBody(HeaderStreamState headerStreamState) {
if (headerStreamState == null)
return;
final Response oldResponse = getRequestCycle().getResponse();
try {
// Create a separate (string) response for the header container itself
final StringResponse bodyResponse = new StringResponse();
getRequestCycle().setResponse(bodyResponse);
// render the header section directly associated with the markup
super.onComponentTagBody(headerStreamState.getMarkupStream(), headerStreamState.getOpenTag());
CharSequence bodyOutput = getCleanResponse(bodyResponse);
if (bodyOutput.length() > 0) {
getHeaderResponse().render(new PageHeaderItem(bodyOutput));
}
} finally {
getRequestCycle().setResponse(oldResponse);
}
}
use of org.apache.wicket.request.Response in project wicket by apache.
the class ResponseBufferZone method execute.
public CharSequence execute() {
final int originalStreamPos = stream.getCurrentIndex();
final Response original = cycle.getResponse();
final StringResponse buffer = new StringResponse();
cycle.setResponse(buffer);
try {
executeInsideBufferedZone();
return buffer.getBuffer();
} finally {
cycle.setResponse(original);
stream.setCurrentIndex(originalStreamPos);
}
}
use of org.apache.wicket.request.Response in project wicket by apache.
the class BorderBehavior method afterRender.
@Override
public void afterRender(final Component component) {
final MarkupStream stream = getMarkupStream(component);
final Response response = component.getResponse();
while (stream.isCurrentIndexInsideTheStream()) {
MarkupElement elem = stream.get();
stream.next();
if (elem instanceof WicketTag) {
WicketTag wTag = (WicketTag) elem;
if (wTag.isBorderTag() && wTag.isClose()) {
break;
} else {
throw new WicketRuntimeException("Unexpected tag encountered in markup of component border " + getClass().getName() + ". Tag: " + wTag.toString() + ", expected tag: </wicket:border>");
}
}
response.write(elem.toCharSequence());
}
}
Aggregations