Author: jacopoc
Date: Sun Jun 1 22:27:12 2008 New Revision: 662328 URL: http://svn.apache.org/viewvc?rev=662328&view=rev Log: Based on a recent discussion in the dev list, and especially on the comments from David Jones and the work done by Adrian Crum, I'm committing a patch to refactor all the widget rendering methods and some of the content and Freemarker rendering classes to use Appendable instead of Writer. OFBIZ-1816 Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/template/FreeMarkerWorker.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ContentWorkerInterface.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/DataResourceWorkerInterface.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FormStringRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlWidgetRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MenuStringRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenStringRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextScreenRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeStringRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/xml/XmlFormRenderer.java Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java?rev=662328&r1=662327&r2=662328&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java Sun Jun 1 22:27:12 2008 @@ -89,11 +89,11 @@ } // new rendering methods - public void renderContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Writer out, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException { + public void renderContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Appendable out, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException { renderContentAsText(dispatcher, delegator, contentId, out, templateContext, locale, mimeTypeId, cache); } - public void renderSubContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Writer out, String mapKey, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException { + public void renderSubContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Appendable out, String mapKey, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException { renderSubContentAsText(dispatcher, delegator, contentId, out, mapKey, templateContext, locale, mimeTypeId, cache); } @@ -116,7 +116,7 @@ return writer.toString(); } - public static void renderContentAsText(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Writer out, + public static void renderContentAsText(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Appendable out, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException { GenericValue content; if (UtilValidate.isEmpty(contentId)) { @@ -287,7 +287,7 @@ return writer.toString(); } - public static void renderSubContentAsText(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Writer out, String mapKey, + public static void renderSubContentAsText(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Appendable out, String mapKey, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException { // find the sub-content with matching mapKey @@ -304,7 +304,7 @@ if (subContent == null) { //throw new GeneralException("No sub-content found with map-key [" + mapKey + "] for content [" + contentId + "]"); - out.write("<!-- no sub-content found with map-key [" + mapKey + "] for content [" + contentId + "] -->"); + out.append("<!-- no sub-content found with map-key [" + mapKey + "] for content [" + contentId + "] -->"); } else { String subContentId = subContent.getString("contentIdTo"); templateContext.put("mapKey", mapKey); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java?rev=662328&r1=662327&r2=662328&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java Sun Jun 1 22:27:12 2008 @@ -571,7 +571,7 @@ return writer.toString(); } - public static void renderDataResourceAsText(GenericDelegator delegator, String dataResourceId, Writer out, + public static void renderDataResourceAsText(GenericDelegator delegator, String dataResourceId, Appendable out, Map templateContext, Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException { if (dataResourceId == null) { throw new GeneralException("Cannot lookup data resource with for a null dataResourceId"); @@ -696,7 +696,7 @@ } /** @deprecated */ - public static void renderDataResourceAsText(GenericDelegator delegator, String dataResourceId, Writer out, + public static void renderDataResourceAsText(GenericDelegator delegator, String dataResourceId, Appendable out, Map templateContext, GenericValue view, Locale locale, String targetMimeTypeId) throws GeneralException, IOException { renderDataResourceAsText(delegator, dataResourceId, out, templateContext, locale, targetMimeTypeId, false); } @@ -708,7 +708,7 @@ } /** @deprecated */ - public static void renderDataResourceAsTextCache(GenericDelegator delegator, String dataResourceId, Writer out, + public static void renderDataResourceAsTextCache(GenericDelegator delegator, String dataResourceId, Appendable out, Map templateContext, GenericValue view, Locale locale, String targetMimeTypeId) throws GeneralException, IOException { renderDataResourceAsText(delegator, dataResourceId, out, templateContext, locale, targetMimeTypeId, true); } @@ -725,7 +725,7 @@ } public static void writeDataResourceText(GenericValue dataResource, String mimeTypeId, Locale locale, Map templateContext, - GenericDelegator delegator, Writer out, boolean cache) throws IOException, GeneralException { + GenericDelegator delegator, Appendable out, boolean cache) throws IOException, GeneralException { Map context = (Map) templateContext.get("context"); if (context == null) { context = FastMap.newInstance(); @@ -799,7 +799,7 @@ URL fixedUrl = new URL(fixedUrlStr); text = (String) fixedUrl.getContent(); } - out.write(text); + out.append(text); // file types } else if (dataResourceTypeId.endsWith("_FILE_BIN")) { @@ -826,7 +826,7 @@ /** @deprecated */ public static void writeDataResourceTextCache(GenericValue dataResource, String mimeTypeId, Locale locale, Map context, - GenericDelegator delegator, Writer outWriter) throws IOException, GeneralException { + GenericDelegator delegator, Appendable outWriter) throws IOException, GeneralException { writeDataResourceText(dataResource, mimeTypeId, locale, context, delegator, outWriter, true); } @@ -838,11 +838,11 @@ /** @deprecated */ public static void writeDataResourceText(GenericValue dataResource, String mimeTypeId, Locale locale, Map context, - GenericDelegator delegator, Writer out) throws IOException, GeneralException { + GenericDelegator delegator, Appendable out) throws IOException, GeneralException { writeDataResourceText(dataResource, mimeTypeId, locale, context, delegator, out, false); } - public static void writeText(GenericValue dataResource, String textData, Map context, String targetMimeTypeId, Locale locale, Writer out) throws GeneralException, IOException { + public static void writeText(GenericValue dataResource, String textData, Map context, String targetMimeTypeId, Locale locale, Appendable out) throws GeneralException, IOException { String dataResourceMimeTypeId = dataResource.getString("mimeTypeId"); GenericDelegator delegator = dataResource.getDelegator(); @@ -873,12 +873,12 @@ mimeContext.put("textData", textData); String mimeString = DataResourceWorker.renderMimeTypeTemplate(mimeTypeTemplate, context); - out.write(mimeString); + out.append(mimeString); } else { - out.write(textData); + out.append(textData); } } else if ("text/plain".equals(targetMimeTypeId)) { - out.write(textData); + out.append(textData); } } @@ -894,7 +894,7 @@ return writer.toString(); } - public static void renderFile(String dataResourceTypeId, String objectInfo, String rootDir, Writer out) throws GeneralException, IOException { + public static void renderFile(String dataResourceTypeId, String objectInfo, String rootDir, Appendable out) throws GeneralException, IOException { // TODO: this method assumes the file is a text file, if it is an image we should respond differently, see the comment above for IMAGE_OBJECT type data resource if (dataResourceTypeId.equals("LOCAL_FILE")) { @@ -905,7 +905,7 @@ int c; FileReader in = new FileReader(file); while ((c = in.read()) != -1) { - out.write(c); + out.append((char)c); } } else if (dataResourceTypeId.equals("OFBIZ_FILE")) { String prefix = System.getProperty("ofbiz.home"); @@ -917,7 +917,7 @@ int c; FileReader in = new FileReader(file); while ((c = in.read()) != -1) - out.write(c); + out.append((char)c); } else if (dataResourceTypeId.equals("CONTEXT_FILE")) { String prefix = rootDir; String sep = ""; @@ -939,7 +939,7 @@ Debug.logError(" in renderDataResourceAsHtml(CONTEXT_FILE), got exception:" + e.getMessage(), module); } while ((c = in.read()) != -1) { - out.write(c); + out.append((char)c); } //out.flush(); } @@ -1152,7 +1152,7 @@ return renderDataResourceAsText(delegator, dataResourceId, templateContext, locale, targetMimeTypeId, cache); } - public void renderDataResourceAsTextExt(GenericDelegator delegator, String dataResourceId, Writer out, Map templateContext, + public void renderDataResourceAsTextExt(GenericDelegator delegator, String dataResourceId, Appendable out, Map templateContext, Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException { renderDataResourceAsText(delegator, dataResourceId, out, templateContext, locale, targetMimeTypeId, cache); } Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/template/FreeMarkerWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/template/FreeMarkerWorker.java?rev=662328&r1=662327&r2=662328&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/template/FreeMarkerWorker.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/template/FreeMarkerWorker.java Sun Jun 1 22:27:12 2008 @@ -132,7 +132,7 @@ * @param context The context Map * @param outWriter The Writer to render to */ - public static void renderTemplateAtLocation(String templateLocation, Map<String, Object> context, Writer outWriter) throws MalformedURLException, TemplateException, IOException { + public static void renderTemplateAtLocation(String templateLocation, Map<String, Object> context, Appendable outWriter) throws MalformedURLException, TemplateException, IOException { renderTemplate(templateLocation, context, outWriter); } @@ -143,7 +143,7 @@ * @param context The context Map * @param outWriter The Writer to render to */ - public static void renderTemplate(String templateLocation, String templateString, Map<String, Object> context, Writer outWriter) throws TemplateException, IOException { + public static void renderTemplate(String templateLocation, String templateString, Map<String, Object> context, Appendable outWriter) throws TemplateException, IOException { if (UtilValidate.isEmpty(templateString)) { renderTemplate(templateLocation, context, outWriter); } else { @@ -158,12 +158,12 @@ * @param context The context Map * @param outWriter The Writer to render to */ - public static void renderTemplate(String templateLocation, Map<String, Object> context, Writer outWriter) throws TemplateException, IOException { + public static void renderTemplate(String templateLocation, Map<String, Object> context, Appendable outWriter) throws TemplateException, IOException { Template template = getTemplate(templateLocation); renderTemplate(template, context, outWriter); } - public static void renderTemplateFromString(String templateString, String templateLocation, Map<String, Object> context, Writer outWriter) throws TemplateException, IOException { + public static void renderTemplateFromString(String templateString, String templateLocation, Map<String, Object> context, Appendable outWriter) throws TemplateException, IOException { Template template = cachedTemplates.get(templateLocation); if (template == null) { synchronized (cachedTemplates) { @@ -186,14 +186,18 @@ * @param context The context Map * @param outWriter The Writer to render to */ - public static void renderTemplate(Template template, Map<String, Object> context, Writer outWriter) throws TemplateException, IOException { + public static void renderTemplate(Template template, Map<String, Object> context, Appendable outWriter) throws TemplateException, IOException { addAllOfbizTransforms(context); // make sure there is no "null" string in there as FreeMarker will try to use it context.remove("null"); // Since the template cache keeps a single instance of a Template that is shared among users, // and since that Template instance is immutable, we need to create an Environment instance and // use it to process the template with the user's settings. - Environment env = template.createProcessingEnvironment(context, outWriter); + // + // FIXME: the casting from Appendable to Writer is a temporary fix that could cause a + // run time error if in the future we will pass a different class to the method + // (such as a StringBuffer). + Environment env = template.createProcessingEnvironment(context, (Writer)outWriter); applyUserSettings(env, context); env.process(); } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ContentWorkerInterface.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ContentWorkerInterface.java?rev=662328&r1=662327&r2=662328&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ContentWorkerInterface.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ContentWorkerInterface.java Sun Jun 1 22:27:12 2008 @@ -41,9 +41,9 @@ public String getMimeTypeIdExt(GenericDelegator delegator, GenericValue view, Map ctx); // new rendering methods - public void renderContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Writer out, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException; + public void renderContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Appendable out, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException; public String renderContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException; - public void renderSubContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Writer out, String mapKey, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException; + public void renderSubContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Appendable out, String mapKey, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException; public String renderSubContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, String mapKey, Map templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException; } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/DataResourceWorkerInterface.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/DataResourceWorkerInterface.java?rev=662328&r1=662327&r2=662328&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/DataResourceWorkerInterface.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/DataResourceWorkerInterface.java Sun Jun 1 22:27:12 2008 @@ -37,6 +37,6 @@ public String renderDataResourceAsTextExt(GenericDelegator delegator, String dataResourceId, Map templateContext, Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException; - public void renderDataResourceAsTextExt(GenericDelegator delegator, String dataResourceId, Writer out, Map templateContext, + public void renderDataResourceAsTextExt(GenericDelegator delegator, String dataResourceId, Appendable out, Map templateContext, Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException; } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java?rev=662328&r1=662327&r2=662328&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/WidgetWorker.java Sun Jun 1 22:27:12 2008 @@ -37,82 +37,82 @@ public WidgetWorker () {} - public static void buildHyperlinkUrl(Writer writer, String requestName, String targetType, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException { + public static void buildHyperlinkUrl(Appendable writer, String requestName, String targetType, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException { String localRequestName = UtilHttp.encodeAmpersands(requestName); if ("intra-app".equals(targetType)) { appendOfbizUrl(writer, "/" + localRequestName, request, response); } else if ("inter-app".equals(targetType)) { String fullTarget = localRequestName; - writer.write(fullTarget); + writer.append(fullTarget); String externalLoginKey = (String) request.getAttribute("externalLoginKey"); if (UtilValidate.isNotEmpty(externalLoginKey)) { if (fullTarget.indexOf('?') == -1) { - writer.write('?'); + writer.append('?'); } else { - writer.write("&"); + writer.append("&"); } - writer.write("externalLoginKey="); - writer.write(externalLoginKey); + writer.append("externalLoginKey="); + writer.append(externalLoginKey); } } else if ("content".equals(targetType)) { appendContentUrl(writer, localRequestName, request); } else if ("plain".equals(targetType)) { - writer.write(localRequestName); + writer.append(localRequestName); } else { - writer.write(localRequestName); + writer.append(localRequestName); } } - public static void appendOfbizUrl(Writer writer, String location, HttpServletRequest request, HttpServletResponse response) throws IOException { + public static void appendOfbizUrl(Appendable writer, String location, HttpServletRequest request, HttpServletResponse response) throws IOException { ServletContext ctx = (ServletContext) request.getAttribute("servletContext"); RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_"); // make and append the link - writer.write(rh.makeLink(request, response, location)); + writer.append(rh.makeLink(request, response, location)); } - public static void appendContentUrl(Writer writer, String location, HttpServletRequest request) throws IOException { + public static void appendContentUrl(Appendable writer, String location, HttpServletRequest request) throws IOException { StringBuffer buffer = new StringBuffer(); ContentUrlTag.appendContentPrefix(request, buffer); - writer.write(buffer.toString()); - writer.write(location); + writer.append(buffer.toString()); + writer.append(location); } - public static void makeHyperlinkString(Writer writer, String linkStyle, String targetType, String target, String description, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context, String targetWindow, String event, String action) throws IOException { + public static void makeHyperlinkString(Appendable writer, String linkStyle, String targetType, String target, String description, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context, String targetWindow, String event, String action) throws IOException { if (UtilValidate.isNotEmpty(description)) { - writer.write("<a"); + writer.append("<a"); if (UtilValidate.isNotEmpty(linkStyle)) { - writer.write(" class=\""); - writer.write(linkStyle); - writer.write("\""); + writer.append(" class=\""); + writer.append(linkStyle); + writer.append("\""); } - writer.write(" href=\""); + writer.append(" href=\""); buildHyperlinkUrl(writer, target, targetType, request, response, context); - writer.write("\""); + writer.append("\""); if (UtilValidate.isNotEmpty(targetWindow)) { - writer.write(" target=\""); - writer.write(targetWindow); - writer.write("\""); + writer.append(" target=\""); + writer.append(targetWindow); + writer.append("\""); } if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) { - writer.write(" "); - writer.write(event); - writer.write("=\""); - writer.write(action); - writer.write('"'); + writer.append(" "); + writer.append(event); + writer.append("=\""); + writer.append(action); + writer.append('"'); } - writer.write('>'); + writer.append('>'); - writer.write(description); - writer.write("</a>"); + writer.append(description); + writer.append("</a>"); } } } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java?rev=662328&r1=662327&r2=662328&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java Sun Jun 1 22:27:12 2008 @@ -71,48 +71,48 @@ this.response = response; } - private void makeBlockString(Writer writer, String widgetStyle, String text) throws IOException { - writer.write("<fo:block"); + private void makeBlockString(Appendable writer, String widgetStyle, String text) throws IOException { + writer.append("<fo:block"); if (UtilValidate.isNotEmpty(widgetStyle)) { - writer.write(" "); - writer.write(FoScreenRenderer.getFoStyle(widgetStyle)); + writer.append(" "); + writer.append(FoScreenRenderer.getFoStyle(widgetStyle)); } - writer.write(">"); - writer.write(UtilFormatOut.encodeXmlValue(text)); - writer.write("</fo:block>"); + writer.append(">"); + writer.append(UtilFormatOut.encodeXmlValue(text)); + writer.append("</fo:block>"); } - public void renderDisplayField(Writer writer, Map<String, Object> context, DisplayField displayField) throws IOException { + public void renderDisplayField(Appendable writer, Map<String, Object> context, DisplayField displayField) throws IOException { ModelFormField modelFormField = displayField.getModelFormField(); this.makeBlockString(writer, modelFormField.getWidgetStyle(), displayField.getDescription(context)); appendWhitespace(writer); } - public void renderHyperlinkField(Writer writer, Map<String, Object> context, HyperlinkField hyperlinkField) throws IOException { + public void renderHyperlinkField(Appendable writer, Map<String, Object> context, HyperlinkField hyperlinkField) throws IOException { ModelFormField modelFormField = hyperlinkField.getModelFormField(); this.makeBlockString(writer, modelFormField.getWidgetStyle(), hyperlinkField.getDescription(context)); appendWhitespace(writer); } - public void renderTextField(Writer writer, Map<String, Object> context, TextField textField) throws IOException { + public void renderTextField(Appendable writer, Map<String, Object> context, TextField textField) throws IOException { ModelFormField modelFormField = textField.getModelFormField(); this.makeBlockString(writer, modelFormField.getWidgetStyle(), modelFormField.getEntry(context, textField.getDefaultValue(context))); appendWhitespace(writer); } - public void renderTextareaField(Writer writer, Map<String, Object> context, TextareaField textareaField) throws IOException { + public void renderTextareaField(Appendable writer, Map<String, Object> context, TextareaField textareaField) throws IOException { ModelFormField modelFormField = textareaField.getModelFormField(); this.makeBlockString(writer, modelFormField.getWidgetStyle(), modelFormField.getEntry(context, textareaField.getDefaultValue(context))); appendWhitespace(writer); } - public void renderDateTimeField(Writer writer, Map<String, Object> context, DateTimeField dateTimeField) throws IOException { + public void renderDateTimeField(Appendable writer, Map<String, Object> context, DateTimeField dateTimeField) throws IOException { ModelFormField modelFormField = dateTimeField.getModelFormField(); this.makeBlockString(writer, modelFormField.getWidgetStyle(), modelFormField.getEntry(context, dateTimeField.getDefaultValue(context))); appendWhitespace(writer); } - public void renderDropDownField(Writer writer, Map<String, Object> context, DropDownField dropDownField) throws IOException { + public void renderDropDownField(Appendable writer, Map<String, Object> context, DropDownField dropDownField) throws IOException { ModelFormField modelFormField = dropDownField.getModelFormField(); ModelForm modelForm = modelFormField.getModelForm(); String currentValue = modelFormField.getEntry(context); @@ -143,278 +143,278 @@ appendWhitespace(writer); } - public void renderCheckField(Writer writer, Map<String, Object> context, CheckField checkField) throws IOException { + public void renderCheckField(Appendable writer, Map<String, Object> context, CheckField checkField) throws IOException { this.makeBlockString(writer, null, ""); } - public void renderRadioField(Writer writer, Map<String, Object> context, RadioField radioField) throws IOException { + public void renderRadioField(Appendable writer, Map<String, Object> context, RadioField radioField) throws IOException { this.makeBlockString(writer, null, ""); } - public void renderSubmitField(Writer writer, Map<String, Object> context, SubmitField submitField) throws IOException { + public void renderSubmitField(Appendable writer, Map<String, Object> context, SubmitField submitField) throws IOException { this.makeBlockString(writer, null, ""); } - public void renderResetField(Writer writer, Map<String, Object> context, ResetField resetField) throws IOException { + public void renderResetField(Appendable writer, Map<String, Object> context, ResetField resetField) throws IOException { this.makeBlockString(writer, null, ""); } - public void renderHiddenField(Writer writer, Map<String, Object> context, HiddenField hiddenField) throws IOException { + public void renderHiddenField(Appendable writer, Map<String, Object> context, HiddenField hiddenField) throws IOException { } - public void renderHiddenField(Writer writer, Map<String, Object> context, ModelFormField modelFormField, String value) throws IOException { + public void renderHiddenField(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String value) throws IOException { } - public void renderIgnoredField(Writer writer, Map<String, Object> context, IgnoredField ignoredField) throws IOException { + public void renderIgnoredField(Appendable writer, Map<String, Object> context, IgnoredField ignoredField) throws IOException { } - public void renderFieldTitle(Writer writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { + public void renderFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { String tempTitleText = modelFormField.getTitle(context); - writer.write(tempTitleText); + writer.append(tempTitleText); } - public void renderSingleFormFieldTitle(Writer writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { + public void renderSingleFormFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { renderFieldTitle(writer, context, modelFormField); } - public void renderFormOpen(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + public void renderFormOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { renderBeginningBoundaryComment(writer, "Form Widget", modelForm); } - public void renderFormClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + public void renderFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { renderEndingBoundaryComment(writer, "Form Widget", modelForm); } - public void renderMultiFormClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + public void renderMultiFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { renderEndingBoundaryComment(writer, "Form Widget", modelForm); } - public void renderFormatListWrapperOpen(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { - writer.write("<fo:table border=\"solid black\">"); + public void renderFormatListWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + writer.append("<fo:table border=\"solid black\">"); List<ModelFormField> childFieldList = modelForm.getFieldList(); for (ModelFormField childField : childFieldList) { int childFieldType = childField.getFieldInfo().getFieldType(); if (childFieldType == ModelFormField.FieldInfo.HIDDEN || childFieldType == ModelFormField.FieldInfo.IGNORED) { continue; } - writer.write("<fo:table-column"); + writer.append("<fo:table-column"); String areaStyle = childField.getTitleAreaStyle(); if (UtilValidate.isNotEmpty(areaStyle)) { - writer.write(" "); - writer.write(FoScreenRenderer.getFoStyle(areaStyle)); + writer.append(" "); + writer.append(FoScreenRenderer.getFoStyle(areaStyle)); } - writer.write("/>"); + writer.append("/>"); appendWhitespace(writer); } appendWhitespace(writer); } - public void renderFormatListWrapperClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { - writer.write("</fo:table-body>"); - writer.write("</fo:table>"); + public void renderFormatListWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + writer.append("</fo:table-body>"); + writer.append("</fo:table>"); appendWhitespace(writer); } - public void renderFormatHeaderRowOpen(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { - writer.write("<fo:table-header>"); - writer.write("<fo:table-row>"); + public void renderFormatHeaderRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + writer.append("<fo:table-header>"); + writer.append("<fo:table-row>"); appendWhitespace(writer); } - public void renderFormatHeaderRowClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { - writer.write("</fo:table-row>"); - writer.write("</fo:table-header>"); - writer.write("<fo:table-body>"); + public void renderFormatHeaderRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + writer.append("</fo:table-row>"); + writer.append("</fo:table-header>"); + writer.append("<fo:table-body>"); // FIXME: this is an hack to avoid FOP rendering errors for empty lists (fo:table-body cannot be null) - writer.write("<fo:table-row><fo:table-cell><fo:block/></fo:table-cell></fo:table-row>"); + writer.append("<fo:table-row><fo:table-cell><fo:block/></fo:table-cell></fo:table-row>"); appendWhitespace(writer); } - public void renderFormatHeaderRowCellOpen(Writer writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, int positionSpan) throws IOException { - writer.write("<fo:table-cell "); + public void renderFormatHeaderRowCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, int positionSpan) throws IOException { + writer.append("<fo:table-cell "); if (positionSpan > 1) { - writer.write("number-columns-spanned=\""); - writer.write(Integer.toString(positionSpan)); - writer.write("\" "); + writer.append("number-columns-spanned=\""); + writer.append(Integer.toString(positionSpan)); + writer.append("\" "); } - writer.write("font-weight=\"bold\" text-align=\"center\" border=\"solid black\" padding=\"2pt\""); - writer.write(">"); - writer.write("<fo:block>"); + writer.append("font-weight=\"bold\" text-align=\"center\" border=\"solid black\" padding=\"2pt\""); + writer.append(">"); + writer.append("<fo:block>"); appendWhitespace(writer); } - public void renderFormatHeaderRowCellClose(Writer writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField) throws IOException { - writer.write("</fo:block>"); - writer.write("</fo:table-cell>"); + public void renderFormatHeaderRowCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField) throws IOException { + writer.append("</fo:block>"); + writer.append("</fo:table-cell>"); appendWhitespace(writer); } - public void renderFormatHeaderRowFormCellOpen(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { - writer.write("<fo:table-cell>"); + public void renderFormatHeaderRowFormCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + writer.append("<fo:table-cell>"); appendWhitespace(writer); } - public void renderFormatHeaderRowFormCellClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { - writer.write("</fo:table-cell>"); + public void renderFormatHeaderRowFormCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + writer.append("</fo:table-cell>"); appendWhitespace(writer); } - public void renderFormatHeaderRowFormCellTitleSeparator(Writer writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, boolean isLast) throws IOException { + public void renderFormatHeaderRowFormCellTitleSeparator(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, boolean isLast) throws IOException { } - public void renderFormatItemRowOpen(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { - writer.write("<fo:table-row>"); + public void renderFormatItemRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + writer.append("<fo:table-row>"); appendWhitespace(writer); } - public void renderFormatItemRowClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { - writer.write("</fo:table-row>"); + public void renderFormatItemRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + writer.append("</fo:table-row>"); appendWhitespace(writer); } - public void renderFormatItemRowCellOpen(Writer writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, int positionSpan) throws IOException { - writer.write("<fo:table-cell "); + public void renderFormatItemRowCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, int positionSpan) throws IOException { + writer.append("<fo:table-cell "); if (positionSpan > 1) { - writer.write("number-columns-spanned=\""); - writer.write(Integer.toString(positionSpan)); - writer.write("\" "); + writer.append("number-columns-spanned=\""); + writer.append(Integer.toString(positionSpan)); + writer.append("\" "); } String areaStyle = modelFormField.getWidgetAreaStyle(); if (UtilValidate.isEmpty(areaStyle)) { areaStyle = "tabletext"; } - writer.write(FoScreenRenderer.getFoStyle(areaStyle)); - writer.write(">"); + writer.append(FoScreenRenderer.getFoStyle(areaStyle)); + writer.append(">"); appendWhitespace(writer); } - public void renderFormatItemRowCellClose(Writer writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField) throws IOException { - writer.write("</fo:table-cell>"); + public void renderFormatItemRowCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField) throws IOException { + writer.append("</fo:table-cell>"); appendWhitespace(writer); } - public void renderFormatItemRowFormCellOpen(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { - writer.write("<fo:table-cell>"); + public void renderFormatItemRowFormCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + writer.append("<fo:table-cell>"); appendWhitespace(writer); } - public void renderFormatItemRowFormCellClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { - writer.write("</fo:table-cell>"); + public void renderFormatItemRowFormCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + writer.append("</fo:table-cell>"); appendWhitespace(writer); } // TODO: multi columns (position attribute) in single forms are still not implemented - public void renderFormatSingleWrapperOpen(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { - writer.write("<fo:table>"); + public void renderFormatSingleWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + writer.append("<fo:table>"); appendWhitespace(writer); - writer.write("<fo:table-column column-width=\"2in\"/>"); + writer.append("<fo:table-column column-width=\"2in\"/>"); appendWhitespace(writer); - writer.write("<fo:table-column/>"); + writer.append("<fo:table-column/>"); appendWhitespace(writer); - writer.write("<fo:table-body>"); + writer.append("<fo:table-body>"); appendWhitespace(writer); } - public void renderFormatSingleWrapperClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { - writer.write("</fo:table-body>"); - writer.write("</fo:table>"); + public void renderFormatSingleWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + writer.append("</fo:table-body>"); + writer.append("</fo:table>"); appendWhitespace(writer); } - public void renderFormatFieldRowOpen(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { - writer.write("<fo:table-row>"); + public void renderFormatFieldRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + writer.append("<fo:table-row>"); appendWhitespace(writer); } - public void renderFormatFieldRowClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { - writer.write("</fo:table-row>"); + public void renderFormatFieldRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + writer.append("</fo:table-row>"); appendWhitespace(writer); } - public void renderFormatFieldRowTitleCellOpen(Writer writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { - writer.write("<fo:table-cell font-weight=\"bold\" text-align=\"right\" padding=\"3pt\">"); - writer.write("<fo:block>"); + public void renderFormatFieldRowTitleCellOpen(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { + writer.append("<fo:table-cell font-weight=\"bold\" text-align=\"right\" padding=\"3pt\">"); + writer.append("<fo:block>"); appendWhitespace(writer); } - public void renderFormatFieldRowTitleCellClose(Writer writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { - writer.write("</fo:block>"); - writer.write("</fo:table-cell>"); + public void renderFormatFieldRowTitleCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { + writer.append("</fo:block>"); + writer.append("</fo:table-cell>"); appendWhitespace(writer); } - public void renderFormatFieldRowSpacerCell(Writer writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { + public void renderFormatFieldRowSpacerCell(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { } - public void renderFormatFieldRowWidgetCellOpen(Writer writer, Map<String, Object> context, ModelFormField modelFormField, int positions, int positionSpan, Integer nextPositionInRow) throws IOException { - writer.write("<fo:table-cell text-align=\"left\" padding=\"2pt\" padding-left=\"5pt\">"); + public void renderFormatFieldRowWidgetCellOpen(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions, int positionSpan, Integer nextPositionInRow) throws IOException { + writer.append("<fo:table-cell text-align=\"left\" padding=\"2pt\" padding-left=\"5pt\">"); appendWhitespace(writer); } - public void renderFormatFieldRowWidgetCellClose(Writer writer, Map<String, Object> context, ModelFormField modelFormField, int positions, int positionSpan, Integer nextPositionInRow) throws IOException { - writer.write("</fo:table-cell>"); + public void renderFormatFieldRowWidgetCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions, int positionSpan, Integer nextPositionInRow) throws IOException { + writer.append("</fo:table-cell>"); appendWhitespace(writer); } - public void renderFormatEmptySpace(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + public void renderFormatEmptySpace(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { // TODO } - public void renderTextFindField(Writer writer, Map<String, Object> context, TextFindField textFindField) throws IOException { + public void renderTextFindField(Appendable writer, Map<String, Object> context, TextFindField textFindField) throws IOException { ModelFormField modelFormField = textFindField.getModelFormField(); this.makeBlockString(writer, modelFormField.getWidgetStyle(), modelFormField.getEntry(context, textFindField.getDefaultValue(context))); appendWhitespace(writer); } - public void renderRangeFindField(Writer writer, Map<String, Object> context, RangeFindField rangeFindField) throws IOException { + public void renderRangeFindField(Appendable writer, Map<String, Object> context, RangeFindField rangeFindField) throws IOException { ModelFormField modelFormField = rangeFindField.getModelFormField(); this.makeBlockString(writer, modelFormField.getWidgetStyle(), modelFormField.getEntry(context, rangeFindField.getDefaultValue(context))); appendWhitespace(writer); } - public void renderDateFindField(Writer writer, Map<String, Object> context, DateFindField dateFindField) throws IOException { + public void renderDateFindField(Appendable writer, Map<String, Object> context, DateFindField dateFindField) throws IOException { ModelFormField modelFormField = dateFindField.getModelFormField(); this.makeBlockString(writer, modelFormField.getWidgetStyle(), modelFormField.getEntry(context, dateFindField.getDefaultValue(context))); appendWhitespace(writer); } - public void renderLookupField(Writer writer, Map<String, Object> context, LookupField lookupField) throws IOException { + public void renderLookupField(Appendable writer, Map<String, Object> context, LookupField lookupField) throws IOException { ModelFormField modelFormField = lookupField.getModelFormField(); this.makeBlockString(writer, modelFormField.getWidgetStyle(), modelFormField.getEntry(context, lookupField.getDefaultValue(context))); appendWhitespace(writer); } - public void renderNextPrev(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + public void renderNextPrev(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { } - public void renderFileField(Writer writer, Map<String, Object> context, FileField textField) throws IOException { + public void renderFileField(Appendable writer, Map<String, Object> context, FileField textField) throws IOException { ModelFormField modelFormField = textField.getModelFormField(); this.makeBlockString(writer, modelFormField.getWidgetStyle(), modelFormField.getEntry(context, textField.getDefaultValue(context))); appendWhitespace(writer); } - public void renderPasswordField(Writer writer, Map<String, Object> context, PasswordField passwordField) throws IOException { + public void renderPasswordField(Appendable writer, Map<String, Object> context, PasswordField passwordField) throws IOException { this.makeBlockString(writer, null, ""); } - public void renderImageField(Writer writer, Map<String, Object> context, ImageField imageField) throws IOException { + public void renderImageField(Appendable writer, Map<String, Object> context, ImageField imageField) throws IOException { // TODO this.makeBlockString(writer, null, ""); } - public void renderFieldGroupOpen(Writer writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException { + public void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException { // TODO } - public void renderFieldGroupClose(Writer writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException { + public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException { // TODO } - public void renderBanner(Writer writer, Map<String, Object> context, ModelForm.Banner banner) throws IOException { + public void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner) throws IOException { // TODO this.makeBlockString(writer, null, ""); } - public void renderHyperlinkTitle(Writer writer, Map<String, Object> context, ModelFormField modelFormField, String titleText) throws IOException { + public void renderHyperlinkTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText) throws IOException { } } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java?rev=662328&r1=662327&r2=662328&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java Sun Jun 1 22:27:12 2008 @@ -47,30 +47,30 @@ return value; } - public void renderSectionBegin(Writer writer, Map<String, Object> context, ModelScreenWidget.Section section) throws IOException { + public void renderSectionBegin(Appendable writer, Map<String, Object> context, ModelScreenWidget.Section section) throws IOException { renderBeginningBoundaryComment(writer, section.isMainSection?"Screen":"Section Widget", section); } - public void renderSectionEnd(Writer writer, Map<String, Object> context, ModelScreenWidget.Section section) throws IOException { + public void renderSectionEnd(Appendable writer, Map<String, Object> context, ModelScreenWidget.Section section) throws IOException { renderEndingBoundaryComment(writer, section.isMainSection?"Screen":"Section Widget", section); } - public void renderContainerBegin(Writer writer, Map<String, Object> context, ModelScreenWidget.Container container) throws IOException { - writer.write("<fo:block"); + public void renderContainerBegin(Appendable writer, Map<String, Object> context, ModelScreenWidget.Container container) throws IOException { + writer.append("<fo:block"); String style = container.getStyle(context); if (UtilValidate.isNotEmpty(style)) { writer.append(" "); writer.append(FoScreenRenderer.getFoStyle(style)); } - writer.write(">"); + writer.append(">"); appendWhitespace(writer); } - public void renderContainerEnd(Writer writer, Map<String, Object> context, ModelScreenWidget.Container container) throws IOException { - writer.write("</fo:block>"); + public void renderContainerEnd(Appendable writer, Map<String, Object> context, ModelScreenWidget.Container container) throws IOException { + writer.append("</fo:block>"); appendWhitespace(writer); } - public void renderLabel(Writer writer, Map<String, Object> context, ModelScreenWidget.Label label) throws IOException { + public void renderLabel(Appendable writer, Map<String, Object> context, ModelScreenWidget.Label label) throws IOException { String labelText = label.getText(context); if (UtilValidate.isEmpty(labelText)) { // nothing to render @@ -79,64 +79,64 @@ // open tag String style = label.getStyle(context); if (UtilValidate.isNotEmpty(style)) { - writer.write("<fo:inline "); + writer.append("<fo:inline "); writer.append(FoScreenRenderer.getFoStyle(style)); - writer.write(">"); + writer.append(">"); // the text - writer.write(labelText); + writer.append(labelText); // close tag - writer.write("</fo:inline>"); + writer.append("</fo:inline>"); } else { - writer.write(labelText); + writer.append(labelText); } appendWhitespace(writer); } - public void renderLink(Writer writer, Map<String, Object> context, ModelScreenWidget.Link link) throws IOException { + public void renderLink(Appendable writer, Map<String, Object> context, ModelScreenWidget.Link link) throws IOException { // TODO: not implemented } - public void renderImage(Writer writer, Map<String, Object> context, ModelScreenWidget.Image image) throws IOException { + public void renderImage(Appendable writer, Map<String, Object> context, ModelScreenWidget.Image image) throws IOException { // TODO: not implemented } - public void renderContentBegin(Writer writer, Map<String, Object> context, ModelScreenWidget.Content content) throws IOException { + public void renderContentBegin(Appendable writer, Map<String, Object> context, ModelScreenWidget.Content content) throws IOException { // TODO: not implemented } - public void renderContentBody(Writer writer, Map<String, Object> context, ModelScreenWidget.Content content) throws IOException { + public void renderContentBody(Appendable writer, Map<String, Object> context, ModelScreenWidget.Content content) throws IOException { // TODO: not implemented } - public void renderContentEnd(Writer writer, Map<String, Object> context, ModelScreenWidget.Content content) throws IOException { + public void renderContentEnd(Appendable writer, Map<String, Object> context, ModelScreenWidget.Content content) throws IOException { // TODO: not implemented } - public void renderContentFrame(Writer writer, Map<String, Object> context, ModelScreenWidget.Content content) throws IOException { + public void renderContentFrame(Appendable writer, Map<String, Object> context, ModelScreenWidget.Content content) throws IOException { // TODO: not implemented } - public void renderSubContentBegin(Writer writer, Map<String, Object> context, ModelScreenWidget.SubContent content) throws IOException { + public void renderSubContentBegin(Appendable writer, Map<String, Object> context, ModelScreenWidget.SubContent content) throws IOException { // TODO: not implemented } - public void renderSubContentBody(Writer writer, Map<String, Object> context, ModelScreenWidget.SubContent content) throws IOException { + public void renderSubContentBody(Appendable writer, Map<String, Object> context, ModelScreenWidget.SubContent content) throws IOException { // TODO: not implemented } - public void renderSubContentEnd(Writer writer, Map<String, Object> context, ModelScreenWidget.SubContent content) throws IOException { + public void renderSubContentEnd(Appendable writer, Map<String, Object> context, ModelScreenWidget.SubContent content) throws IOException { // TODO: not implemented } - public void renderScreenletBegin(Writer writer, Map<String, Object> context, boolean collapsed, ModelScreenWidget.Screenlet screenlet) throws IOException { + public void renderScreenletBegin(Appendable writer, Map<String, Object> context, boolean collapsed, ModelScreenWidget.Screenlet screenlet) throws IOException { // TODO: not implemented } - public void renderScreenletSubWidget(Writer writer, Map<String, Object> context, ModelScreenWidget subWidget, ModelScreenWidget.Screenlet screenlet) throws GeneralException { + public void renderScreenletSubWidget(Appendable writer, Map<String, Object> context, ModelScreenWidget subWidget, ModelScreenWidget.Screenlet screenlet) throws GeneralException { // TODO: not implemented } - public void renderScreenletEnd(Writer writer, Map<String, Object> context, ModelScreenWidget.Screenlet screenlet) throws IOException { + public void renderScreenletEnd(Appendable writer, Map<String, Object> context, ModelScreenWidget.Screenlet screenlet) throws IOException { // TODO: not implemented } } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FormStringRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FormStringRenderer.java?rev=662328&r1=662327&r2=662328&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FormStringRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FormStringRenderer.java Sun Jun 1 22:27:12 2008 @@ -26,71 +26,71 @@ * Widget Library - Form String Renderer interface. */ public interface FormStringRenderer { - public void renderDisplayField(Writer writer, Map<String, Object> context, ModelFormField.DisplayField displayField) throws IOException; - public void renderHyperlinkField(Writer writer, Map<String, Object> context, ModelFormField.HyperlinkField hyperlinkField) throws IOException; + public void renderDisplayField(Appendable writer, Map<String, Object> context, ModelFormField.DisplayField displayField) throws IOException; + public void renderHyperlinkField(Appendable writer, Map<String, Object> context, ModelFormField.HyperlinkField hyperlinkField) throws IOException; - public void renderTextField(Writer writer, Map<String, Object> context, ModelFormField.TextField textField) throws IOException; - public void renderTextareaField(Writer writer, Map<String, Object> context, ModelFormField.TextareaField textareaField) throws IOException; - public void renderDateTimeField(Writer writer, Map<String, Object> context, ModelFormField.DateTimeField dateTimeField) throws IOException; - - public void renderDropDownField(Writer writer, Map<String, Object> context, ModelFormField.DropDownField dropDownField) throws IOException; - public void renderCheckField(Writer writer, Map<String, Object> context, ModelFormField.CheckField checkField) throws IOException; - public void renderRadioField(Writer writer, Map<String, Object> context, ModelFormField.RadioField radioField) throws IOException; - - public void renderSubmitField(Writer writer, Map<String, Object> context, ModelFormField.SubmitField submitField) throws IOException; - public void renderResetField(Writer writer, Map<String, Object> context, ModelFormField.ResetField resetField) throws IOException; - - public void renderHiddenField(Writer writer, Map<String, Object> context, ModelFormField modelFormField, String value) throws IOException; - public void renderHiddenField(Writer writer, Map<String, Object> context, ModelFormField.HiddenField hiddenField) throws IOException; - public void renderIgnoredField(Writer writer, Map<String, Object> context, ModelFormField.IgnoredField ignoredField) throws IOException; + public void renderTextField(Appendable writer, Map<String, Object> context, ModelFormField.TextField textField) throws IOException; + public void renderTextareaField(Appendable writer, Map<String, Object> context, ModelFormField.TextareaField textareaField) throws IOException; + public void renderDateTimeField(Appendable writer, Map<String, Object> context, ModelFormField.DateTimeField dateTimeField) throws IOException; + + public void renderDropDownField(Appendable writer, Map<String, Object> context, ModelFormField.DropDownField dropDownField) throws IOException; + public void renderCheckField(Appendable writer, Map<String, Object> context, ModelFormField.CheckField checkField) throws IOException; + public void renderRadioField(Appendable writer, Map<String, Object> context, ModelFormField.RadioField radioField) throws IOException; + + public void renderSubmitField(Appendable writer, Map<String, Object> context, ModelFormField.SubmitField submitField) throws IOException; + public void renderResetField(Appendable writer, Map<String, Object> context, ModelFormField.ResetField resetField) throws IOException; + + public void renderHiddenField(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String value) throws IOException; + public void renderHiddenField(Appendable writer, Map<String, Object> context, ModelFormField.HiddenField hiddenField) throws IOException; + public void renderIgnoredField(Appendable writer, Map<String, Object> context, ModelFormField.IgnoredField ignoredField) throws IOException; - public void renderFieldTitle(Writer writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; - public void renderSingleFormFieldTitle(Writer writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; + public void renderFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; + public void renderSingleFormFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; - public void renderFormOpen(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderMultiFormClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + public void renderFormOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + public void renderFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + public void renderMultiFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatListWrapperOpen(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatListWrapperClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + public void renderFormatListWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + public void renderFormatListWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatHeaderRowOpen(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatHeaderRowClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatHeaderRowCellOpen(Writer writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, int positionSpan) throws IOException; - public void renderFormatHeaderRowCellClose(Writer writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField) throws IOException; - - public void renderFormatHeaderRowFormCellOpen(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatHeaderRowFormCellClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatHeaderRowFormCellTitleSeparator(Writer writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, boolean isLast) throws IOException; + public void renderFormatHeaderRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + public void renderFormatHeaderRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + public void renderFormatHeaderRowCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, int positionSpan) throws IOException; + public void renderFormatHeaderRowCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField) throws IOException; + + public void renderFormatHeaderRowFormCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + public void renderFormatHeaderRowFormCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + public void renderFormatHeaderRowFormCellTitleSeparator(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, boolean isLast) throws IOException; - public void renderFormatItemRowOpen(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatItemRowClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatItemRowCellOpen(Writer writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, int positionSpan) throws IOException; - public void renderFormatItemRowCellClose(Writer writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField) throws IOException; - public void renderFormatItemRowFormCellOpen(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatItemRowFormCellClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - - public void renderFormatSingleWrapperOpen(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatSingleWrapperClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - - public void renderFormatFieldRowOpen(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatFieldRowClose(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatFieldRowTitleCellOpen(Writer writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; - public void renderFormatFieldRowTitleCellClose(Writer writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; - public void renderFormatFieldRowSpacerCell(Writer writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; - public void renderFormatFieldRowWidgetCellOpen(Writer writer, Map<String, Object> context, ModelFormField modelFormField, int positions, int positionSpan, Integer nextPositionInRow) throws IOException; - public void renderFormatFieldRowWidgetCellClose(Writer writer, Map<String, Object> context, ModelFormField modelFormField, int positions, int positionSpan, Integer nextPositionInRow) throws IOException; - - public void renderFormatEmptySpace(Writer writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - - public void renderTextFindField(Writer writer, Map<String, Object> context, ModelFormField.TextFindField textField) throws IOException; - public void renderDateFindField(Writer writer, Map<String, Object> context, ModelFormField.DateFindField textField) throws IOException; - public void renderRangeFindField(Writer writer, Map<String, Object> context, ModelFormField.RangeFindField textField) throws IOException; - public void renderLookupField(Writer writer, Map<String, Object> context, ModelFormField.LookupField textField) throws IOException; - public void renderFileField(Writer writer, Map<String, Object> context, ModelFormField.FileField textField) throws IOException; - public void renderPasswordField(Writer writer, Map<String, Object> context, ModelFormField.PasswordField textField) throws IOException; - public void renderImageField(Writer writer, Map<String, Object> context, ModelFormField.ImageField textField) throws IOException; - public void renderBanner(Writer writer, Map<String, Object> context, ModelForm.Banner banner) throws IOException; - public void renderFieldGroupOpen(Writer writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; - public void renderFieldGroupClose(Writer writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; + public void renderFormatItemRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + public void renderFormatItemRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + public void renderFormatItemRowCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, int positionSpan) throws IOException; + public void renderFormatItemRowCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField) throws IOException; + public void renderFormatItemRowFormCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + public void renderFormatItemRowFormCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + + public void renderFormatSingleWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + public void renderFormatSingleWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + + public void renderFormatFieldRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + public void renderFormatFieldRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + public void renderFormatFieldRowTitleCellOpen(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; + public void renderFormatFieldRowTitleCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; + public void renderFormatFieldRowSpacerCell(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; + public void renderFormatFieldRowWidgetCellOpen(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions, int positionSpan, Integer nextPositionInRow) throws IOException; + public void renderFormatFieldRowWidgetCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions, int positionSpan, Integer nextPositionInRow) throws IOException; + + public void renderFormatEmptySpace(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + + public void renderTextFindField(Appendable writer, Map<String, Object> context, ModelFormField.TextFindField textField) throws IOException; + public void renderDateFindField(Appendable writer, Map<String, Object> context, ModelFormField.DateFindField textField) throws IOException; + public void renderRangeFindField(Appendable writer, Map<String, Object> context, ModelFormField.RangeFindField textField) throws IOException; + public void renderLookupField(Appendable writer, Map<String, Object> context, ModelFormField.LookupField textField) throws IOException; + public void renderFileField(Appendable writer, Map<String, Object> context, ModelFormField.FileField textField) throws IOException; + public void renderPasswordField(Appendable writer, Map<String, Object> context, ModelFormField.PasswordField textField) throws IOException; + public void renderImageField(Appendable writer, Map<String, Object> context, ModelFormField.ImageField textField) throws IOException; + public void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner) throws IOException; + public void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; + public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java?rev=662328&r1=662327&r2=662328&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Sun Jun 1 22:27:12 2008 @@ -771,7 +771,7 @@ * different form elements; implementing your own makes it possible to * use the same form definitions for many types of form UIs */ - public void renderFormString(Writer writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException { + public void renderFormString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException { runFormActions(context); setWidgetBoundaryComments(context); @@ -814,7 +814,7 @@ } } - public void renderSingleFormString(Writer writer, Map<String, Object> context, FormStringRenderer formStringRenderer, int positions) throws IOException { + public void renderSingleFormString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer, int positions) throws IOException { List tempFieldList = FastList.newInstance(); tempFieldList.addAll(this.fieldList); @@ -1048,7 +1048,7 @@ } - public void renderListFormString(Writer writer, Map<String, Object> context, FormStringRenderer formStringRenderer, int positions) throws IOException { + public void renderListFormString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer, int positions) throws IOException { // render list/tabular type forms // prepare the items iterator and compute the pagination parameters @@ -1071,7 +1071,7 @@ } - public void renderMultiFormString(Writer writer, Map<String, Object> context, FormStringRenderer formStringRenderer, int positions) throws IOException { + public void renderMultiFormString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer, int positions) throws IOException { if (!skipStart) { formStringRenderer.renderFormOpen(writer, context, this); } @@ -1092,7 +1092,7 @@ } - public int renderHeaderRow(Writer writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException { + public int renderHeaderRow(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException { int maxNumOfColumns = 0; // We will render one title/column for all the fields with the same name @@ -1354,7 +1354,7 @@ } } - public void renderItemRows(Writer writer, Map<String, Object> context, FormStringRenderer formStringRenderer, boolean formPerItem, int numOfColumns) throws IOException { + public void renderItemRows(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer, boolean formPerItem, int numOfColumns) throws IOException { this.rowCount = 0; String lookupName = this.getListName(); if (UtilValidate.isEmpty(lookupName)) { @@ -1574,7 +1574,7 @@ // The fields in the three lists, usually created in the preprocessing phase // of the renderItemRows method are rendered: this will create a visual representation // of one row (corresponding to one position). - public void renderItemRow(Writer writer, Map localContext, FormStringRenderer formStringRenderer, boolean formPerItem, List hiddenIgnoredFieldList, List innerDisplayHyperlinkFieldsBegin, List innerFormFields, List innerDisplayHyperlinkFieldsEnd, int position, int numOfColumns) throws IOException { + public void renderItemRow(Appendable writer, Map localContext, FormStringRenderer formStringRenderer, boolean formPerItem, List hiddenIgnoredFieldList, List innerDisplayHyperlinkFieldsBegin, List innerFormFields, List innerDisplayHyperlinkFieldsEnd, int position, int numOfColumns) throws IOException { int numOfCells = innerDisplayHyperlinkFieldsBegin.size() + innerDisplayHyperlinkFieldsEnd.size() + (innerFormFields.size() > 0? 1: 0); @@ -1692,7 +1692,7 @@ } return hiddenIgnoredFieldList; } - public void renderHiddenIgnoredFields(Writer writer, Map<String, Object> context, FormStringRenderer formStringRenderer, List fieldList) throws IOException { + public void renderHiddenIgnoredFields(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer, List fieldList) throws IOException { Iterator fieldIter = fieldList.iterator(); while (fieldIter.hasNext()) { ModelFormField modelFormField = (ModelFormField) fieldIter.next(); @@ -2737,12 +2737,12 @@ return this.style; } - public void renderStartString(Writer writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException { + public void renderStartString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException { formStringRenderer.renderFieldGroupOpen(writer, context, this); formStringRenderer.renderFormatSingleWrapperOpen(writer, context, modelForm); } - public void renderEndString(Writer writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException { + public void renderEndString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException { formStringRenderer.renderFormatSingleWrapperClose(writer, context, modelForm); formStringRenderer.renderFieldGroupClose(writer, context, this); } @@ -2777,7 +2777,7 @@ public String getRightText(Map<String, Object> context) { return this.rightText.expandString(context); } public String getRightTextStyle(Map<String, Object> context) { return this.rightTextStyle.expandString(context); } - public void renderString(Writer writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException { + public void renderString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException { formStringRenderer.renderBanner(writer, context, this); } } |
Free forum by Nabble | Edit this page |