List of usage examples for java.lang Appendable toString
public String toString()
From source file:org.ofbiz.widget.form.MacroFormRenderer.java
public void renderMultiFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { //FIXME copy from HtmlFormRenderer.java (except for the closing form tag itself, that is now converted) Iterator<ModelFormField> submitFields = modelForm.getMultiSubmitFields().iterator(); while (submitFields.hasNext()) { ModelFormField submitField = submitFields.next(); if (submitField != null && submitField.shouldUse(context)) { // Threw this in that as a hack to keep the submit button from expanding the first field // Needs a more rugged solution // WARNING: this method (renderMultiFormClose) must be called after the // table that contains the list has been closed (to avoid validation errors) so // we cannot call here the methods renderFormatItemRowCell*: for this reason // they are now commented. // this.renderFormatItemRowCellOpen(writer, context, modelForm, submitField); // this.renderFormatItemRowCellClose(writer, context, modelForm, submitField); // this.renderFormatItemRowCellOpen(writer, context, modelForm, submitField); submitField.renderFieldString(writer, context, this); // this.renderFormatItemRowCellClose(writer, context, modelForm, submitField); }/* www . j ava 2s.c o m*/ } StringWriter sr = new StringWriter(); sr.append("<@renderMultiFormClose />"); executeMacro(writer, sr.toString()); // see if there is anything that needs to be added outside of the multi-form Map<String, Object> wholeFormContext = UtilGenerics.checkMap(context.get("wholeFormContext")); Appendable postMultiFormWriter = wholeFormContext != null ? (Appendable) wholeFormContext.get("postMultiFormWriter") : null; if (postMultiFormWriter != null) { writer.append(postMultiFormWriter.toString()); appendWhitespace(writer); } renderEndingBoundaryComment(writer, "Form Widget - Form Element (Multi)", modelForm); }
From source file:org.ofbiz.widget.WidgetWorker.java
public static void buildHyperlinkUrl(Appendable externalWriter, String target, String targetType, Map<String, String> parameterMap, String prefix, boolean fullPath, boolean secure, boolean encode, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException { // We may get an encoded request like: /projectmgr/control/EditTaskContents?workEffortId=10003 // Try to reducing a possibly encoded string down to its simplest form: /projectmgr/control/EditTaskContents?workEffortId=10003 // This step make sure the following appending externalLoginKey operation to work correctly String localRequestName = StringEscapeUtils.unescapeHtml(target); localRequestName = UtilHttp.encodeAmpersands(localRequestName); Appendable localWriter = new StringWriter(); if ("intra-app".equals(targetType)) { if (request != null && response != null) { ServletContext servletContext = request.getSession().getServletContext(); RequestHandler rh = (RequestHandler) servletContext.getAttribute("_REQUEST_HANDLER_"); externalWriter//from w w w . j a v a 2 s . c o m .append(rh.makeLink(request, response, "/" + localRequestName, fullPath, secure, encode)); } else if (prefix != null) { externalWriter.append(prefix); externalWriter.append(localRequestName); } else { externalWriter.append(localRequestName); } } else if ("inter-app".equals(targetType)) { String fullTarget = localRequestName; localWriter.append(fullTarget); String externalLoginKey = (String) request.getAttribute("externalLoginKey"); if (UtilValidate.isNotEmpty(externalLoginKey)) { if (fullTarget.indexOf('?') == -1) { localWriter.append('?'); } else { localWriter.append("&"); } localWriter.append("externalLoginKey="); localWriter.append(externalLoginKey); } } else if ("content".equals(targetType)) { appendContentUrl(localWriter, localRequestName, request); } else if ("plain".equals(targetType)) { localWriter.append(localRequestName); } else { localWriter.append(localRequestName); } if (UtilValidate.isNotEmpty(parameterMap)) { String localUrl = localWriter.toString(); externalWriter.append(localUrl); boolean needsAmp = true; if (localUrl.indexOf('?') == -1) { externalWriter.append('?'); needsAmp = false; } for (Map.Entry<String, String> parameter : parameterMap.entrySet()) { String parameterValue = null; if (parameter.getValue() instanceof String) { parameterValue = parameter.getValue(); } else { Object parameterObject = parameter.getValue(); // skip null values if (parameterObject == null) continue; if (parameterObject instanceof String[]) { // it's probably a String[], just get the first value String[] parameterArray = (String[]) parameterObject; parameterValue = parameterArray[0]; Debug.logInfo("Found String array value for parameter [" + parameter.getKey() + "], using first value: " + parameterValue, module); } else { // not a String, and not a String[], just use toString parameterValue = parameterObject.toString(); } } if (needsAmp) { externalWriter.append("&"); } else { needsAmp = true; } externalWriter.append(parameter.getKey()); externalWriter.append('='); StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder"); if (simpleEncoder != null && parameterValue != null) { externalWriter.append(simpleEncoder .encode(URLEncoder.encode(parameterValue, Charset.forName("UTF-8").displayName()))); } else { externalWriter.append(parameterValue); } } } else { externalWriter.append(localWriter.toString()); } }
From source file:org.ramadda.util.HtmlUtils.java
/** * _more_//w w w. ja v a2s . c o m * * @param name _more_ * @param value _more_ * @param encodeArg _more_ * * @return _more_ */ public static String arg(Object name, Object value, boolean encodeArg) { Appendable sb = new StringBuilder(); arg(sb, name, value, encodeArg); return sb.toString(); }
From source file:org.ramadda.util.HtmlUtils.java
/** * _more_//from w w w . j a v a 2 s. c o m * * @param sb _more_ * @param function _more_ * @param args _more_ * * @return _more_ */ public static String call(Appendable sb, String function, String... args) { try { sb.append("("); for (int i = 0; i < args.length; i++) { if (i > 0) { sb.append(","); } sb.append(args[i]); } sb.append(");"); return sb.toString(); } catch (IOException ioe) { throw new RuntimeException(ioe); } }