本文整理汇总了Java中org.apache.wicket.util.string.AppendingStringBuffer.append方法的典型用法代码示例。如果您正苦于以下问题:Java AppendingStringBuffer.append方法的具体用法?Java AppendingStringBuffer.append怎么用?Java AppendingStringBuffer.append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.wicket.util.string.AppendingStringBuffer
的用法示例。
在下文中一共展示了AppendingStringBuffer.append方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toMultilineMarkup
import org.apache.wicket.util.string.AppendingStringBuffer; //导入方法依赖的package包/类
private CharSequence toMultilineMarkup(final CharSequence s) {
if (s == null) {
return null;
}
final AppendingStringBuffer buffer = new AppendingStringBuffer();
for (int i = 0; i < s.length(); i++) {
final char c = s.charAt(i);
switch (c) {
case '\n':
buffer.append("<br/>");
break;
case '\r':
break;
default:
buffer.append(c);
break;
}
}
return buffer;
}
示例2: appendOptionHtml
import org.apache.wicket.util.string.AppendingStringBuffer; //导入方法依赖的package包/类
@Override
protected void appendOptionHtml(AppendingStringBuffer buffer, User choice, int index, String selected) {
if (isNewGroup(choice)) {
if (!isFirst(index)) {
buffer.append("</optgroup>");
}
buffer.append("<optgroup label='");
buffer.append(Strings.escapeMarkup(getGroupLabel(choice)));
buffer.append("'>");
}
super.appendOptionHtml(buffer, choice, index, selected);
if (isLast(index)) {
buffer.append("</optgroup>");
}
last = choice;
}
示例3: appendOptionHtml
import org.apache.wicket.util.string.AppendingStringBuffer; //导入方法依赖的package包/类
@Override
protected void appendOptionHtml(AppendingStringBuffer buffer, T choice, int index, String selected) {
if (grouped) {
if (last == null || isNewGroup(choice, last)) {
if (!isFirst(index)) {
buffer.append("</optgroup>");
}
buffer.append("<optgroup label='");
buffer.append(Strings.escapeMarkup(getGroupLabel(choice)));
buffer.append("'>");
}
super.appendOptionHtml(buffer, choice, index, selected);
if (isLast(index)) {
buffer.append("</optgroup>");
}
last = choice;
} else {
super.appendOptionHtml(buffer, choice, index, selected);
}
}
示例4: appendOptionHtml
import org.apache.wicket.util.string.AppendingStringBuffer; //导入方法依赖的package包/类
@Override
protected void appendOptionHtml(AppendingStringBuffer buffer, E choice, int index, String selected) {
if (grouped) {
if (last == null || isNewGroup(choice, last)) {
if (!isFirst(index)) {
buffer.append("</optgroup>");
}
buffer.append("<optgroup label='");
buffer.append(Strings.escapeMarkup(getGroupLabel(choice)));
buffer.append("'>");
}
super.appendOptionHtml(buffer, choice, index, selected);
if (isLast(index)) {
buffer.append("</optgroup>");
}
last = choice;
} else {
super.appendOptionHtml(buffer, choice, index, selected);
}
}
示例5: filter
import org.apache.wicket.util.string.AppendingStringBuffer; //导入方法依赖的package包/类
/**
* @see org.apache.wicket.IResponseFilter#filter(AppendingStringBuffer)
*/
public AppendingStringBuffer filter(AppendingStringBuffer responseBuffer) {
String responseHtmlTagUsed = "</html>";
int index = responseBuffer.indexOf(responseHtmlTagUsed);
long timeTaken = System.currentTimeMillis() - RequestCycle.get().getStartTime();
if (index != -1) {
AppendingStringBuffer script = new AppendingStringBuffer(125);
script.append("\n<!--");
// server time used
script.append("\n window.pagemeta.serverPageRenderingTime=' ");
script.append(((double)timeTaken) / 1000);
script.append("s';\n");
// server ip
script.append("\n window.pagemeta.serverIP='");
script.append(retrieveServerIP());
script.append("';\n");
// rendering date
script.append("\n window.pagemeta.renderingDate='");
script.append(retrieveRenderingDateStr());
script.append("';\n");
script.append(" -->\n");
responseBuffer.insert(index, script);
}
log.debug(timeTaken + "ms server time taken for request " +
RequestCycle.get().getRequest().getUrl() + " response size: " + responseBuffer.length());
return responseBuffer;
}
示例6: appendOptionHtml
import org.apache.wicket.util.string.AppendingStringBuffer; //导入方法依赖的package包/类
@SuppressWarnings({"RefusedBequest", "unchecked"})
@Override
protected void appendOptionHtml(AppendingStringBuffer buffer, File choice, int index, String selected) {
IChoiceRenderer<? super File> renderer = getChoiceRenderer();
Object objectValue = renderer.getDisplayValue(choice);
String displayValue = "";
if (objectValue != null) {
IConverter converter = getConverter(objectValue.getClass());
displayValue = converter
.convertToString(objectValue, getLocale());
}
if ("".equals(displayValue)) {
displayValue = getString("file.browser.breadCrumbs.root", null);
}
buffer.append("\n<option ");
if (isSelected(choice, index, selected)) {
buffer.append("selected=\"selected\" ");
}
buffer.append("style=\"padding-left: " + (index * 10 + 18) + "px; " +
"background-position: " + index * 10 + "px\" ");
index++;
buffer.append("value=\"");
buffer.append(Strings.escapeMarkup(renderer.getIdValue(choice, index)));
buffer.append("\">");
CharSequence escaped = escapeOptionHtml(displayValue);
buffer.append(escaped);
buffer.append("</option>");
}
示例7: renderHead
import org.apache.wicket.util.string.AppendingStringBuffer; //导入方法依赖的package包/类
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
AppendingStringBuffer asb = new AppendingStringBuffer();
asb.append("function attachChoiceHandler(markupId, callbackScript) {\n");
asb.append(" var inputNode = wicketGet(markupId);\n");
asb.append(" var inputType = inputNode.type.toLowerCase();\n");
asb.append(" if (inputType == 'checkbox' || inputType == 'radio') {\n");
asb.append(" Wicket.Event.add(inputNode, 'click', callbackScript);\n");
asb.append(" }\n");
asb.append("}\n");
response.renderJavascript(asb, "attachChoiceParent");
}
示例8: setOptionAttributes
import org.apache.wicket.util.string.AppendingStringBuffer; //导入方法依赖的package包/类
@Override
protected void setOptionAttributes(AppendingStringBuffer buffer, T choice,
int index, String selected) {
super.setOptionAttributes(buffer, choice, index, selected);
int depth = calculateDepth(choice);
buffer.append(" class=\"treedepth").append(depth).append("\"");
if(disableParents && choice.getChildren()!=null && !choice.getChildren().isEmpty())
buffer.append(" disabled=\"disabled\"");
}
示例9: onComponentTagBody
import org.apache.wicket.util.string.AppendingStringBuffer; //导入方法依赖的package包/类
/**
* 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("\" />");
// insert the page parameters, if any, as hidden fields as long as they
// 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
logger().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);
}
示例10: onComponentTagBody
import org.apache.wicket.util.string.AppendingStringBuffer; //导入方法依赖的package包/类
/**
* 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("\" />");
// insert the page parameters, if any, as hidden fields as long as they
// 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);
}
示例11: appendOptionHtml
import org.apache.wicket.util.string.AppendingStringBuffer; //导入方法依赖的package包/类
@Override
protected void appendOptionHtml(AppendingStringBuffer buffer, T choice, int index, String selected) {
// CHECKSTYLE:ON
String label = generateLabelForChoice(choice);
// If there is a display value for the choice, then we know that the choice is automatic in some way. If label
// is /null/ then we know that the choice is a manually created checkbox tag at some random location in the page
// markup!
if (label == null) {
return;
}
String id = getChoiceRenderer().getIdValue(choice, index);
String idAttr = getMarkupId() + "-" + id;
boolean isSelected = isSelected(choice, index, selected);
boolean enabled = isEnabledInHierarchy() && !isDisabled(choice, index, selected);
Tag inputTag =
new Tag("input").attr("name", getInputName()).attr("type", "radio")
.attr("checked", "checked", isSelected).attr("disabled", "disabled", !enabled).attr("value", id)
.attr("id", idAttr).attr("style", "display:none");
// Should a roundtrip be made (have onSelectionChanged called) when the option is clicked?
if (wantOnSelectionChangedNotifications()) {
inputTag.attr("onclick", buildOnClickUrl(id));
}
if (getApplication().getDebugSettings().isOutputComponentPath()) {
inputTag.attr("wicketpath", buildWicketPath(index));
}
// Add label for radio button
Tag labelTag =
new Tag("label").attr("for", idAttr).attr("class", generateLabelTagClass(choice, index, isSelected));
inputTag.attrs(getAdditionalAttributes(index, choice));
inputTag.attrs(getAdditionalAttributesForLabel(index, choice));
labelTag.add(inputTag);
labelTag.add(generateLabelBody(label).toString());
buffer.append(getPrefix(index, choice));
buffer.append(labelTag);
buffer.append(getSuffix(index, choice));
}
示例12: appendOptionHtml
import org.apache.wicket.util.string.AppendingStringBuffer; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void appendOptionHtml(final AppendingStringBuffer buffer, final T choice, int index,
final String selected) {
Object displayValue = getChoiceRenderer().getDisplayValue(choice);
Class<?> objectClass = displayValue == null ? null : displayValue.getClass();
// Get label for choice
String label = "";
if (objectClass != null && objectClass != String.class) {
@SuppressWarnings("rawtypes")
IConverter converter = getConverter(objectClass);
label = converter.convertToString(displayValue, getLocale());
} else if (displayValue != null) {
label = displayValue.toString();
}
// If there is a display value for the choice, then we know that the
// choice is automatic in some way. If label is /null/ then we know
// that the choice is a manually created checkbox tag at some random
// location in the page markup!
if (label != null) {
String id = getChoiceRenderer().getIdValue(choice, index);
final String idAttr = getCheckBoxMarkupId(id);
boolean isSlected = isSelected(choice, index, selected);
// Append option suffix
buffer.append(getPrefix(index, choice));
Tag tag = new Tag("label").attr("for", idAttr);
List<String> labelClasses = new ArrayList<>();
labelClasses.add("btn");
if (isSlected) {
labelClasses.add("active");
labelClasses.add(getActiveLabelClass(choice, index));
} else {
labelClasses.add(getLabelClass(choice, index));
}
tag.attr("class", labelClasses);
// Add checkbox element
Tag input = new Tag("input").attr("name", getInputName()).attr("type", "checkbox");
input.attr("value", id).attr("id", idAttr);
input.attr("checked", "checked", isSlected);
input.attr("disabled", "disabled", isDisabled(choice, index, selected) || !isEnabledInHierarchy());
// Allows user to add attributes to the <input..> tag
{
IValueMap attrs = getAdditionalAttributes(index, choice);
if (attrs != null) {
input.getAttributes().putAll(attrs);
}
}
if (getApplication().getDebugSettings().isOutputComponentPath()) {
CharSequence path = getPageRelativePath();
path = Strings.replaceAll(path, "_", "__");
path = Strings.replaceAll(path, ":", "_");
input.attr("wicketpath", path + "_input_" + index);
}
tag.add(input);
// Add label for checkbox
tag.add(getLabelText(label));
buffer.append(tag.toString());
// Append option suffix
buffer.append(getSuffix(index, choice));
}
// CHECKSTYLE:ON
}