public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator,
RenderResult renderResult, String[] args) {
AbstractInlineElementComponent aiec = (AbstractInlineElementComponent) source;
InlineTextElement itei = (InlineTextElement) aiec.getInlineElement();
StringBuilder htmlVal = new StringBuilder();
/**
* in case of an error show the test which caused the error which must be stored by the textelement in the transientValue.
* the last valid value is always set over setValue(..) by the textelement, and thus can be retrieved as such here.
*/
String tmpVal;
if(itei.hasError()){
tmpVal = StringHelper.containsNonWhitespace(transientValue) ? transientValue : itei.getEmptyDisplayText();
}else{
tmpVal = StringHelper.containsNonWhitespace(getValue()) ? getValue() : itei.getEmptyDisplayText();
}
//the html safe value
htmlVal.append(StringEscapeUtils.escapeHtml(tmpVal));
if (!itei.isEnabled()) {
// RO view and not clickable
String id = aiec.getFormDispatchId();
sb.append("<span id=\"");
sb.append(id);
sb.append("\" ");
sb.append(" >");
sb.append(htmlVal); //
sb.append("</span>");
} else {
//
// Editable view
// which can be left
// .......with clicking outside -> onBlur saves the value
// .......pressing ENTER/RETURN or TAB -> onBlur saves the value
// .......presssing ESC -> restore previous value and submit this one.
if (itei.isInlineEditingOn()) {
String id = aiec.getFormDispatchId();
// read write view
sb.append("<input type=\"").append("input").append("\" id=\"");
sb.append(id);
sb.append("\" name=\"");
sb.append(id);
sb.append("\" size=\"");
sb.append("10");
// if(itei.maxlength > -1){
// sb.append("\" maxlength=\"");
// sb.append(itei.maxlength);
// }
sb.append("\" value=\"");
sb.append(htmlVal);
sb.append("\" ");
sb.append(" />");
// Javascript
sb.append(FormJSHelper.getJSStart());
// clicking outside or pressing enter -> OK, pressing ESC -> Cancel
FormJSHelper.getInlineEditOkCancelJS(sb, id, StringEscapeUtils.escapeHtml(getValue()), itei.getRootForm());
sb.append(FormJSHelper.getJSEnd());
} else {
// RO<->RW view which can be clicked
String id = aiec.getFormDispatchId();
sb.append("<span id=\"");
sb.append(id);
sb.append("\" ");
sb.append(FormJSHelper.getRawJSFor(itei.getRootForm(), id, itei.getAction()));
sb.append(" >");
sb.append(htmlVal); //
sb.append("</span>");
}