use of org.apache.wicket.util.string.AppendingStringBuffer in project gitblit by gitblit.
the class SessionlessForm method onComponentTagBody.
/**
* Append an additional hidden input tag that forces Wicket to correctly
* determine the destination page class even after a session expiration or
* a server restart.
*
* @param markupStream
* The markup stream
* @param openTag
* The open tag for the body
*/
@Override
protected void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
// render the hidden bookmarkable page field
AppendingStringBuffer buffer = new AppendingStringBuffer(HIDDEN_DIV_START);
buffer.append("<input type=\"hidden\" name=\"").append(WebRequestCodingStrategy.BOOKMARKABLE_PAGE_PARAMETER_NAME).append("\" value=\":").append(pageClass.getName()).append("\" />");
// do not collide with any child wicket:id of the form.
if (pageParameters != null) {
for (String key : pageParameters.keySet()) {
Component c = get(key);
if (c != null) {
// this form has a field id which matches the
// parameter name, skip embedding a hidden value
log.warn(MessageFormat.format("Skipping page parameter \"{0}\" from sessionless form hidden fields because it collides with a form child wicket:id", key));
continue;
}
String value = pageParameters.getString(key);
buffer.append("<input type=\"hidden\" name=\"").append(recode(key)).append("\" value=\"").append(recode(value)).append("\" />");
}
}
buffer.append("</div>");
getResponse().write(buffer);
super.onComponentTagBody(markupStream, openTag);
}
Aggregations