Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Fri Mar 27 16:59:28 2009 @@ -76,7 +76,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRenderer { public static final String module = HtmlFormRenderer.class.getName(); - + protected HttpServletRequest request; protected HttpServletResponse response; protected RequestHandler rh; @@ -131,17 +131,17 @@ } public void addAsterisks(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { - + boolean requiredField = modelFormField.getRequiredField(); if (requiredField) { String requiredStyle = modelFormField.getRequiredFieldStyle(); - + if (UtilValidate.isEmpty(requiredStyle)) { writer.append("*"); } } } - + public void appendClassNames(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { String className = modelFormField.getWidgetStyle(); if (UtilValidate.isNotEmpty(className) || modelFormField.shouldBeRed(context)) { @@ -154,7 +154,7 @@ writer.append('"'); } } - + /* (non-Javadoc) * @see org.ofbiz.widget.form.FormStringRenderer#renderDisplayField(java.io.Writer, java.util.Map, org.ofbiz.widget.form.ModelFormField.DisplayField) */ @@ -163,7 +163,7 @@ ModelForm modelForm = modelFormField.getModelForm(); StringBuffer str = new StringBuffer(); - + String idName = modelFormField.getIdName(); if (UtilValidate.isNotEmpty(idName) && ("list".equals(modelForm.getType()) || "multi".equals(modelForm.getType()))) { idName += "_" + modelForm.getRowCount(); @@ -201,10 +201,10 @@ if (str.length() > 0) { writer.append("</span>"); } - + ModelFormField.InPlaceEditor inPlaceEditor = displayField.getInPlaceEditor(); boolean ajaxEnabled = inPlaceEditor != null && this.javaScriptEnabled; - + if (ajaxEnabled) { writer.append("<script language=\"JavaScript\" type=\"text/javascript\">"); String url = inPlaceEditor.getUrl(context); @@ -324,7 +324,7 @@ if (displayField instanceof DisplayEntityField) { this.makeHyperlinkString(writer, ((DisplayEntityField) displayField).getSubHyperlink(), context); } - + this.appendTooltip(writer, context, modelFormField); //appendWhitespace(writer); @@ -336,11 +336,11 @@ public void renderHyperlinkField(Appendable writer, Map<String, Object> context, HyperlinkField hyperlinkField) throws IOException { this.request.setAttribute("image", hyperlinkField.getImage()); ModelFormField modelFormField = hyperlinkField.getModelFormField(); - + WidgetWorker.makeHyperlinkByType(writer, hyperlinkField.getLinkType(), modelFormField.getWidgetStyle(), hyperlinkField.getTargetType(), hyperlinkField.getTarget(context), hyperlinkField.getParameterList(), hyperlinkField.getDescription(context), hyperlinkField.getTargetWindow(context), modelFormField, this.request, this.response, context); - + this.appendTooltip(writer, context, modelFormField); //appendWhitespace(writer); } @@ -413,7 +413,7 @@ } writer.append("/>"); - + this.addAsterisks(writer, context, modelFormField); this.makeHyperlinkString(writer, textField.getSubHyperlink(), context); @@ -467,7 +467,7 @@ if (textareaField.isReadOnly()) { writer.append(" readonly"); } - + writer.append('>'); String value = modelFormField.getEntry(context, textareaField.getDefaultValue(context)); @@ -476,7 +476,7 @@ } writer.append("</textarea>"); - + if (textareaField.getVisualEditorEnable()) { writer.append("<script language=\"javascript\" src=\"/images/htmledit/whizzywig.js\" type=\"text/javascript\"></script>"); writer.append("<script language=\"javascript\" type=\"text/javascript\"> buttonPath = \"/images/htmledit/\"; cssFile=\"/images/htmledit/simple.css\";makeWhizzyWig(\""); @@ -509,7 +509,7 @@ ModelFormField modelFormField = dateTimeField.getModelFormField(); String paramName = modelFormField.getParameterName(context); String defaultDateTimeString = dateTimeField.getDefaultDateTimeString(context); - + Map<String, String> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap")); if (uiLabelMap == null) { Debug.logWarning("Could not find uiLabelMap in context", module); @@ -553,7 +553,7 @@ writer.append(" title=\""); writer.append(localizedInputTitle); writer.append('"'); - + String value = modelFormField.getEntry(context, dateTimeField.getDefaultValue(context)); if (UtilValidate.isNotEmpty(value)) { if (value.length() > maxlength) { @@ -563,7 +563,7 @@ writer.append(value); writer.append('"'); } - + writer.append(" size=\""); writer.append(Integer.toString(size)); writer.append('"'); @@ -603,7 +603,7 @@ writer.append(",'"); writer.append(UtilHttp.encodeBlanks(modelFormField.getEntry(context, defaultDateTimeString))); writer.append("');\">"); - + writer.append("<img src=\""); this.appendContentUrl(writer, "/images/cal.gif"); writer.append("\" width=\"16\" height=\"16\" border=\"0\" alt=\""); @@ -612,7 +612,7 @@ writer.append(localizedIconTitle); writer.append("\"/></a>"); } - + // if we have an input method of time-dropdown, then render two dropdowns if ("time-dropdown".equals(dateTimeField.getInputMethod())) { String className = modelFormField.getWidgetStyle(); @@ -655,7 +655,7 @@ writer.append(">" + Integer.toString(i) + "</option>"); } } - + // write the select for minutes writer.append("</select>:<select name=\""); writer.append(UtilHttp.makeCompositeParam(paramName, "minutes") + "\""); @@ -705,7 +705,7 @@ String event = modelFormField.getEvent(); String action = modelFormField.getAction(context); - + String currentValue = modelFormField.getEntry(context); // Get the current value's description from the option value. If there // is a localized version it will be there. @@ -731,7 +731,7 @@ writer.append(modelFormField.getParameterName(context)); String idName = modelFormField.getIdName(); - + if (ajaxEnabled) { writer.append("_description\""); @@ -742,7 +742,7 @@ writer.append(textFieldIdName); writer.append('"'); } - + if (UtilValidate.isNotEmpty(currentValue)) { writer.append(" value=\""); String explicitDescription = (currentDescription != null ? currentDescription : dropDownField.getCurrentDescription(context)); @@ -754,7 +754,7 @@ writer.append('"'); } writer.append("/>"); - + appendWhitespace(writer); writer.append("<input type=\"hidden\""); writer.append(" name=\""); @@ -765,14 +765,14 @@ writer.append(idName); writer.append('"'); } - + if (UtilValidate.isNotEmpty(currentValue)) { writer.append(" value=\""); //String explicitDescription = dropDownField.getCurrentDescription(context); writer.append(currentValue); writer.append('"'); } - + writer.append("/>"); appendWhitespace(writer); @@ -809,7 +809,7 @@ if (dropDownField.isAllowMultiple()) { writer.append(" multiple=\"multiple\""); } - + int otherFieldSize = dropDownField.getOtherFieldSize(); String otherFieldName = dropDownField.getParameterNameOther(context); if (otherFieldSize > 0) { @@ -879,12 +879,12 @@ } writer.append("</select>"); - + // Adapted from work by Yucca Korpela // http://www.cs.tut.fi/~jkorpela/forms/combo.html if (otherFieldSize > 0) { - + String fieldName = modelFormField.getParameterName(context); Map<String, Object> dataMap = UtilGenerics.checkMap(modelFormField.getMap(context)); if (dataMap == null) { @@ -892,7 +892,7 @@ } Object otherValueObj = dataMap.get(otherFieldName); String otherValue = (otherValueObj == null) ? "" : otherValueObj.toString(); - + writer.append("<noscript>"); writer.append("<input type='text' name='"); writer.append(otherFieldName); @@ -927,7 +927,7 @@ writer.append("\n//--></script>"); } } - + this.makeHyperlinkString(writer, dropDownField.getSubHyperlink(), context); this.appendTooltip(writer, context, modelFormField); @@ -943,7 +943,7 @@ ModelForm modelForm = modelFormField.getModelForm(); String currentValue = modelFormField.getEntry(context); Boolean allChecked = checkField.isAllChecked(context); - + List<ModelFormField.OptionValue> allOptionValues = checkField.getAllOptionValues(context, modelForm.getDelegator(context)); String event = modelFormField.getEvent(); String action = modelFormField.getAction(context); @@ -956,7 +956,7 @@ writer.append("<input type=\"checkbox\""); appendClassNames(writer, context, modelFormField); - + // if current value should be selected in the list, select it if (Boolean.TRUE.equals(allChecked)) { writer.append(" checked=\"checked\""); @@ -979,7 +979,7 @@ writer.append(action); writer.append('"'); } - + writer.append("/>"); writer.append(optionValue.getDescription()); @@ -1011,7 +1011,7 @@ appendClassNames(writer, context, modelFormField); writer.append("><input type=\"radio\""); - + // if current value should be selected in the list, select it String noCurrentSelectedKey = radioField.getNoCurrentSelectedKey(context); if (UtilValidate.isNotEmpty(currentValue) && currentValue.equals(optionValue.getKey())) { @@ -1033,7 +1033,7 @@ writer.append(action); writer.append('"'); } - + writer.append("/>"); writer.append(optionValue.getDescription()); @@ -1085,7 +1085,7 @@ writer.append(" src=\""); this.appendContentUrl(writer, submitField.getImageLocation()); writer.append('"'); - + event = modelFormField.getEvent(); action = modelFormField.getAction(context); if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) { @@ -1095,7 +1095,7 @@ writer.append(action); writer.append('"'); } - + writer.append("/>"); } else { // default to "button" @@ -1132,7 +1132,7 @@ writer.append('"'); } - + event = modelFormField.getEvent(); action = modelFormField.getAction(context); if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) { @@ -1145,7 +1145,7 @@ //add single click JS onclick // disabling for now, using form onSubmit action instead: writer.append(singleClickAction); } - + if (ajaxEnabled) { writer.append(" onclick=\""); writer.append("ajaxSubmitFormUpdateAreas('"); @@ -1153,7 +1153,7 @@ writer.append("', '" + createAjaxParamsFromUpdateAreas(updateAreas, null, context)); writer.append("')\""); } - + writer.append("/>"); } @@ -1229,7 +1229,7 @@ public void renderFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { String tempTitleText = modelFormField.getTitle(context); String titleText = UtilHttp.encodeAmpersands(tempTitleText); - + if (UtilValidate.isNotEmpty(titleText)) { if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) { writer.append("<span class=\""); @@ -1258,12 +1258,12 @@ public void renderSingleFormFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { boolean requiredField = modelFormField.getRequiredField(); if (requiredField) { - + String requiredStyle = modelFormField.getRequiredFieldStyle(); if (UtilValidate.isEmpty(requiredStyle)) { requiredStyle = modelFormField.getTitleStyle(); } - + if (UtilValidate.isNotEmpty(requiredStyle)) { writer.append("<span class=\""); writer.append(requiredStyle); @@ -1324,7 +1324,7 @@ writer.append("basic-form"); } writer.append("\""); - + writer.append(" onSubmit=\"javascript:submitFormDisableSubmits(this)\""); if (!modelForm.getClientAutocompleteFields()) { @@ -1391,7 +1391,7 @@ } writer.append("</form>"); appendWhitespace(writer); - + // 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; @@ -1399,7 +1399,7 @@ writer.append(postMultiFormWriter.toString()); appendWhitespace(writer); } - + renderEndingBoundaryComment(writer, "Form Widget - Form Element (Multi)", modelForm); } @@ -1518,7 +1518,7 @@ * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatHeaderRowFormCellTitleSeparator(java.io.Writer, java.util.Map, org.ofbiz.widget.form.ModelForm, boolean) */ public void renderFormatHeaderRowFormCellTitleSeparator(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, boolean isLast) throws IOException { - + String titleStyle = modelFormField.getTitleStyle(); if (UtilValidate.isNotEmpty(titleStyle)) { writer.append("<span class=\""); @@ -1540,10 +1540,10 @@ */ public void renderFormatItemRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { Integer itemIndex = (Integer)context.get("itemIndex"); - + writer.append(" <tr"); if (itemIndex!=null) { - + String altRowStyles = modelForm.getStyleAltRowStyle(context); if (itemIndex.intValue() % 2 == 0) { String evenRowStyle = modelForm.getEvenRowStyle(); @@ -1756,7 +1756,7 @@ public void renderTextFindField(Appendable writer, Map<String, Object> context, TextFindField textFindField) throws IOException { ModelFormField modelFormField = textFindField.getModelFormField(); - + String defaultOption = textFindField.getDefaultOption(); Locale locale = (Locale)context.get("locale"); if (!textFindField.getHideOptions()) { @@ -1779,7 +1779,7 @@ writer.append(modelFormField.getParameterName(context)); writer.append("_op\" value=\"" + defaultOption + "\"/>"); } - + writer.append("<input type=\"text\""); appendClassNames(writer, context, modelFormField); @@ -1831,7 +1831,7 @@ writer.append(modelFormField.getParameterName(context)); writer.append("_ic\" value=\"" + (ignCase ? "Y" : "") + "\"/>"); } - + if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) { writer.append("</span>"); } @@ -2204,7 +2204,7 @@ } writer.append("/>"); - + // add lookup pop-up button String descriptionFieldName = lookupField.getDescriptionFieldName(); if (UtilValidate.isNotEmpty(descriptionFieldName)) { @@ -2239,7 +2239,7 @@ writer.append("\" width=\"15\" height=\"14\" border=\"0\" alt=\"Lookup\"/></a>"); this.addAsterisks(writer, context, modelFormField); - + this.makeHyperlinkString(writer, lookupField.getSubHyperlink(), context); this.appendTooltip(writer, context, modelFormField); @@ -2434,7 +2434,7 @@ writer.append(commonDisplaying); writer.append("</li>"); appendWhitespace(writer); - + // Next button writer.append(" <li class=\"" + modelForm.getPaginateNextStyle()); if (highIndex < listSize) { @@ -2498,7 +2498,7 @@ String str = (String) context.get("_QBESTRING_"); String oldSortField = modelForm.getSortField(context); String sortFieldStyle = modelFormField.getSortFieldStyle(); - + // if the entry-name is defined use this instead of field name String columnField = modelFormField.getEntryName(); if (UtilValidate.isEmpty(columnField)) { @@ -2555,7 +2555,7 @@ } writer.append("\">" + titleText + "</a>"); } - + /* (non-Javadoc) * @see org.ofbiz.widget.form.FormStringRenderer#renderFileField(java.io.Writer, java.util.Map, org.ofbiz.widget.form.ModelFormField.FileField) */ @@ -2710,7 +2710,7 @@ //appendWhitespace(writer); } - + public void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException { String style = fieldGroup.getStyle(); String id = fieldGroup.getId(); @@ -2765,7 +2765,7 @@ writer.append(title); writer.append("</div>"); } - + writer.append("</td></tr></table></div>"); writer.append("<div id=\"" + collapsibleAreaId + "\" class=\"fieldgroup-body\""); @@ -2775,7 +2775,7 @@ writer.append(">"); } } - + public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException { String style = fieldGroup.getStyle(); String id = fieldGroup.getId(); @@ -2785,7 +2785,7 @@ writer.append("</div>"); } } - + // TODO: Remove embedded styling public void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner) throws IOException { writer.append(" <table width=\"100%\"> <tr>"); @@ -2794,7 +2794,7 @@ if (UtilValidate.isEmpty(leftStyle)) leftStyle = style; String rightStyle = banner.getRightTextStyle(context); if (UtilValidate.isEmpty(rightStyle)) rightStyle = style; - + String leftText = banner.getLeftText(context); if (UtilValidate.isNotEmpty(leftText)) { writer.append(" <td align=\"left\">"); @@ -2811,7 +2811,7 @@ } writer.append("</td>"); } - + String text = banner.getText(context); if (UtilValidate.isNotEmpty(text)) { writer.append(" <td align=\"center\">"); @@ -2828,7 +2828,7 @@ } writer.append("</td>"); } - + String rightText = banner.getRightText(context); if (UtilValidate.isNotEmpty(rightText)) { writer.append(" <td align=\"right\">"); @@ -2847,7 +2847,7 @@ } writer.append("</tr> </table>"); } - + /** * Renders a link for the column header fields when there is a header-link="" specified in the <field > tag, using * style from header-link-style="". Also renders a selectAll checkbox in multi forms. Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java Fri Mar 27 16:59:28 2009 @@ -43,9 +43,9 @@ * Widget Library - HTML Form Wrapper class - makes it easy to do the setup and render of a form */ public class HtmlFormWrapper { - + public static final String module = HtmlFormWrapper.class.getName(); - + protected String resourceName; protected String formName; protected HttpServletRequest request; @@ -62,7 +62,7 @@ this.formName = formName; this.request = request; this.response = response; - + try { GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); @@ -73,35 +73,35 @@ } this.renderer = new HtmlFormRenderer(request, response); - + this.context = new HashMap<String, Object>(); Map parameterMap = UtilHttp.getParameterMap(request); context.put("parameters", parameterMap); - + //make sure the locale is in the context context.put("locale", UtilHttp.getLocale(request)); //make sure the timeZone is in the context context.put("timeZone", UtilHttp.getTimeZone(request)); - + // if there was an error message, this is an error if (UtilValidate.isNotEmpty((String) request.getAttribute("_ERROR_MESSAGE_"))) { context.put("isError", Boolean.TRUE); } else { context.put("isError", Boolean.FALSE); } - + // if a parameter was passed saying this is an error, it is an error if ("true".equals((String) parameterMap.get("isError"))) { context.put("isError", Boolean.TRUE); } - + Map uiLabelMap = (Map) request.getAttribute("uiLabelMap"); if (uiLabelMap != null && uiLabelMap.size() > 0 && context.get("uiLabelMap") == null) { Debug.logInfo("Got uiLabelMap: " + uiLabelMap, module); context.put("uiLabelMap", uiLabelMap); } } - + @SuppressWarnings("unchecked") public StringWriter renderFormString(Object contextStack) throws IOException { if (contextStack instanceof MapStack) { @@ -135,7 +135,7 @@ public void setIsError(boolean isError) { this.context.put("isError", Boolean.valueOf(isError)); } - + public boolean getIsError() { Boolean isErrorBoolean = (Boolean) this.context.get("isError"); if (isErrorBoolean == null) { @@ -144,7 +144,7 @@ return isErrorBoolean.booleanValue(); } } - + /** * The "useRequestParameters" value in the form context tells the form library * to use the request parameters to fill in values instead of the value map. @@ -157,7 +157,7 @@ public void setUseRequestParameters(boolean useRequestParameters) { this.context.put("useRequestParameters", Boolean.valueOf(useRequestParameters)); } - + public boolean getUseRequestParameters() { Boolean useRequestParametersBoolean = (Boolean) this.context.get("useRequestParameters"); if (useRequestParametersBoolean == null) { @@ -166,19 +166,19 @@ return useRequestParametersBoolean.booleanValue(); } } - + public void setFormOverrideName(String formName) { this.context.put("formName", formName); } - + public void putInContext(String name, Object value) { this.context.put(name, value); } - + public Object getFromContext(String name) { return this.context.get(name); } - + public ModelForm getModelForm() { return modelForm; } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java Fri Mar 27 16:59:28 2009 @@ -141,7 +141,7 @@ } public void renderMenuItem(Appendable writer, Map<String, Object> context, ModelMenuItem menuItem) throws IOException { - + //Debug.logInfo("in renderMenuItem, menuItem:" + menuItem.getName() + " context:" + context ,""); boolean hideThisItem = isHideIfSelected(menuItem, context); //if (Debug.infoOn()) Debug.logInfo("in HtmlMenuRendererImage, hideThisItem:" + hideThisItem,""); @@ -149,18 +149,18 @@ return; String style = null; - + if (menuItem.isSelected(context)) { style = menuItem.getSelectedStyle(); if (UtilValidate.isEmpty(style)) { style = "selected"; } } - + if (menuItem.getDisabled()) { style = menuItem.getDisabledTitleStyle(); } - + writer.append(" <li"); String alignStyle = menuItem.getAlignStyle(); if (UtilValidate.isNotEmpty(style) || UtilValidate.isNotEmpty(alignStyle)) { @@ -178,7 +178,7 @@ writer.append(" title=\"" + toolTip + "\""); } writer.append(">"); - + Link link = menuItem.getLink(); //if (Debug.infoOn()) Debug.logInfo("in HtmlMenuRendererImage, link(0):" + link,""); if (link != null) { @@ -186,7 +186,7 @@ } writer.append("</li>"); - + appendWhitespace(writer); } @@ -249,7 +249,7 @@ } appendWhitespace(writer); writer.append(" <ul>"); - + appendWhitespace(writer); } @@ -273,7 +273,7 @@ writer.append("</div>"); appendWhitespace(writer); renderEndingBoundaryComment(writer, "Menu Widget", modelMenu); - + userLoginIdHasChanged = userLoginIdHasChanged(); GenericValue userLogin = (GenericValue)request.getSession().getAttribute("userLogin"); if (userLogin != null) { @@ -368,7 +368,7 @@ if (menuItem.getDisabled()) { target = null; } - + if (UtilValidate.isNotEmpty(target)) { HttpServletResponse response = (HttpServletResponse) context.get("response"); HttpServletRequest request = (HttpServletRequest) context.get("request"); @@ -404,10 +404,10 @@ writer.append(parameter.getValue(context)); writer.append("\" type=\"hidden\"/>"); } - + writer.append("</form>"); } - + writer.append("<a"); String id = link.getId(context); if (UtilValidate.isNotEmpty(id)) { @@ -415,7 +415,7 @@ writer.append(id); writer.append("\""); } - + String style = link.getStyle(context); if (UtilValidate.isNotEmpty(style)) { writer.append(" class=\""); @@ -445,7 +445,7 @@ } writer.append("\">"); } - + // the text Image img = link.getImage(); if (img == null) { @@ -453,17 +453,17 @@ } else { renderImage(writer, context, img); } - + if (UtilValidate.isNotEmpty(target)) { // close tag writer.append("</a>"); } - + /* NOTE DEJ20090316: This was here as a comment and not sure what it is for or if it is useful... can probably be safely removed in the future if still not used/needed boolean isSelected = menuItem.isSelected(context); - + String style = null; - + if (isSelected) { style = menuItem.getSelectedStyle(); } else { @@ -473,11 +473,11 @@ if (UtilValidate.isEmpty(style)) style = menuItem.getWidgetStyle(); } - + if (menuItem.getDisabled()) { style = menuItem.getDisabledTitleStyle(); } - + if (UtilValidate.isNotEmpty(style)) { writer.append(" class=\""); writer.append(style); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRendererImage.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRendererImage.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRendererImage.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRendererImage.java Fri Mar 27 16:59:28 2009 @@ -73,7 +73,7 @@ String widthStr = ""; if (UtilValidate.isNotEmpty(cellWidth)) widthStr = " width=\"" + cellWidth + "\" "; - + imgStr += widthStr; imgStr += " border=\"0\" />"; return imgStr; Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapper.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapper.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapper.java Fri Mar 27 16:59:28 2009 @@ -45,9 +45,9 @@ * Widget Library - HTML Menu Wrapper class - makes it easy to do the setup and render of a menu */ public class HtmlMenuWrapper { - + public static final String module = HtmlMenuWrapper.class.getName(); - + protected String resourceName; protected String menuName; protected HttpServletRequest request; @@ -69,11 +69,11 @@ this.menuName = menuName; this.request = request; this.response = response; - + this.modelMenu = MenuFactory.getMenuFromWebappContext(resourceName, menuName, request); this.renderer = getMenuRenderer(); - + this.context = new HashMap<String, Object>(); Map parameterMap = UtilHttp.getParameterMap(request); context.put("parameters", parameterMap); @@ -81,17 +81,17 @@ HttpSession session = request.getSession(); GenericValue userLogin = (GenericValue)session.getAttribute("userLogin"); context.put("userLogin", userLogin); - + //make sure the locale is in the context context.put("locale", UtilHttp.getLocale(request)); - + // if there was an error message, this is an error if (UtilValidate.isNotEmpty((String) request.getAttribute("_ERROR_MESSAGE_"))) { context.put("isError", Boolean.TRUE); } else { context.put("isError", Boolean.FALSE); } - + // if a parameter was passed saying this is an error, it is an error if ("true".equals((String) parameterMap.get("isError"))) { context.put("isError", Boolean.TRUE); @@ -101,7 +101,7 @@ public MenuStringRenderer getMenuRenderer() { return new HtmlMenuRenderer(request, response); } - + public String renderMenuString() throws IOException { HttpServletRequest req = ((HtmlMenuRenderer)renderer).request; ServletContext ctx = (ServletContext) req.getAttribute("servletContext"); @@ -131,7 +131,7 @@ public void setIsError(boolean isError) { this.context.put("isError", Boolean.valueOf(isError)); } - + public boolean getIsError() { Boolean isErrorBoolean = (Boolean) this.context.get("isError"); if (isErrorBoolean == null) { @@ -140,15 +140,15 @@ return isErrorBoolean.booleanValue(); } } - + public void setMenuOverrideName(String menuName) { this.context.put("menuName", menuName); } - + public void putInContext(String name, Object value) { this.context.put(name, value); } - + public void putInContext(String menuItemName, String valueName, Object value) { Map<String, Object> valueMap = UtilGenerics.toMap(context.get(menuItemName)); if (valueMap == null) { @@ -157,11 +157,11 @@ } valueMap.put(valueName, value); } - + public Object getFromContext(String name) { return this.context.get(name); } - + public Object getFromContext(String menuItemName, String valueName) { Map<String, Object> valueMap = UtilGenerics.toMap(context.get(menuItemName)); if (valueMap == null) { @@ -170,7 +170,7 @@ } return valueMap.get(valueName); } - + public ModelMenu getModelMenu() { return modelMenu; } @@ -202,9 +202,9 @@ } public static HtmlMenuWrapper getMenuWrapper(HttpServletRequest request, HttpServletResponse response, HttpSession session, String menuDefFile, String menuName, String menuWrapperClassName ) { - + HtmlMenuWrapper menuWrapper = null; - + String menuSig = menuDefFile + "__" + menuName; if (session != null) { menuWrapper = (HtmlMenuWrapper)session.getAttribute(menuSig); @@ -236,7 +236,7 @@ GenericValue userLogin = (GenericValue)session.getAttribute("userLogin"); menuWrapper.putInContext("userLogin", userLogin); - + } if (session != null) { Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapperImage.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapperImage.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapperImage.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuWrapperImage.java Fri Mar 27 16:59:28 2009 @@ -40,7 +40,7 @@ * Widget Library - HTML Menu Wrapper class - makes it easy to do the setup and render of a menu */ public class HtmlMenuWrapperImage extends HtmlMenuWrapper { - + public static final String module = HtmlMenuWrapperImage.class.getName(); protected HtmlMenuWrapperImage() {} @@ -53,10 +53,10 @@ public MenuStringRenderer getMenuRenderer() { return new HtmlMenuRendererImage(request, response); } - + public void init(String resourceName, String menuName, HttpServletRequest request, HttpServletResponse response) throws IOException, SAXException, ParserConfigurationException { - + super.init(resourceName, menuName, request, response); //String pubPt = (String)request.getAttribute("pubPt"); //if (Debug.infoOn()) Debug.logInfo("in init, pubPt:" + pubPt, module); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java Fri Mar 27 16:59:28 2009 @@ -101,14 +101,14 @@ writer.append(containerId); writer.append("\""); } - + String style = container.getStyle(context); if (UtilValidate.isNotEmpty(style)) { writer.append(" class=\""); writer.append(style); writer.append("\""); } - + writer.append(">"); appendWhitespace(writer); } @@ -235,7 +235,7 @@ appendWhitespace(writer); } } - + protected void renderScreenletPaginateMenu(Appendable writer, Map<String, Object> context, ModelScreenWidget.Form form) throws IOException { HttpServletResponse response = (HttpServletResponse) context.get("response"); HttpServletRequest request = (HttpServletRequest) context.get("request"); @@ -378,7 +378,7 @@ writer.append("</li>"); appendWhitespace(writer); } - + public void renderScreenletSubWidget(Appendable writer, Map<String, Object> context, ModelScreenWidget subWidget, ModelScreenWidget.Screenlet screenlet) throws GeneralException, IOException { if (subWidget.equals(screenlet.getNavigationForm())) { HttpServletRequest request = (HttpServletRequest) context.get("request"); @@ -424,7 +424,7 @@ String id = label.getId(context); if (UtilValidate.isNotEmpty(style) || UtilValidate.isNotEmpty(id) ) { writer.append("<span"); - + if (UtilValidate.isNotEmpty(id)) { writer.append(" id=\""); writer.append(id); @@ -436,17 +436,17 @@ writer.append("\""); } writer.append(">"); - + // the text writer.append(labelText); - + // close tag writer.append("</span>"); - + } else { writer.append(labelText); } - + appendWhitespace(writer); } @@ -456,7 +456,7 @@ String targetWindow = link.getTargetWindow(context); String target = link.getTarget(context); - + String uniqueItemName = link.getModelScreen().getName() + "_LF_" + UtilMisc.<String>addToBigDecimalInMap(context, "screenUniqueItemIndex", BigDecimal.ONE); String linkType = WidgetWorker.determineAutoLinkType(link.getLinkType(), target, link.getUrlMode(), request); @@ -487,10 +487,10 @@ writer.append(parameter.getValue(context)); writer.append("\" type=\"hidden\"/>"); } - + writer.append("</form>"); } - + writer.append("<a"); String id = link.getId(context); if (UtilValidate.isNotEmpty(id)) { @@ -528,7 +528,7 @@ writer.append("\""); } writer.append(">"); - + // the text ModelScreenWidget.Image img = link.getImage(); if (img == null) { @@ -536,10 +536,10 @@ } else { renderImage(writer, context, img); } - + // close tag writer.append("</a>"); - + appendWhitespace(writer); } @@ -586,7 +586,7 @@ writer.append(alt); writer.append("\""); } - + writer.append(" src=\""); String urlMode = image.getUrlMode(); boolean fullPath = false; @@ -613,9 +613,9 @@ } else { writer.append(src); } - + writer.append("\"/>"); - + appendWhitespace(writer); } @@ -624,9 +624,9 @@ String editContainerStyle = content.getEditContainerStyle(context); String enableEditName = content.getEnableEditName(context); String enableEditValue = (String)context.get(enableEditName); - + if (Debug.verboseOn()) Debug.logVerbose("directEditRequest:" + editRequest, module); - + if (UtilValidate.isNotEmpty(editRequest) && "true".equals(enableEditValue)) { writer.append("<div"); writer.append(" class=\"" + editContainerStyle + "\"> "); @@ -649,7 +649,7 @@ contentContext.putAll(context); String dataResourceId = (String)contentContext.get("dataResourceId"); if (Debug.verboseOn()) Debug.logVerbose("expandedContentId:" + expandedContentId, module); - + try { if (UtilValidate.isNotEmpty(dataResourceId)) { if (WidgetDataResourceWorker.dataresourceWorker != null) { @@ -683,7 +683,7 @@ if (content.xmlEscape()) { renderedContent = UtilFormatOut.encodeXmlValue(renderedContent); } - + writer.append(renderedContent); } @@ -711,7 +711,7 @@ editMode += " Image"; } //String editRequestWithParams = editRequest + "?contentId=${currentValue.contentId}&drDataResourceId=${currentValue.drDataResourceId}&directEditRequest=${directEditRequest}&indirectEditRequest=${indirectEditRequest}&caContentIdTo=${currentValue.caContentIdTo}&caFromDate=${currentValue.caFromDate}&caContentAssocTypeId=${currentValue.caContentAssocTypeId}"; - + if (UtilValidate.isNotEmpty(editRequest) && "true".equals(enableEditValue)) { HttpServletResponse response = (HttpServletResponse) context.get("response"); HttpServletRequest request = (HttpServletRequest) context.get("request"); @@ -733,18 +733,18 @@ } public void renderContentFrame(Appendable writer, Map<String, Object> context, ModelScreenWidget.Content content) throws IOException { - + String dataResourceId = content.getDataResourceId(context); // String urlString = "/content/control/ViewSimpleContent?dataResourceId=" + dataResourceId; String urlString = "/ViewSimpleContent?dataResourceId=" + dataResourceId; - + String width = content.getWidth(); String widthString=" width=\"" + width + "\""; String height = content.getHeight(); String heightString=" height=\"" + height + "\""; String border = content.getBorder(); String borderString = (UtilValidate.isNotEmpty(border)) ? " border=\"" + border + "\"" : ""; - + HttpServletRequest request = (HttpServletRequest) context.get("request"); HttpServletResponse response = (HttpServletResponse) context.get("response"); if (request != null && response != null) { @@ -754,7 +754,7 @@ String linkString = "<iframe src=\"" + fullUrlString + "\" " + widthString + heightString + borderString + " />"; writer.append(linkString); } - + } public void renderSubContentBegin(Appendable writer, Map<String, Object> context, ModelScreenWidget.SubContent content) throws IOException { @@ -766,7 +766,7 @@ if (UtilValidate.isNotEmpty(editRequest) && "true".equals(enableEditValue)) { writer.append("<div"); writer.append(" class=\"" + editContainerStyle + "\"> "); - + appendWhitespace(writer); } } @@ -804,7 +804,7 @@ if (content.xmlEscape()) { renderedContent = UtilFormatOut.encodeXmlValue(renderedContent); } - + writer.append(renderedContent); } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java Fri Mar 27 16:59:28 2009 @@ -77,7 +77,7 @@ if (depth < targetNodeTrail.size()) { targetEntityId = (String)targetNodeTrail.get(depth); } - + int openDepth = node.getModelTree().getOpenDepth(); if (depth >= openDepth && (targetEntityId == null || !targetEntityId.equals(entityId))) { // Not on the trail @@ -151,7 +151,7 @@ writer.append("<ul class=\"basic-tree\">"); } } - + public void renderLabel(Appendable writer, Map<String, Object> context, ModelTree.ModelNode.Label label) throws IOException { // open tag writer.append("<span"); @@ -168,13 +168,13 @@ writer.append("\""); } writer.append(">"); - + // the text writer.append(label.getText(context)); - + // close tag writer.append("</span>"); - + appendWhitespace(writer); } @@ -254,7 +254,7 @@ writer.append("\""); } writer.append(">"); - + // the text ModelTree.ModelNode.Image img = link.getImage(); if (img == null) { @@ -330,7 +330,7 @@ writer.append("\""); } writer.append("/>"); - + } public ScreenStringRenderer getScreenStringRenderer(Map<String, Object> context) { Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlWidgetRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlWidgetRenderer.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlWidgetRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlWidgetRenderer.java Fri Mar 27 16:59:28 2009 @@ -43,7 +43,7 @@ public void appendWhitespace(Appendable writer) throws IOException { writer.append(whiteSpace); } - + /** * Helper method used to build the boundary comment string. * @param boundaryType The boundary type: "Begin" or "End" @@ -53,7 +53,7 @@ public String buildBoundaryComment(String boundaryType, String widgetType, String widgetName) { return formatBoundaryComment(boundaryType, widgetType, widgetName); } - + public static String formatBoundaryComment(String boundaryType, String widgetType, String widgetName) { return "<!-- " + boundaryType + " " + widgetType + " " + widgetName + " -->" + whiteSpace; } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MenuFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MenuFactory.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MenuFactory.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MenuFactory.java Fri Mar 27 16:59:28 2009 @@ -45,18 +45,18 @@ * Widget Library - Menu factory class */ public class MenuFactory { - + public static final String module = MenuFactory.class.getName(); public static final UtilCache<String, Map<String, ModelMenu>> menuWebappCache = new UtilCache<String, Map<String, ModelMenu>>("widget.menu.webappResource", 0, 0, false); public static final UtilCache<String, Map<String, ModelMenu>> menuLocationCache = new UtilCache<String, Map<String, ModelMenu>>("widget.menu.locationResource", 0, 0, false); - + public static ModelMenu getMenuFromWebappContext(String resourceName, String menuName, HttpServletRequest request) throws IOException, SAXException, ParserConfigurationException { String webappName = UtilHttp.getApplicationName(request); String cacheKey = webappName + "::" + resourceName; - - + + Map<String, ModelMenu> modelMenuMap = menuWebappCache.get(cacheKey); if (modelMenuMap == null) { synchronized (MenuFactory.class) { @@ -65,7 +65,7 @@ ServletContext servletContext = (ServletContext) request.getAttribute("servletContext"); GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher"); - + URL menuFileUrl = servletContext.getResource(resourceName); Document menuFileDoc = UtilXml.readXmlDocument(menuFileUrl, true); modelMenuMap = readMenuDocument(menuFileDoc, delegator, dispatcher, cacheKey); @@ -73,18 +73,18 @@ } } } - + if (UtilValidate.isEmpty(modelMenuMap)) { throw new IllegalArgumentException("Could not find menu file in webapp resource [" + resourceName + "] in the webapp [" + webappName + "]"); } - + ModelMenu modelMenu = (ModelMenu) modelMenuMap.get(menuName); if (modelMenu == null) { throw new IllegalArgumentException("Could not find menu with name [" + menuName + "] in webapp resource [" + resourceName + "] in the webapp [" + webappName + "]"); } return modelMenu; } - + public static Map<String, ModelMenu> readMenuDocument(Document menuFileDoc, GenericDelegator delegator, LocalDispatcher dispatcher, String menuLocation) { Map<String, ModelMenu> modelMenuMap = new HashMap<String, ModelMenu>(); if (menuFileDoc != null) { @@ -113,7 +113,7 @@ if (loader == null) { loader = MenuFactory.class.getClassLoader(); } - + URL menuFileUrl = null; menuFileUrl = FlexibleLocation.resolveLocation(resourceName); //, loader); Document menuFileDoc = UtilXml.readXmlDocument(menuFileUrl, true); @@ -126,12 +126,12 @@ if (UtilValidate.isEmpty(modelMenuMap)) { throw new IllegalArgumentException("Could not find menu file in location [" + resourceName + "]"); } - + ModelMenu modelMenu = (ModelMenu) modelMenuMap.get(menuName); if (modelMenu == null) { throw new IllegalArgumentException("Could not find menu with name [" + menuName + "] in location [" + resourceName + "]"); } return modelMenu; } - + } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MenuWrapTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MenuWrapTransform.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MenuWrapTransform.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MenuWrapTransform.java Fri Mar 27 16:59:28 2009 @@ -55,7 +55,7 @@ public static final String module = MenuWrapTransform.class.getName(); public static final String [] upSaveKeyNames = {"globalNodeTrail"}; public static final String [] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale", "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly", "renderOnStart", "renderOnClose", "menuDefFile", "menuName", "associatedContentId", "wrapperClassName"}; - + /** * A wrapper for the FreeMarkerWorker version. */ @@ -168,7 +168,7 @@ } public void renderMenu() throws IOException { - + String menuDefFile = (String)templateCtx.get("menuDefFile"); String menuName = (String)templateCtx.get("menuName"); String menuWrapperClassName = (String)templateCtx.get("menuWrapperClassName"); @@ -183,7 +183,7 @@ String menuStr = menuWrapper.renderMenuString(); out.write(menuStr); } - + }; } } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java Fri Mar 27 16:59:28 2009 @@ -100,10 +100,10 @@ * with conditions is not possible. */ protected Map<String, ModelMenuItem> menuItemMap = new HashMap<String, ModelMenuItem>(); - + protected List<ModelMenuAction> actions; - + // ===== CONSTRUCTORS ===== /** Default Constructor */ public ModelMenu() {} @@ -484,7 +484,7 @@ public String getBoundaryCommentName() { return menuLocation + "#" + name; } - + public Interpreter getBshInterpreter(Map<String, Object> context) throws EvalError { Interpreter bsh = (Interpreter) context.get("bshInterpreter"); if (bsh == null) { Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuAction.java Fri Mar 27 16:59:28 2009 @@ -63,19 +63,19 @@ this.modelMenu = modelMenu; if (Debug.verboseOn()) Debug.logVerbose("Reading Screen action with name: " + actionElement.getNodeName(), module); } - + public ModelMenuAction(ModelMenuItem modelMenuItem, Element actionElement) { this.modelMenuItem = modelMenuItem; this.modelMenu = modelMenuItem.getModelMenu(); if (Debug.verboseOn()) Debug.logVerbose("Reading Screen action with name: " + actionElement.getNodeName(), module); } - + public abstract void runAction(Map<String, Object> context); - + public static List<ModelMenuAction> readSubActions(ModelMenuItem modelMenuItem, Element parentElement) { return readSubActions(modelMenuItem.getModelMenu(), parentElement); } - + public static List<ModelMenuAction> readSubActions(ModelMenu modelMenu, Element parentElement) { List<? extends Element> actionElementList = UtilXml.childElementList(parentElement); ArrayList<ModelMenuAction> actions = new ArrayList<ModelMenuAction>(actionElementList.size()); @@ -103,7 +103,7 @@ actions.trimToSize(); return actions; } - + public static void runSubActions(List<ModelMenuAction> actions, Map<String, Object> context) { if (actions == null) return; for (ModelMenuAction action : actions) { @@ -111,7 +111,7 @@ action.runAction(context); } } - + public static class SetField extends ModelMenuAction { protected FlexibleMapAccessor<Object> field; protected FlexibleMapAccessor<Object> fromField; @@ -121,7 +121,7 @@ protected String type; protected String toScope; protected String fromScope; - + public SetField(ModelMenu modelMenu, Element setElement) { super (modelMenu, setElement); this.field = FlexibleMapAccessor.getInstance(setElement.getAttribute("field")); @@ -136,12 +136,12 @@ throw new IllegalArgumentException("Cannot specify a from-field [" + setElement.getAttribute("from-field") + "] and a value [" + setElement.getAttribute("value") + "] on the set action in a screen widget"); } } - + public void runAction(Map<String, Object> context) { String globalStr = this.globalExdr.expandString(context); // default to false boolean global = "true".equals(globalStr); - + Object newValue = null; if (this.fromScope != null && this.fromScope.equals("user")) { if (!this.fromField.isEmpty()) { @@ -154,7 +154,7 @@ } else if (!this.valueExdr.isEmpty()) { newValue = this.valueExdr.expandString(context); } - + } else if (this.fromScope != null && this.fromScope.equals("application")) { if (!this.fromField.isEmpty()) { String originalName = this.fromField.getOriginalName(); @@ -166,7 +166,7 @@ } else if (!this.valueExdr.isEmpty()) { newValue = this.valueExdr.expandString(context); } - + } else { if (!this.fromField.isEmpty()) { newValue = this.fromField.get(context); @@ -182,7 +182,7 @@ newValue = this.defaultExdr.expandString(context); } } - + if (UtilValidate.isNotEmpty(this.type)) { try { newValue = ObjectType.simpleTypeConvert(newValue, this.type, null, (TimeZone) context.get("timeZone"), (Locale) context.get("locale"), true); @@ -191,7 +191,7 @@ Debug.logError(e, errMsg, module); throw new IllegalArgumentException(errMsg); } - + } if (this.toScope != null && this.toScope.equals("user")) { String originalName = this.field.getOriginalName(); @@ -200,7 +200,7 @@ HttpSession session = (HttpSession)context.get("session"); session.setAttribute(newKey, newValue); if (Debug.verboseOn()) Debug.logVerbose("In user setting value for field from [" + this.field.getOriginalName() + "]: " + newValue, module); - + } else if (this.toScope != null && this.toScope.equals("application")) { String originalName = this.field.getOriginalName(); String currentWidgetTrail = (String)context.get("_WIDGETTRAIL_"); @@ -208,19 +208,19 @@ ServletContext servletContext = (ServletContext)context.get("application"); servletContext.setAttribute(newKey, newValue); if (Debug.verboseOn()) Debug.logVerbose("In application setting value for field from [" + this.field.getOriginalName() + "]: " + newValue, module); - + } else { if (Debug.verboseOn()) Debug.logVerbose("In screen setting field [" + this.field.getOriginalName() + "] to value: " + newValue, module); this.field.put(context, newValue); } - + if (global) { Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext")); if (globalCtx != null) { this.field.put(globalCtx, newValue); } } - + // this is a hack for backward compatibility with the JPublish page object Map<String, Object> page = UtilGenerics.checkMap(context.get("page")); if (page != null) { @@ -228,19 +228,19 @@ } } } - + public static class PropertyMap extends ModelMenuAction { protected FlexibleStringExpander resourceExdr; protected FlexibleMapAccessor<Map<String, Object>> mapNameAcsr; protected FlexibleStringExpander globalExdr; - + public PropertyMap(ModelMenu modelMenu, Element setElement) { super (modelMenu, setElement); this.resourceExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("resource")); this.mapNameAcsr = FlexibleMapAccessor.getInstance(setElement.getAttribute("map-name")); this.globalExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("global")); } - + public void runAction(Map<String, Object> context) { String globalStr = this.globalExdr.expandString(context); // default to false @@ -259,9 +259,9 @@ } } } - + public static class PropertyToField extends ModelMenuAction { - + protected FlexibleStringExpander resourceExdr; protected FlexibleStringExpander propertyExdr; protected FlexibleMapAccessor<Object> fieldAcsr; @@ -280,14 +280,14 @@ this.argListAcsr = FlexibleMapAccessor.getInstance(setElement.getAttribute("arg-list-name")); this.globalExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("global")); } - + public void runAction(Map<String, Object> context) { // default to false Locale locale = (Locale) context.get("locale"); String resource = this.resourceExdr.expandString(context, locale); String property = this.propertyExdr.expandString(context, locale); - + String value = null; if (noLocale) { value = UtilProperties.getPropertyValue(resource, property); @@ -297,7 +297,7 @@ if (value == null || value.length() == 0) { value = this.defaultExdr.expandString(context); } - + // note that expanding the value string here will handle defaultValue and the string from // the properties file; if we decide later that we don't want the string from the properties // file to be expanded we should just expand the defaultValue at the beginning of this method. @@ -313,15 +313,15 @@ fieldAcsr.put(context, value); } } - + public static class Script extends ModelMenuAction { protected String location; - + public Script(ModelMenu modelMenu, Element scriptElement) { super (modelMenu, scriptElement); this.location = scriptElement.getAttribute("location"); } - + public void runAction(Map<String, Object> context) { if (location.endsWith(".bsh")) { try { @@ -350,13 +350,13 @@ protected FlexibleMapAccessor<Map<String, Object>> resultMapNameAcsr; protected FlexibleStringExpander autoFieldMapExdr; protected Map<FlexibleMapAccessor<Object>, FlexibleMapAccessor<Object>> fieldMap; - + public Service(ModelMenu modelMenu, Element serviceElement) { super (modelMenu, serviceElement); this.serviceNameExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("service-name")); this.resultMapNameAcsr = FlexibleMapAccessor.getInstance(serviceElement.getAttribute("result-map-name")); this.autoFieldMapExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("auto-field-map")); - + List<? extends Element> fieldMapElementList = UtilXml.childElementList(serviceElement, "field-map"); if (fieldMapElementList.size() > 0) { this.fieldMap = FastMap.newInstance(); @@ -368,16 +368,16 @@ } } } - + public void runAction(Map<String, Object> context) { String serviceNameExpanded = this.serviceNameExdr.expandString(context); if (UtilValidate.isEmpty(serviceNameExpanded)) { throw new IllegalArgumentException("Service name was empty, expanded from: " + this.serviceNameExdr.getOriginal()); } - + String autoFieldMapString = this.autoFieldMapExdr.expandString(context); boolean autoFieldMapBool = !"false".equals(autoFieldMapString); - + try { Map<String, Object> serviceContext = null; if (autoFieldMapBool) { @@ -385,7 +385,7 @@ } else { serviceContext = FastMap.newInstance(); } - + if (this.fieldMap != null) { for (Map.Entry<FlexibleMapAccessor<Object>, FlexibleMapAccessor<Object>> entry: this.fieldMap.entrySet()) { FlexibleMapAccessor<Object> serviceContextFieldAcsr = entry.getKey(); @@ -393,9 +393,9 @@ serviceContextFieldAcsr.put(serviceContext, contextEnvAcsr.get(context)); } } - + Map<String, Object> result = this.modelMenu.getDispacher().runSync(serviceNameExpanded, serviceContext); - + if (!this.resultMapNameAcsr.isEmpty()) { this.resultMapNameAcsr.put(context, result); } else { @@ -411,12 +411,12 @@ public static class EntityOne extends ModelMenuAction { protected PrimaryKeyFinder finder; - + public EntityOne(ModelMenu modelMenu, Element entityOneElement) { super (modelMenu, entityOneElement); finder = new PrimaryKeyFinder(entityOneElement); } - + public void runAction(Map<String, Object> context) { try { finder.runFind(context, this.modelMenu.getDelegator()); @@ -430,12 +430,12 @@ public static class EntityAnd extends ModelMenuAction { protected ByAndFinder finder; - + public EntityAnd(ModelMenu modelMenu, Element entityAndElement) { super (modelMenu, entityAndElement); finder = new ByAndFinder(entityAndElement); } - + public void runAction(Map<String, Object> context) { try { finder.runFind(context, this.modelMenu.getDelegator()); @@ -449,12 +449,12 @@ public static class EntityCondition extends ModelMenuAction { ByConditionFinder finder; - + public EntityCondition(ModelMenu modelMenu, Element entityConditionElement) { super (modelMenu, entityConditionElement); finder = new ByConditionFinder(entityConditionElement); } - + public void runAction(Map<String, Object> context) { try { finder.runFind(context, this.modelMenu.getDelegator()); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuCondition.java Fri Mar 27 16:59:28 2009 @@ -90,17 +90,17 @@ } return cond; } - + public static abstract class MenuCondition { protected ModelMenuItem modelMenuItem; public MenuCondition(ModelMenuItem modelMenuItem, Element conditionElement) { this.modelMenuItem = modelMenuItem; } - + public abstract boolean eval(Map<String, Object> context); } - + public static List<MenuCondition> readSubConditions(ModelMenuItem modelMenuItem, Element conditionElement) { List<MenuCondition> condList = FastList.newInstance(); List<? extends Element> subElementList = UtilXml.childElementList(conditionElement); @@ -109,7 +109,7 @@ } return condList; } - + public static MenuCondition readCondition(ModelMenuItem modelMenuItem, Element conditionElement) { if (conditionElement == null) { return null; @@ -142,15 +142,15 @@ throw new IllegalArgumentException("Condition element not supported with name: " + conditionElement.getNodeName()); } } - + public static class And extends MenuCondition { protected List<MenuCondition> subConditions; - + public And(ModelMenuItem modelMenuItem, Element condElement) { super (modelMenuItem, condElement); this.subConditions = readSubConditions(modelMenuItem, condElement); } - + public boolean eval(Map<String, Object> context) { // return false for the first one in the list that is false, basic and algo for (MenuCondition subCondition: this.subConditions) { @@ -161,15 +161,15 @@ return true; } } - + public static class Xor extends MenuCondition { protected List<MenuCondition> subConditions; - + public Xor(ModelMenuItem modelMenuItem, Element condElement) { super (modelMenuItem, condElement); this.subConditions = readSubConditions(modelMenuItem, condElement); } - + public boolean eval(Map<String, Object> context) { // if more than one is true stop immediately and return false; if all are false return false; if only one is true return true boolean foundOneTrue = false; @@ -186,15 +186,15 @@ return foundOneTrue; } } - + public static class Or extends MenuCondition { protected List<MenuCondition> subConditions; - + public Or(ModelMenuItem modelMenuItem, Element condElement) { super (modelMenuItem, condElement); this.subConditions = readSubConditions(modelMenuItem, condElement); } - + public boolean eval(Map<String, Object> context) { // return true for the first one in the list that is true, basic or algo for (MenuCondition subCondition: this.subConditions) { @@ -205,16 +205,16 @@ return false; } } - + public static class Not extends MenuCondition { protected MenuCondition subCondition; - + public Not(ModelMenuItem modelMenuItem, Element condElement) { super (modelMenuItem, condElement); Element firstChildElement = UtilXml.firstChildElement(condElement); this.subCondition = readCondition(modelMenuItem, firstChildElement); } - + public boolean eval(Map<String, Object> context) { return !this.subCondition.eval(context); } @@ -294,20 +294,20 @@ public static class IfHasPermission extends MenuCondition { protected FlexibleStringExpander permissionExdr; protected FlexibleStringExpander actionExdr; - + public IfHasPermission(ModelMenuItem modelMenuItem, Element condElement) { super (modelMenuItem, condElement); this.permissionExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("permission")); this.actionExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("action")); } - + public boolean eval(Map<String, Object> context) { // if no user is logged in, treat as if the user does not have permission GenericValue userLogin = (GenericValue) context.get("userLogin"); if (userLogin != null) { String permission = permissionExdr.expandString(context); String action = actionExdr.expandString(context); - + Security security = (Security) context.get("security"); if (action != null && action.length() > 0) { // run hasEntityPermission @@ -329,7 +329,7 @@ protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleStringExpander methodExdr; protected FlexibleStringExpander classExdr; - + public IfValidateMethod(ModelMenuItem modelMenuItem, Element condElement) { super (modelMenuItem, condElement); this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field")); @@ -337,11 +337,11 @@ this.methodExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("method")); this.classExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("class")); } - + public boolean eval(Map<String, Object> context) { String methodName = this.methodExdr.expandString(context); String className = this.classExdr.expandString(context); - + Object fieldVal = this.fieldAcsr.get(context); String fieldString = null; if (fieldVal != null) { @@ -384,7 +384,7 @@ return resultBool.booleanValue(); } } - + public static class IfCompare extends MenuCondition { protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleStringExpander valueExdr; @@ -392,25 +392,25 @@ protected String operator; protected String type; protected FlexibleStringExpander formatExdr; - + public IfCompare(ModelMenuItem modelMenuItem, Element condElement) { super (modelMenuItem, condElement); this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field")); if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name")); this.valueExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("value")); - + this.operator = condElement.getAttribute("operator"); this.type = condElement.getAttribute("type"); this.formatExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("format")); } - + public boolean eval(Map<String, Object> context) { String value = this.valueExdr.expandString(context); String format = this.formatExdr.expandString(context); - + Object fieldVal = this.fieldAcsr.get(context); - + // always use an empty string by default if (fieldVal == null) { fieldVal = ""; @@ -429,11 +429,11 @@ throw new IllegalArgumentException(fullString.toString()); } - + return resultBool.booleanValue(); } } - + public static class IfCompareField extends MenuCondition { protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleMapAccessor<Object> toFieldAcsr; @@ -441,26 +441,26 @@ protected String operator; protected String type; protected FlexibleStringExpander formatExdr; - + public IfCompareField(ModelMenuItem modelMenuItem, Element condElement) { super (modelMenuItem, condElement); this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field")); if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name")); this.toFieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("to-field")); if (this.toFieldAcsr.isEmpty()) this.toFieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("to-field-name")); - + this.operator = condElement.getAttribute("operator"); this.type = condElement.getAttribute("type"); this.formatExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("format")); } - + public boolean eval(Map<String, Object> context) { String format = this.formatExdr.expandString(context); - + Object fieldVal = this.fieldAcsr.get(context); Object toFieldVal = this.toFieldAcsr.get(context); - + // always use an empty string by default if (fieldVal == null) { fieldVal = ""; @@ -479,25 +479,25 @@ throw new IllegalArgumentException(fullString.toString()); } - + return resultBool.booleanValue(); } } - + public static class IfRegexp extends MenuCondition { static PatternMatcher matcher = new Perl5Matcher(); static PatternCompiler compiler = new Perl5Compiler(); protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleStringExpander exprExdr; - + public IfRegexp(ModelMenuItem modelMenuItem, Element condElement) { super (modelMenuItem, condElement); this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field")); if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name")); this.exprExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("expr")); } - + public boolean eval(Map<String, Object> context) { Object fieldVal = this.fieldAcsr.get(context); String expr = this.exprExdr.expandString(context); @@ -518,20 +518,20 @@ } // always use an empty string by default if (fieldString == null) fieldString = ""; - + return matcher.matches(fieldString, pattern); } } - + public static class IfEmpty extends MenuCondition { protected FlexibleMapAccessor<Object> fieldAcsr; - + public IfEmpty(ModelMenuItem modelMenuItem, Element condElement) { super (modelMenuItem, condElement); this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field")); if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name")); } - + public boolean eval(Map<String, Object> context) { Object fieldVal = this.fieldAcsr.get(context); return ObjectType.isEmpty(fieldVal); @@ -539,14 +539,14 @@ } public static class IfEntityPermission extends MenuCondition { protected EntityPermissionChecker permissionChecker; - + public IfEntityPermission(ModelMenuItem modelMenuItem, Element condElement) { super (modelMenuItem, condElement); this.permissionChecker = new EntityPermissionChecker(condElement); } - + public boolean eval(Map<String, Object> context) { - + boolean passed = permissionChecker.runPermissionCheck(context); return passed; } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java Fri Mar 27 16:59:28 2009 @@ -68,13 +68,13 @@ protected String disableIfEmpty; protected ModelMenu subMenu; protected Link link; - + protected List<ModelMenuItem> menuItemList = new LinkedList<ModelMenuItem>(); protected Map<String, ModelMenuItem> menuItemMap = new HashMap<String, ModelMenuItem>(); public static String DEFAULT_TARGET_TYPE = "intra-app"; - + protected EntityPermissionChecker permissionChecker; protected ModelMenuItem parentMenuItem; protected ModelMenuCondition condition; @@ -82,7 +82,7 @@ protected List<ModelMenuAction> actions; protected String align; protected String alignStyle; - + // ===== CONSTRUCTORS ===== /** Default Constructor */ public ModelMenuItem(ModelMenu modelMenu) { @@ -94,12 +94,12 @@ parentMenuItem = modelMenuItem; loadMenuItem(fieldElement, modelMenuItem.getModelMenu()); } - + public ModelMenuItem(Element fieldElement, ModelMenu modelMenu) { loadMenuItem(fieldElement, modelMenu); } - + public void loadMenuItem(Element fieldElement, ModelMenu modelMenu) { this.modelMenu = modelMenu; this.name = fieldElement.getAttribute("name"); @@ -159,7 +159,7 @@ if (linkElement != null) { link = new Link(linkElement, this); } - + // Element permissionElement = UtilXml.firstChildElement(fieldElement, "if-entity-permission"); // if (permissionElement != null) // permissionChecker = new EntityPermissionChecker(permissionElement); @@ -183,7 +183,7 @@ } } - + public ModelMenuItem addUpdateMenuItem(ModelMenuItem modelMenuItem) { // not a conditional item, see if a named item exists in Map @@ -247,7 +247,7 @@ } public void renderMenuItemString(Appendable writer, Map<String, Object> context, MenuStringRenderer menuStringRenderer) throws IOException { - + boolean passed = true; if (this.condition != null) { if (!this.condition.eval(context)) { @@ -323,7 +323,7 @@ return this.modelMenu.getDefaultDisabledTitleStyle(); } } - + public void setDisabledTitleStyle(String style) { this.disabledTitleStyle = style; } @@ -509,7 +509,7 @@ public Link getLink() { return this.link; } - + public boolean isSelected(Map<String, Object> context) { return this.name.equals(modelMenu.getSelectedMenuItemContextFieldName(context)); } @@ -548,7 +548,7 @@ if (imageElement != null) { this.image = new Image(imageElement); } - + this.linkType = linkElement.getAttribute("link-type"); List<? extends Element> parameterElementList = UtilXml.childElementList(linkElement, "parameter"); for (Element parameterElement: parameterElementList) { @@ -583,7 +583,7 @@ if (simpleEncoder != null) { txt = simpleEncoder.encode(txt); } - + return txt; } @@ -643,7 +643,7 @@ public String getLinkType() { return this.linkType; } - + public List<WidgetWorker.Parameter> getParameterList() { return this.parameterList; } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java Fri Mar 27 16:59:28 2009 @@ -83,11 +83,11 @@ return StringUtil.htmlEncoder.encode(super.getAsString()); } } - + // End Static, begin class section - + protected List<ModelScreenWidget> subWidgets = new ArrayList<ModelScreenWidget>(); - + public HtmlWidget(ModelScreen modelScreen, Element htmlElement) { super(modelScreen, htmlElement); List<? extends Element> childElementList = UtilXml.childElementList(htmlElement); @@ -116,20 +116,20 @@ buffer.append("</html-widget>"); return buffer.toString(); } - + public static void renderHtmlTemplate(Appendable writer, FlexibleStringExpander locationExdr, Map<String, Object> context) { String location = locationExdr.expandString(context); //Debug.logInfo("Rendering template at location [" + location + "] with context: \n" + context, module); - + if (UtilValidate.isEmpty(location)) { throw new IllegalArgumentException("Template location is empty"); } - + /* // ======================================================================= // Go through the context and find GenericValue objects and wrap them - + // NOTE PROBLEM: there are still problems with this as it gets some things // but does not get non-entity data including lots of strings // directly in the context or things prepared or derived right in @@ -137,18 +137,18 @@ // do something more aggressive to encode and wrap EVERYTHING in // the context, but I've been thinking that even this is too much // overhead and that would be crazy - + // NOTE ALTERNATIVE1: considering instead to use the FTL features to wrap // everything in an <#escape x as x?html>...</#escape>, but that could // cause problems with ${} expansions that have HTML in them, including: // included screens (using ${screens.render(...)}), content that should // have HTML in it (lots of general, product, category, etc content), etc - + // NOTE ALTERNATIVE2: kind of like the "#escape X as x?html" option, // implement an FTL *Model class and load it through a ObjectWrapper // FINAL NOTE: after testing all of these alternatives, this one seems // to behave the best, so going with that for now. - + // isolate the scope so these wrapper objects go away after rendering is done MapStack<String> contextMs; if (!(context instanceof MapStack)) { @@ -177,12 +177,12 @@ // and Lists in Maps and such; that's tricky because we have to go // through the entire Map and not just one entry, and we would // have to shallow copy the whole Map too - + } // this line goes at the end of the method, but moved up here to be part of the big comment about this contextMs.pop(); */ - + if (location.endsWith(".ftl")) { try { Map<String, ? extends Object> parameters = UtilGenerics.checkMap(context.get("parameters")); @@ -190,7 +190,7 @@ if (insertWidgetBoundaryComments) { writer.append(HtmlWidgetRenderer.formatBoundaryComment("Begin", "Template", location)); } - + //FreeMarkerWorker.renderTemplateAtLocation(location, context, writer); Template template = null; if (location.endsWith(".fo.ftl")) { // FOP can't render correctly escaped characters @@ -199,7 +199,7 @@ template = FreeMarkerWorker.getTemplate(location, specialTemplateCache, specialConfig); } FreeMarkerWorker.renderTemplate(template, context, writer); - + if (insertWidgetBoundaryComments) { writer.append(HtmlWidgetRenderer.formatBoundaryComment("End", "Template", location)); } @@ -224,7 +224,7 @@ throw new IllegalArgumentException("Rendering not yet supported for the template at location: " + location); } } - + // TODO: We can make this more fancy, but for now this is very functional public static void writeError(Appendable writer, String message) { try { @@ -235,7 +235,7 @@ public static class HtmlTemplate extends ModelScreenWidget { protected FlexibleStringExpander locationExdr; - + public HtmlTemplate(ModelScreen modelScreen, Element htmlTemplateElement) { super(modelScreen, htmlTemplateElement); this.locationExdr = FlexibleStringExpander.getInstance(htmlTemplateElement.getAttribute("location")); @@ -253,11 +253,11 @@ public static class HtmlTemplateDecorator extends ModelScreenWidget { protected FlexibleStringExpander locationExdr; protected Map<String, HtmlTemplateDecoratorSection> sectionMap = FastMap.newInstance(); - + public HtmlTemplateDecorator(ModelScreen modelScreen, Element htmlTemplateDecoratorElement) { super(modelScreen, htmlTemplateDecoratorElement); this.locationExdr = FlexibleStringExpander.getInstance(htmlTemplateDecoratorElement.getAttribute("location")); - + List<? extends Element> htmlTemplateDecoratorSectionElementList = UtilXml.childElementList(htmlTemplateDecoratorElement, "html-template-decorator-section"); for (Element htmlTemplateDecoratorSectionElement: htmlTemplateDecoratorSectionElementList) { String name = htmlTemplateDecoratorSectionElement.getAttribute("name"); @@ -279,7 +279,7 @@ MapStack<String> standAloneStack = contextMs.standAloneChildStack(); standAloneStack.put("screens", new ScreenRenderer(writer, standAloneStack, screenStringRenderer)); SectionsRenderer sections = new SectionsRenderer(this.sectionMap, standAloneStack, writer, screenStringRenderer); - + // put the sectionMap in the context, make sure it is in the sub-scope, ie after calling push on the MapStack contextMs.push(); context.put("sections", sections); @@ -296,7 +296,7 @@ public static class HtmlTemplateDecoratorSection extends ModelScreenWidget { protected String name; protected List<ModelScreenWidget> subWidgets; - + public HtmlTemplateDecoratorSection(ModelScreen modelScreen, Element htmlTemplateDecoratorSectionElement) { super(modelScreen, htmlTemplateDecoratorSectionElement); this.name = htmlTemplateDecoratorSectionElement.getAttribute("name"); |
Free forum by Nabble | Edit this page |