Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/IterateSectionWidget.java Fri Mar 27 16:59:28 2009 @@ -53,7 +53,7 @@ @SuppressWarnings("serial") public class IterateSectionWidget extends ModelScreenWidget { public static final String module = IterateSectionWidget.class.getName(); - + protected ModelScreenWidget childWidget; protected List<ModelScreenWidget.Section> sectionList; protected FlexibleMapAccessor<Object> listNameExdr; @@ -61,7 +61,7 @@ protected FlexibleStringExpander keyNameExdr; protected FlexibleStringExpander paginateTarget; protected boolean paginate = true; - + public static int DEFAULT_PAGE_SIZE = 5; protected int viewIndex = 0; protected int viewSize = DEFAULT_PAGE_SIZE; @@ -69,7 +69,7 @@ protected int highIndex = -1; protected int listSize = 0; protected int actualPageSize = 0; - + public IterateSectionWidget(ModelScreen modelScreen, Element iterateSectionElement) { super(modelScreen, iterateSectionElement); @@ -79,11 +79,11 @@ if (entryNameExdr.isEmpty()) entryNameExdr = FlexibleStringExpander.getInstance(iterateSectionElement.getAttribute("entry-name")); keyNameExdr = FlexibleStringExpander.getInstance(iterateSectionElement.getAttribute("key")); if (keyNameExdr.isEmpty()) keyNameExdr = FlexibleStringExpander.getInstance(iterateSectionElement.getAttribute("key-name")); - + if (this.paginateTarget == null || iterateSectionElement.hasAttribute("paginate-target")) { this.paginateTarget = FlexibleStringExpander.getInstance(iterateSectionElement.getAttribute("paginate-target")); } - + paginate = "true".equals(iterateSectionElement.getAttribute("paginate")); if (iterateSectionElement.hasAttribute("view-size")) { setViewSize(iterateSectionElement.getAttribute("view-size")); @@ -97,7 +97,7 @@ } public void renderWidgetString(Appendable writer, Map<String, Object> context, ScreenStringRenderer screenStringRenderer) throws GeneralException, IOException { - + boolean isEntrySet = false; // create a standAloneStack, basically a "save point" for this SectionsRenderer, and make a new "screens" object just for it so it is isolated and doesn't follow the stack down MapStack<String> contextMs = MapStack.create(context); @@ -143,7 +143,7 @@ contextMs.put(entryName, item); } contextMs.put("itemIndex", Integer.valueOf(itemIndex)); - + rowCount++; for (ModelScreenWidget.Section section: this.sectionList) { section.renderWidgetString(writer, contextMs, screenStringRenderer); @@ -162,7 +162,7 @@ lastPageNumber = (Integer)globalCtx.get("PAGINATOR_NUMBER"); globalCtx.put("PAGINATOR_NUMBER", Integer.valueOf(startPageNumber)); } - + renderNextPrev(writer, context); if (globalCtx != null) { @@ -173,7 +173,7 @@ throw new RuntimeException(e.getMessage()); } } - + } /* * @return @@ -181,15 +181,15 @@ public String getPaginateTarget(Map<String, Object> context) { return this.paginateTarget.expandString(context); } - + public boolean getPaginate() { return this.paginate; } - + public void setPaginate(boolean val) { paginate = val; } - + public void setViewIndex(int val) { viewIndex = val; } @@ -240,14 +240,14 @@ public int getHighIndex() { return highIndex; } - + public int getActualPageSize() { return actualPageSize; } - + public void getListLimits(Map<String, Object> context, List<?> items) { listSize = items.size(); - + if (paginate) { try { Map params = (Map)context.get("parameters"); @@ -273,27 +273,27 @@ highIndex = DEFAULT_PAGE_SIZE; } } - + public void renderNextPrev(Appendable writer, Map<String, Object> context) throws IOException { String targetService = this.getPaginateTarget(context); if (targetService == null) { targetService = "${targetService}"; } - + Map<String, Object> inputFields = UtilGenerics.checkMap(context.get("requestParameters")); Map<String, Object> queryStringMap = UtilGenerics.toMap(context.get("queryStringMap")); if (UtilValidate.isNotEmpty(queryStringMap)) { inputFields.putAll(queryStringMap); } - + String queryString = UtilHttp.urlEncodeArgs(inputFields); int paginatorNumber = this.getPaginatorNumber(context); queryString = UtilHttp.stripViewParamsFromQueryString(queryString, "" + paginatorNumber); - - - - + + + + if (UtilValidate.isEmpty(targetService)) { Debug.logWarning("TargetService is empty.", module); return; @@ -335,7 +335,7 @@ lowIndex = 0; } */ - + int lowIndex = viewIndex * viewSize; int highIndex = (viewIndex + 1) * viewSize; int actualPageSize = this.getActualPageSize(); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroFormRenderer.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroFormRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroFormRenderer.java Fri Mar 27 16:59:28 2009 @@ -93,7 +93,7 @@ protected HttpServletResponse response; protected boolean javaScriptEnabled = false; protected boolean renderPagination = true; - + public MacroFormRenderer(String macroLibraryPath, Appendable writer, HttpServletRequest request, HttpServletResponse response) throws TemplateException, IOException { macroLibrary = FreeMarkerWorker.getTemplate(macroLibraryPath); Map<String, Object> input = UtilMisc.toMap("key", null); @@ -104,7 +104,7 @@ this.rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_"); this.javaScriptEnabled = UtilHttp.isJavaScriptEnabled(request); } - + public boolean getRenderPagination() { return this.renderPagination; } @@ -112,7 +112,7 @@ public void setRenderPagination(boolean renderPagination) { this.renderPagination = renderPagination; } - + private void executeMacro(Appendable writer, String macro) throws IOException { try { @@ -181,11 +181,11 @@ // FIXME copy from HtmlFormRenderer.java 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); } @@ -211,15 +211,15 @@ String action = modelFormField.getAction(context); String id = modelFormField.getIdName(); String clientAutocomplete = "false"; - + List<ModelForm.UpdateArea> updateAreas = modelFormField.getOnChangeUpdateAreas(); boolean ajaxEnabled = updateAreas != null && this.javaScriptEnabled; if (!textField.getClientAutocompleteField() || ajaxEnabled) { clientAutocomplete = "true"; } - + String ajaxUrl = createAjaxParamsFromUpdateAreas(updateAreas, null, context); - + StringWriter sr = new StringWriter(); sr.append("<@renderTextField "); sr.append("name=\""); @@ -248,7 +248,7 @@ sr.append(Boolean.toString(ajaxEnabled)); sr.append(" />"); executeMacro(writer, sr.toString()); - + ModelFormField.SubHyperlink subHyperlink = textField.getSubHyperlink(); if (subHyperlink != null && subHyperlink.shouldUse(context)) { makeHyperlinkString(writer,subHyperlink,context); @@ -340,7 +340,7 @@ // whether the date field is short form, yyyy-mm-dd boolean shortDateInput = ("date".equals(dateTimeField.getType()) || "time-dropdown".equals(dateTimeField.getInputMethod()) ? true : false); - + if ("time-dropdown".equals(dateTimeField.getInputMethod())) { name = UtilHttp.makeCompositeParam(paramName, "date"); } else { @@ -366,7 +366,7 @@ localizedInputTitle = (String) uiLabelMap.get("CommonFormatDateTime"); } } - + String value = modelFormField.getEntry(context, dateTimeField.getDefaultValue(context)); if (UtilValidate.isNotEmpty(value)) { if (value.length() > maxlength) { @@ -389,7 +389,7 @@ if (uiLabelMap != null) { localizedIconTitle = (String) uiLabelMap.get("CommonViewCalendar"); } - + if (!"time".equals(dateTimeField.getType())) { String tempParamName; if ("time-dropdown".equals(dateTimeField.getInputMethod())) { @@ -419,7 +419,7 @@ Debug.logWarning("Form widget field [" + paramName + "] with input-method=\"time-dropdown\" was not able to understand the default time [" + defaultDateTimeString + "]. The parsing error was: " + e.getMessage(), module); } - + timeHourName = UtilHttp.makeCompositeParam(paramName, "hour"); if( cal != null){ int hour = cal.get(Calendar.HOUR_OF_DAY); @@ -439,7 +439,7 @@ pmSelected = ((cal != null && cal.get(Calendar.AM_PM) == Calendar.PM) ? "selected" : ""); ampmName = UtilHttp.makeCompositeParam(paramName, "ampm"); } - + } StringWriter sr = new StringWriter(); sr.append("<@renderDateTimeField "); @@ -574,7 +574,7 @@ // Adapted from work by Yucca Korpela // http://www.cs.tut.fi/~jkorpela/forms/combo.html if (otherFieldSize > 0) { - + fieldName = modelFormField.getParameterName(context); Map dataMap = modelFormField.getMap(context); if (dataMap == null) { @@ -631,7 +631,7 @@ makeHyperlinkString(writer,subHyperlink,context); } this.appendTooltip(writer, context, modelFormField); - + } public void renderCheckField(Appendable writer, Map<String, Object> context, CheckField checkField) throws IOException { @@ -651,7 +651,7 @@ alert = "true"; } } - + List allOptionValues = checkField.getAllOptionValues(context, modelForm.getDelegator(context)); Iterator<ModelFormField.OptionValue> optionValueIter = allOptionValues.iterator(); items.append("["); @@ -665,7 +665,7 @@ items.append("'}"); } items.append("]"); - + StringWriter sr = new StringWriter(); sr.append("<@renderCheckField "); sr.append("items="); @@ -686,7 +686,7 @@ sr.append(action); sr.append("\" />"); executeMacro(writer, sr.toString()); - + this.appendTooltip(writer, context, modelFormField); } @@ -708,7 +708,7 @@ alert = "true"; } } - + String noCurrentSelectedKey = radioField.getNoCurrentSelectedKey(context); Iterator<ModelFormField.OptionValue> optionValueIter = allOptionValues.iterator(); items.append("["); @@ -722,7 +722,7 @@ items.append("'}"); } items.append("]"); - + StringWriter sr = new StringWriter(); sr.append("<@renderRadioField "); sr.append("items="); @@ -743,7 +743,7 @@ sr.append(action); sr.append("\" />"); executeMacro(writer, sr.toString()); - + this.appendTooltip(writer, context, modelFormField); } @@ -802,7 +802,7 @@ } } String title = modelFormField.getTitle(context); - + StringWriter sr = new StringWriter(); sr.append("<@renderResetField "); sr.append(" className=\""); @@ -815,7 +815,7 @@ sr.append(title); sr.append("\" />"); executeMacro(writer, sr.toString()); - + this.appendTooltip(writer, context, modelFormField); } @@ -854,7 +854,7 @@ } else { renderHyperlinkTitle(sb, context, modelFormField, titleText); } - + } StringWriter sr = new StringWriter(); sr.append("<@renderFieldTitle "); @@ -952,7 +952,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; @@ -960,7 +960,7 @@ writer.append(postMultiFormWriter.toString()); appendWhitespace(writer); } - + renderEndingBoundaryComment(writer, "Form Widget - Form Element (Multi)", modelForm); } @@ -987,7 +987,7 @@ sr.append(modelForm.getDefaultTableStyle()); sr.append("\" />"); executeMacro(writer, sr.toString()); - + } public void renderFormatListWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { @@ -1049,7 +1049,7 @@ sr.append("<@renderFormatHeaderRowFormCellClose />"); executeMacro(writer, sr.toString()); } - + public void renderFormatHeaderRowFormCellTitleSeparator(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, boolean isLast) throws IOException { String titleStyle = modelFormField.getTitleStyle(); @@ -1187,7 +1187,7 @@ sr.append(areaStyle); sr.append("\" />"); executeMacro(writer, sr.toString()); - + } public void renderFormatFieldRowWidgetCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions, int positionSpan, Integer nextPositionInRow) throws IOException { @@ -1244,12 +1244,12 @@ public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) { // TODO } - + public void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner) { // TODO } - - + + /** * Renders the beginning boundary comment string. * @param writer The writer to write to @@ -1318,7 +1318,7 @@ writer.append(titleText); } } - + public void renderSortField(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText) throws IOException { boolean ajaxEnabled = false; ModelForm modelForm = modelFormField.getModelForm(); @@ -1340,7 +1340,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)) { @@ -1387,7 +1387,7 @@ } else { linkUrl = rh.makeLink(this.request, this.response, urlPath + prepLinkText); } - + StringWriter sr = new StringWriter(); sr.append("<@renderSortField "); sr.append(" style=\""); @@ -1400,7 +1400,7 @@ sr.append(Boolean.toString(ajaxEnabled)); sr.append(" />"); executeMacro(writer, sr.toString()); - + } /** Create an ajaxXxxx JavaScript CSV string from a list of UpdateArea objects. See * <code>selectall.js</code>. Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java Fri Mar 27 16:59:28 2009 @@ -74,7 +74,7 @@ private Template macroLibrary; private Environment environment; private int elementId = 999; - + public MacroScreenRenderer(String macroLibraryPath, Appendable writer) throws TemplateException, IOException { macroLibrary = FreeMarkerWorker.getTemplate(macroLibraryPath); Map<String, Object> input = UtilMisc.toMap("key", null); @@ -175,7 +175,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); @@ -200,7 +200,7 @@ parameters.append("'}"); } parameters.append("]"); - + } String id = link.getId(context); String style = link.getStyle(context); @@ -314,9 +314,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); - + StringWriter sr = new StringWriter(); sr.append("<@renderContentBegin "); sr.append("editRequest=\""); @@ -345,7 +345,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) { @@ -379,7 +379,7 @@ if (content.xmlEscape()) { renderedContent = UtilFormatOut.encodeXmlValue(renderedContent); } - + writer.append(renderedContent); } @@ -405,7 +405,7 @@ if (editRequest != null && editRequest.toUpperCase().indexOf("IMAGE") > 0) { editMode += " Image"; } - + if (UtilValidate.isNotEmpty(editRequest) && "true".equals(enableEditValue)) { HttpServletResponse response = (HttpServletResponse) context.get("response"); HttpServletRequest request = (HttpServletRequest) context.get("request"); @@ -417,7 +417,7 @@ RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_"); urlString = rh.makeLink(request, response, editRequest, false, false, false); } - + StringWriter sr = new StringWriter(); sr.append("<@renderContentEnd "); sr.append("urlString=\""); @@ -468,7 +468,7 @@ String editContainerStyle = content.getEditContainerStyle(context); String enableEditName = content.getEnableEditName(context); String enableEditValue = (String)context.get(enableEditName); - + StringWriter sr = new StringWriter(); sr.append("<@renderSubContentBegin "); sr.append(" editContainerStyle=\""); @@ -515,7 +515,7 @@ if (content.xmlEscape()) { renderedContent = UtilFormatOut.encodeXmlValue(renderedContent); } - + writer.append(renderedContent); } @@ -557,7 +557,7 @@ urlString = rh.makeLink(request, response, editRequest, false, false, false); } } - + StringWriter sr = new StringWriter(); sr.append("<@renderSubContentEnd "); sr.append("urlString=\""); @@ -574,7 +574,7 @@ executeMacro(writer, sr.toString()); } - + public void renderScreenletBegin(Appendable writer, Map<String, Object> context, boolean collapsed, ModelScreenWidget.Screenlet screenlet) throws IOException { HttpServletRequest request = (HttpServletRequest) context.get("request"); HttpServletResponse response = (HttpServletResponse) context.get("response"); @@ -583,7 +583,7 @@ if (tabMenu != null) { tabMenu.renderWidgetString(writer, context, this); } - + String title = screenlet.getTitle(context); boolean collapsible = screenlet.collapsible(); ModelScreenWidget.Menu navMenu = screenlet.getNavigationMenu(); @@ -626,7 +626,7 @@ menuString = sb.toString(); } } - + StringWriter sr = new StringWriter(); sr.append("<@renderScreenletBegin "); sr.append("id=\""); @@ -758,7 +758,7 @@ String linkText; - + // The current screenlet title bar navigation syling requires rendering // these links in reverse order // Last button @@ -792,7 +792,7 @@ linkText = prepLinkText + 0 + anchor; firstLinkUrl = rh.makeLink(request, response, linkText); } - + StringWriter sr = new StringWriter(); sr.append("<@renderScreenletPaginateMenu "); sr.append("lowIndex=\""); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java Fri Mar 27 16:59:28 2009 @@ -49,7 +49,7 @@ import freemarker.template.utility.StandardCompress; public class MacroScreenViewHandler extends AbstractViewHandler { - + public static final String module = MacroScreenViewHandler.class.getName(); protected ServletContext servletContext = null; @@ -86,7 +86,7 @@ // to speed up output. writer = new StandardCompress().getWriter(writer, null); } - + ScreenStringRenderer screenStringRenderer = new MacroScreenRenderer(UtilProperties.getPropertyValue("widget", getName() + ".screenrenderer"), writer); FormStringRenderer formStringRenderer = new MacroFormRenderer(UtilProperties.getPropertyValue("widget", getName() + ".formrenderer"), writer, request, response); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java Fri Mar 27 16:59:28 2009 @@ -52,7 +52,7 @@ protected FlexibleStringExpander transactionTimeoutExdr; protected Map<String, ModelScreen> modelScreenMap; protected boolean useCache; - + protected ModelScreenWidget.Section section; // ===== CONSTRUCTORS ===== @@ -75,7 +75,7 @@ this.section = new ModelScreenWidget.Section(this, sectionElement); this.section.isMainSection = true; } - + public String getSourceLocation() { return sourceLocation; } @@ -263,7 +263,7 @@ } } } - + public Set<String> getAllRequestsLocationAndUri() throws GeneralException { Set<String> allRequestNamesIncluded = FastSet.newInstance(); findRequestNamesLinkedtoInWidget(this.section, allRequestNamesIncluded); @@ -275,7 +275,7 @@ String target = link.getTarget(null); String urlMode = link.getUrlMode(); // Debug.logInfo("In findRequestNamesLinkedtoInWidget found link [" + link.rawString() + "] with target [" + target + "]", module); - + Set<String> controllerLocAndRequestSet = ConfigXMLReader.findControllerRequestUniqueForTargetType(target, urlMode); if (controllerLocAndRequestSet == null) return; allRequestNamesIncluded.addAll(controllerLocAndRequestSet); @@ -322,7 +322,7 @@ } } } - + /** * Renders this screen to a String, i.e. in a text format, as defined with the @@ -365,7 +365,7 @@ } } } - + if (transactionTimeout < 0 && !transactionTimeoutExdr.isEmpty()) { // no TRANSACTION_TIMEOUT parameter, check screen attribute String transactionTimeoutStr = transactionTimeoutExdr.expandString(context); @@ -377,7 +377,7 @@ } } } - + try { // If transaction timeout is not present (i.e. is equal to -1), the default transaction timeout is used // If transaction timeout is present, use it to start the transaction @@ -413,9 +413,9 @@ } catch (GenericEntityException e2) { Debug.logError(e2, "Could not rollback transaction: " + e2.toString(), module); } - + // throw nested exception, don't need to log details here: Debug.logError(e, errMsg, module); - + // after rolling back, rethrow the exception throw new ScreenRenderException(errMsg, e); } finally { Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java Fri Mar 27 16:59:28 2009 @@ -74,12 +74,12 @@ this.modelScreen = modelScreen; if (Debug.verboseOn()) Debug.logVerbose("Reading Screen action with name: " + actionElement.getNodeName(), module); } - + public abstract void runAction(Map<String, Object> context) throws GeneralException; - + public static List<ModelScreenAction> readSubActions(ModelScreen modelScreen, Element parentElement) { List<ModelScreenAction> actions = FastList.newInstance(); - + List<? extends Element> actionElementList = UtilXml.childElementList(parentElement); for (Element actionElement: actionElementList) { if ("set".equals(actionElement.getNodeName())) { @@ -106,19 +106,19 @@ throw new IllegalArgumentException("Action element not supported with name: " + actionElement.getNodeName()); } } - + return actions; } - + public static void runSubActions(List<ModelScreenAction> actions, Map<String, Object> context) throws GeneralException { if (actions == null) return; - + for (ModelScreenAction action: actions) { if (Debug.verboseOn()) Debug.logVerbose("Running screen action " + action.getClass().getName(), module); action.runAction(context); } } - + public static class SetField extends ModelScreenAction { protected FlexibleMapAccessor<Object> field; protected FlexibleMapAccessor<Object> fromField; @@ -128,7 +128,7 @@ protected String type; protected String toScope; protected String fromScope; - + public SetField(ModelScreen modelScreen, Element setElement) { super (modelScreen, setElement); this.field = FlexibleMapAccessor.getInstance(setElement.getAttribute("field")); @@ -143,12 +143,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()) { @@ -179,7 +179,7 @@ if (ObjectType.isEmpty(newValue) && !this.defaultExdr.isEmpty()) { 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); @@ -189,7 +189,7 @@ throw new IllegalArgumentException(errMsg); } } - + if (this.toScope != null && this.toScope.equals("user")) { String originalName = this.field.getOriginalName(); List<String> currentWidgetTrail = UtilGenerics.toList(context.get("_WIDGETTRAIL_")); @@ -225,7 +225,7 @@ this.field.put(context, newValue); } } - + if (global) { Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext")); if (globalCtx != null) { @@ -234,14 +234,14 @@ this.field.put(context, 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) { this.field.put(page, newValue); } } - + public Object getInMemoryPersistedFromField(Object storeAgent, Map<String, Object> context) { Object newValue = null; String originalName = this.fromField.getOriginalName(); @@ -250,7 +250,7 @@ if (currentWidgetTrail != null) { trailList.addAll(currentWidgetTrail); } - + for (int i=trailList.size(); i >= 0; i--) { List<String> subTrail = trailList.subList(0,i); String newKey = null; @@ -258,7 +258,7 @@ newKey = StringUtil.join(subTrail, "|") + "|" + originalName; else newKey = originalName; - + if (storeAgent instanceof ServletContext) { newValue = ((ServletContext)storeAgent).getAttribute(newKey); } else if (storeAgent instanceof HttpSession) { @@ -271,19 +271,19 @@ return newValue; } } - + public static class PropertyMap extends ModelScreenAction { protected FlexibleStringExpander resourceExdr; protected FlexibleMapAccessor<ResourceBundleMapWrapper> mapNameAcsr; protected FlexibleStringExpander globalExdr; - + public PropertyMap(ModelScreen modelScreen, Element setElement) { super (modelScreen, 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 @@ -291,7 +291,7 @@ Locale locale = (Locale) context.get("locale"); String resource = this.resourceExdr.expandString(context, locale); - + ResourceBundleMapWrapper existingPropMap = this.mapNameAcsr.get(context); if (existingPropMap == null) { this.mapNameAcsr.put(context, UtilProperties.getResourceBundleMap(resource, locale, context)); @@ -325,9 +325,9 @@ } } } - + public static class PropertyToField extends ModelScreenAction { - + protected FlexibleStringExpander resourceExdr; protected FlexibleStringExpander propertyExdr; protected FlexibleMapAccessor<Object> fieldAcsr; @@ -346,7 +346,7 @@ this.argListAcsr = FlexibleMapAccessor.getInstance(setElement.getAttribute("arg-list-name")); this.globalExdr = FlexibleStringExpander.getInstance(setElement.getAttribute("global")); } - + public void runAction(Map<String, Object> context) { //String globalStr = this.globalExdr.expandString(context); // default to false @@ -355,7 +355,7 @@ 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); @@ -365,7 +365,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. @@ -381,15 +381,15 @@ fieldAcsr.put(context, value); } } - + public static class Script extends ModelScreenAction { protected String location; - + public Script(ModelScreen modelScreen, Element scriptElement) { super (modelScreen, scriptElement); this.location = scriptElement.getAttribute("location"); } - + public void runAction(Map<String, Object> context) throws GeneralException { if (location.endsWith(".bsh")) { try { @@ -427,7 +427,7 @@ protected FlexibleMapAccessor<Map<String, Object>> resultMapNameAcsr; protected FlexibleStringExpander autoFieldMapExdr; protected Map<FlexibleMapAccessor<Object>, Object> fieldMap; - + public Service(ModelScreen modelScreen, Element serviceElement) { super (modelScreen, serviceElement); this.serviceNameExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("service-name")); @@ -436,15 +436,15 @@ this.autoFieldMapExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("auto-field-map")); this.fieldMap = EntityFinderUtil.makeFieldMap(serviceElement); } - + 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); - + try { Map<String, Object> serviceContext = null; if ("true".equals(autoFieldMapString)) { @@ -467,13 +467,13 @@ if (serviceContext == null) { serviceContext = FastMap.newInstance(); } - + if (this.fieldMap != null) { EntityFinderUtil.expandFieldMapToContext(this.fieldMap, context, serviceContext); } - + Map<String, Object> result = this.modelScreen.getDispatcher(context).runSync(serviceNameExpanded, serviceContext); - + if (!this.resultMapNameAcsr.isEmpty()) { this.resultMapNameAcsr.put(context, result); String queryString = (String)result.get("queryString"); @@ -484,7 +484,7 @@ String queryStringEncoded = queryString.replaceAll("&", "%26"); context.put("queryStringEncoded", queryStringEncoded); } catch (PatternSyntaxException e) { - + } } } else { @@ -500,12 +500,12 @@ public static class EntityOne extends ModelScreenAction { protected PrimaryKeyFinder finder; - + public EntityOne(ModelScreen modelScreen, Element entityOneElement) { super (modelScreen, entityOneElement); finder = new PrimaryKeyFinder(entityOneElement); } - + public void runAction(Map<String, Object> context) { try { finder.runFind(context, this.modelScreen.getDelegator(context)); @@ -519,12 +519,12 @@ public static class EntityAnd extends ModelScreenAction { protected ByAndFinder finder; - + public EntityAnd(ModelScreen modelScreen, Element entityAndElement) { super (modelScreen, entityAndElement); finder = new ByAndFinder(entityAndElement); } - + public void runAction(Map<String, Object> context) { try { finder.runFind(context, this.modelScreen.getDelegator(context)); @@ -538,12 +538,12 @@ public static class EntityCondition extends ModelScreenAction { ByConditionFinder finder; - + public EntityCondition(ModelScreen modelScreen, Element entityConditionElement) { super (modelScreen, entityConditionElement); finder = new ByConditionFinder(entityConditionElement); } - + public void runAction(Map<String, Object> context) { try { finder.runFind(context, this.modelScreen.getDelegator(context)); @@ -560,7 +560,7 @@ protected FlexibleMapAccessor<Object> toValueNameAcsr; protected String relationName; protected boolean useCache; - + public GetRelatedOne(ModelScreen modelScreen, Element getRelatedOneElement) { super (modelScreen, getRelatedOneElement); this.valueNameAcsr = FlexibleMapAccessor.getInstance(getRelatedOneElement.getAttribute("value-field")); @@ -595,7 +595,7 @@ throw new IllegalArgumentException(errMsg); } } - + } public static class GetRelated extends ModelScreenAction { @@ -605,7 +605,7 @@ protected FlexibleMapAccessor<List<String>> orderByListAcsr; protected String relationName; protected boolean useCache; - + public GetRelated(ModelScreen modelScreen, Element getRelatedElement) { super (modelScreen, getRelatedElement); this.valueNameAcsr = FlexibleMapAccessor.getInstance(getRelatedElement.getAttribute("value-field")); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java Fri Mar 27 16:59:28 2009 @@ -74,17 +74,17 @@ } return rootCondition.eval(context); } - + public static abstract class ScreenCondition implements Serializable { protected ModelScreen modelScreen; public ScreenCondition(ModelScreen modelScreen, Element conditionElement) { this.modelScreen = modelScreen; } - + public abstract boolean eval(Map<String, Object> context); } - + public static List<ScreenCondition> readSubConditions(ModelScreen modelScreen, Element conditionElement) { List<ScreenCondition> condList = FastList.newInstance(); List<? extends Element> subElementList = UtilXml.childElementList(conditionElement); @@ -93,7 +93,7 @@ } return condList; } - + public static ScreenCondition readCondition(ModelScreen modelScreen, Element conditionElement) { if (conditionElement == null) { return null; @@ -126,15 +126,15 @@ throw new IllegalArgumentException("Condition element not supported with name: " + conditionElement.getNodeName()); } } - + public static class And extends ScreenCondition { protected List<ScreenCondition> subConditions; - + public And(ModelScreen modelScreen, Element condElement) { super (modelScreen, condElement); this.subConditions = readSubConditions(modelScreen, condElement); } - + public boolean eval(Map<String, Object> context) { // return false for the first one in the list that is false, basic and algo for (ScreenCondition subCondition: this.subConditions) { @@ -145,15 +145,15 @@ return true; } } - + public static class Xor extends ScreenCondition { protected List<ScreenCondition> subConditions; - + public Xor(ModelScreen modelScreen, Element condElement) { super (modelScreen, condElement); this.subConditions = readSubConditions(modelScreen, 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; @@ -170,15 +170,15 @@ return foundOneTrue; } } - + public static class Or extends ScreenCondition { protected List<ScreenCondition> subConditions; - + public Or(ModelScreen modelScreen, Element condElement) { super (modelScreen, condElement); this.subConditions = readSubConditions(modelScreen, condElement); } - + public boolean eval(Map<String, Object> context) { // return true for the first one in the list that is true, basic or algo for (ScreenCondition subCondition: this.subConditions) { @@ -189,16 +189,16 @@ return false; } } - + public static class Not extends ScreenCondition { protected ScreenCondition subCondition; - + public Not(ModelScreen modelScreen, Element condElement) { super (modelScreen, condElement); Element firstChildElement = UtilXml.firstChildElement(condElement); this.subCondition = readCondition(modelScreen, firstChildElement); } - + public boolean eval(Map<String, Object> context) { return !this.subCondition.eval(context); } @@ -229,7 +229,7 @@ if (UtilValidate.isEmpty(resource)) { resource = serviceName; } - + if (UtilValidate.isEmpty(serviceName)) { Debug.logWarning("No permission service-name specified!", module); return false; @@ -290,20 +290,20 @@ public static class IfHasPermission extends ScreenCondition { protected FlexibleStringExpander permissionExdr; protected FlexibleStringExpander actionExdr; - + public IfHasPermission(ModelScreen modelScreen, Element condElement) { super (modelScreen, 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 @@ -325,7 +325,7 @@ protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleStringExpander methodExdr; protected FlexibleStringExpander classExdr; - + public IfValidateMethod(ModelScreen modelScreen, Element condElement) { super (modelScreen, condElement); this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field")); @@ -333,11 +333,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) { @@ -380,7 +380,7 @@ return resultBool.booleanValue(); } } - + public static class IfCompare extends ScreenCondition { protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleStringExpander valueExdr; @@ -388,25 +388,25 @@ protected String operator; protected String type; protected FlexibleStringExpander formatExdr; - + public IfCompare(ModelScreen modelScreen, Element condElement) { super (modelScreen, 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 = ""; @@ -425,11 +425,11 @@ throw new IllegalArgumentException(fullString.toString()); } - + return resultBool.booleanValue(); } } - + public static class IfCompareField extends ScreenCondition { protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleMapAccessor<Object> toFieldAcsr; @@ -437,26 +437,26 @@ protected String operator; protected String type; protected FlexibleStringExpander formatExdr; - + public IfCompareField(ModelScreen modelScreen, Element condElement) { super (modelScreen, 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 = ""; @@ -475,25 +475,25 @@ throw new IllegalArgumentException(fullString.toString()); } - + return resultBool.booleanValue(); } } - + public static class IfRegexp extends ScreenCondition { static PatternMatcher matcher = new Perl5Matcher(); static PatternCompiler compiler = new Perl5Compiler(); protected FlexibleMapAccessor<Object> fieldAcsr; protected FlexibleStringExpander exprExdr; - + public IfRegexp(ModelScreen modelScreen, Element condElement) { super (modelScreen, 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); @@ -514,20 +514,20 @@ } // always use an empty string by default if (fieldString == null) fieldString = ""; - + return matcher.matches(fieldString, pattern); } } - + public static class IfEmpty extends ScreenCondition { protected FlexibleMapAccessor<Object> fieldAcsr; - + public IfEmpty(ModelScreen modelScreen, Element condElement) { super (modelScreen, 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); @@ -535,12 +535,12 @@ } public static class IfEntityPermission extends ScreenCondition { protected EntityPermissionChecker permissionChecker; - + public IfEntityPermission(ModelScreen modelScreen, Element condElement) { super (modelScreen, condElement); this.permissionChecker = new EntityPermissionChecker(condElement); } - + public boolean eval(Map<String, Object> context) { return permissionChecker.runPermissionCheck(context); } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java Fri Mar 27 16:59:28 2009 @@ -71,17 +71,17 @@ public static final String module = ModelScreenWidget.class.getName(); protected ModelScreen modelScreen; - + public ModelScreenWidget(ModelScreen modelScreen, Element widgetElement) { super(widgetElement); this.modelScreen = modelScreen; if (Debug.verboseOn()) Debug.logVerbose("Reading Screen sub-widget with name: " + widgetElement.getNodeName(), module); } - + public abstract void renderWidgetString(Appendable writer, Map<String, Object> context, ScreenStringRenderer screenStringRenderer) throws GeneralException, IOException; public abstract String rawString(); - + public static List<ModelScreenWidget> readSubWidgets(ModelScreen modelScreen, List<? extends Element> subElementList) { List<ModelScreenWidget> subWidgets = FastList.newInstance(); for (Element subElement: subElementList) { @@ -123,10 +123,10 @@ throw new IllegalArgumentException("Found invalid screen widget element with name: " + subElement.getNodeName()); } } - + return subWidgets; } - + public static void renderSubWidgetsString(List<ModelScreenWidget> subWidgets, Appendable writer, Map<String, Object> context, ScreenStringRenderer screenStringRenderer) throws GeneralException, IOException { if (subWidgets == null) { return; @@ -142,16 +142,16 @@ public boolean boundaryCommentsEnabled() { return modelScreen.boundaryCommentsEnabled(); } - + public ModelScreen getModelScreen() { return this.modelScreen; } - + public static class SectionsRenderer extends HashMap<String, Object> { protected ScreenStringRenderer screenStringRenderer; protected Map<String, Object> context; protected Appendable writer; - + public SectionsRenderer(Map<String, ? extends Object> sectionMap, Map<String, Object> context, Appendable writer, ScreenStringRenderer screenStringRenderer) { this.putAll(sectionMap); this.context = context; @@ -176,7 +176,7 @@ protected List<ModelScreenWidget> subWidgets; protected List<ModelScreenWidget> failWidgets; public boolean isMainSection = false; - + public Section(ModelScreen modelScreen, Element sectionElement) { super(modelScreen, sectionElement); @@ -191,7 +191,7 @@ if (actionsElement != null) { this.actions = ModelScreenAction.readSubActions(modelScreen, actionsElement); } - + // read sub-widgets Element widgetsElement = UtilXml.firstChildElement(sectionElement, "widgets"); List<? extends Element> subElementList = UtilXml.childElementList(widgetsElement); @@ -213,16 +213,16 @@ condTrue = false; } } - + // if condition does not exist or evals to true run actions and render widgets, otherwise render fail-widgets if (condTrue) { // run the actions only if true ModelScreenAction.runSubActions(this.actions, context); - + try { // section by definition do not themselves do anything, so this method will generally do nothing, but we'll call it anyway screenStringRenderer.renderSectionBegin(writer, context, this); - + // render sub-widgets renderSubWidgetsString(this.subWidgets, writer, context, screenStringRenderer); @@ -236,7 +236,7 @@ try { // section by definition do not themselves do anything, so this method will generally do nothing, but we'll call it anyway screenStringRenderer.renderSectionBegin(writer, context, this); - + // render sub-widgets renderSubWidgetsString(this.failWidgets, writer, context, screenStringRenderer); @@ -247,9 +247,9 @@ throw new RuntimeException(errMsg); } } - + } - + public String getBoundaryCommentName() { if (isMainSection) { return modelScreen.getSourceLocation() + "#" + modelScreen.getName(); @@ -257,7 +257,7 @@ return name; } } - + public String rawString() { return "<section" + (UtilValidate.isNotEmpty(this.name)?" name=\"" + this.name + "\"":"") + ">"; } @@ -269,7 +269,7 @@ protected FlexibleStringExpander autoUpdateTargetExdr; protected String autoUpdateInterval = "2"; protected List<ModelScreenWidget> subWidgets; - + public Container(ModelScreen modelScreen, Element containerElement) { super(modelScreen, containerElement); this.idExdr = FlexibleStringExpander.getInstance(containerElement.getAttribute("id")); @@ -278,7 +278,7 @@ if (containerElement.hasAttribute("auto-update-interval")) { this.autoUpdateInterval = containerElement.getAttribute("auto-update-interval"); } - + // read sub-widgets List<? extends Element> subElementList = UtilXml.childElementList(containerElement); this.subWidgets = ModelScreenWidget.readSubWidgets(this.modelScreen, subElementList); @@ -287,7 +287,7 @@ public void renderWidgetString(Appendable writer, Map<String, Object> context, ScreenStringRenderer screenStringRenderer) throws GeneralException, IOException { try { screenStringRenderer.renderContainerBegin(writer, context, this); - + // render sub-widgets renderSubWidgetsString(this.subWidgets, writer, context, screenStringRenderer); @@ -298,11 +298,11 @@ throw new RuntimeException(errMsg); } } - + public String getId(Map<String, Object> context) { return this.idExdr.expandString(context); } - + public String getStyle(Map<String, Object> context) { return this.styleExdr.expandString(context); } @@ -330,7 +330,7 @@ protected boolean initiallyCollapsed = false; protected boolean padded = true; protected List<ModelScreenWidget> subWidgets; - + public Screenlet(ModelScreen modelScreen, Element screenletElement) { super(modelScreen, screenletElement); this.idExdr = FlexibleStringExpander.getInstance(screenletElement.getAttribute("id")); @@ -404,7 +404,7 @@ throw new RuntimeException(errMsg + e); } } - + public boolean collapsible() { return this.collapsible; } @@ -428,7 +428,7 @@ public String getId(Map<String, Object> context) { return this.idExdr.expandString(context); } - + public String getTitle(Map<String, Object> context) { return this.titleExdr.expandString(context); } @@ -453,7 +453,7 @@ public static class HorizontalSeparator extends ModelScreenWidget { protected FlexibleStringExpander idExdr; protected FlexibleStringExpander styleExdr; - + public HorizontalSeparator(ModelScreen modelScreen, Element separatorElement) { super(modelScreen, separatorElement); this.idExdr = FlexibleStringExpander.getInstance(separatorElement.getAttribute("id")); @@ -463,11 +463,11 @@ public void renderWidgetString(Appendable writer, Map<String, Object> context, ScreenStringRenderer screenStringRenderer) throws GeneralException, IOException { screenStringRenderer.renderHorizontalSeparator(writer, context, this); } - + public String getId(Map<String, Object> context) { return this.idExdr.expandString(context); } - + public String getStyle(Map<String, Object> context) { return this.styleExdr.expandString(context); } @@ -481,7 +481,7 @@ protected FlexibleStringExpander nameExdr; protected FlexibleStringExpander locationExdr; protected FlexibleStringExpander shareScopeExdr; - + public IncludeScreen(ModelScreen modelScreen, Element includeScreenElement) { super(modelScreen, includeScreenElement); this.nameExdr = FlexibleStringExpander.getInstance(includeScreenElement.getAttribute("name")); @@ -496,36 +496,36 @@ if (!(context instanceof MapStack)) { context = MapStack.create(context); } - + ((MapStack) context).push(); - + // build the widgetpath List<String> widgetTrail = UtilGenerics.toList(context.get("_WIDGETTRAIL_")); if (widgetTrail == null) { widgetTrail = FastList.newInstance(); } - + String thisName = nameExdr.expandString(context); widgetTrail.add(thisName); context.put("_WIDGETTRAIL_", widgetTrail); } - + // dont need the renderer here, will just pass this on down to another screen call; screenStringRenderer.renderContainerBegin(writer, context, this); String name = this.getName(context); String location = this.getLocation(context); - + if (UtilValidate.isEmpty(name)) { if (Debug.verboseOn()) Debug.logVerbose("In the include-screen tag the screen name was empty, ignoring include; in screen [" + this.modelScreen.getName() + "]", module); return; } - + // check to see if the name is a composite name separated by a #, if so split it up and get it by the full loc#name if (ScreenFactory.isCombinedName(name)) { String combinedName = name; location = ScreenFactory.getResourceNameFromCombined(combinedName); name = ScreenFactory.getScreenNameFromCombined(combinedName); } - + ModelScreen modelScreen = null; if (UtilValidate.isNotEmpty(location)) { try { @@ -555,15 +555,15 @@ ((MapStack) context).pop(); } } - + public String getName(Map<String, Object> context) { return this.nameExdr.expandString(context); } - + public String getLocation(Map<String, Object> context) { return this.locationExdr.expandString(context); } - + public boolean shareScope(Map<String, Object> context) { String shareScopeString = this.shareScopeExdr.expandString(context); // defaults to false, so anything but true is false @@ -579,12 +579,12 @@ protected FlexibleStringExpander nameExdr; protected FlexibleStringExpander locationExdr; protected Map<String, DecoratorSection> sectionMap = new HashMap<String, DecoratorSection>(); - + public DecoratorScreen(ModelScreen modelScreen, Element decoratorScreenElement) { super(modelScreen, decoratorScreenElement); this.nameExdr = FlexibleStringExpander.getInstance(decoratorScreenElement.getAttribute("name")); this.locationExdr = FlexibleStringExpander.getInstance(decoratorScreenElement.getAttribute("location")); - + List<? extends Element> decoratorSectionElementList = UtilXml.childElementList(decoratorScreenElement, "decorator-section"); for (Element decoratorSectionElement: decoratorSectionElementList) { String name = decoratorSectionElement.getAttribute("name"); @@ -598,28 +598,28 @@ if (!(context instanceof MapStack)) { context = MapStack.create(context); } - + MapStack contextMs = (MapStack) context; // create a standAloneStack, basically a "save point" for this SectionsRenderer, and make a new "screens" object just for it so it is isolated and doesn't follow the stack down MapStack 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); - + String name = this.getName(context); String location = this.getLocation(context); - + // check to see if the name is a composite name separated by a #, if so split it up and get it by the full loc#name if (ScreenFactory.isCombinedName(name)) { String combinedName = name; location = ScreenFactory.getResourceNameFromCombined(combinedName); name = ScreenFactory.getScreenNameFromCombined(combinedName); } - + ModelScreen modelScreen = null; if (UtilValidate.isNotEmpty(location)) { try { @@ -651,7 +651,7 @@ public String getName(Map<String, Object> context) { return this.nameExdr.expandString(context); } - + public String getLocation(Map<String, Object> context) { return this.locationExdr.expandString(context); } @@ -663,7 +663,7 @@ public static class DecoratorSection extends ModelScreenWidget { protected List<ModelScreenWidget> subWidgets; - + public DecoratorSection(ModelScreen modelScreen, Element decoratorSectionElement) { super(modelScreen, decoratorSectionElement); // read sub-widgets @@ -680,9 +680,9 @@ return "<decorator-section name=\"" + this.name + "\">"; } } - + public static class DecoratorSectionInclude extends ModelScreenWidget { - + public DecoratorSectionInclude(ModelScreen modelScreen, Element decoratorSectionElement) { super(modelScreen, decoratorSectionElement); } @@ -712,13 +712,13 @@ return "<decorator-section-include name=\"" + this.name + "\">"; } } - + public static class Label extends ModelScreenWidget { protected FlexibleStringExpander textExdr; - + protected FlexibleStringExpander idExdr; protected FlexibleStringExpander styleExdr; - + public Label(ModelScreen modelScreen, Element labelElement) { super(modelScreen, labelElement); @@ -740,7 +740,7 @@ throw new RuntimeException(errMsg); } } - + public String getText(Map<String, Object> context) { String text = this.textExdr.expandString(context); StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder"); @@ -749,15 +749,15 @@ } return text; } - + public String getId(Map<String, Object> context) { return this.idExdr.expandString(context); } - + public String getStyle(Map<String, Object> context) { return this.styleExdr.expandString(context); } - + public String rawString() { return "<label id=\"" + this.idExdr.getOriginal() + "\" style=\"" + this.styleExdr.getOriginal() + "\" text=\"" + this.textExdr.getOriginal() + "\"/>"; } @@ -768,7 +768,7 @@ protected FlexibleStringExpander locationExdr; protected FlexibleStringExpander shareScopeExdr; protected ModelForm modelForm = null; - + public Form(ModelScreen modelScreen, Element formElement) { super(modelScreen, formElement); @@ -785,7 +785,7 @@ } ((MapStack) context).push(); } - + // try finding the formStringRenderer by name in the context in case one was prepared and put there FormStringRenderer formStringRenderer = (FormStringRenderer) context.get("formStringRenderer"); // if there was no formStringRenderer put in place, now try finding the request/response in the context and creating a new one @@ -800,7 +800,7 @@ if (formStringRenderer == null) { throw new IllegalArgumentException("Could not find a formStringRenderer in the context, and could not find HTTP request/response objects need to create one."); } - + ModelForm modelForm = getModelForm(context); //Debug.logInfo("before renderFormString, context:" + context, module); try { @@ -815,7 +815,7 @@ ((MapStack) context).pop(); } } - + public ModelForm getModelForm(Map<String, Object> context) { ModelForm modelForm = null; String name = this.getName(context); @@ -829,15 +829,15 @@ } return modelForm; } - + public String getName(Map<String, Object> context) { return this.nameExdr.expandString(context); } - + public String getLocation(Map<String, Object> context) { return this.locationExdr.expandString(context); } - + public boolean shareScope(Map<String, Object> context) { String shareScopeString = this.shareScopeExdr.expandString(context); // defaults to false, so anything but true is false @@ -853,7 +853,7 @@ protected FlexibleStringExpander nameExdr; protected FlexibleStringExpander locationExdr; protected FlexibleStringExpander shareScopeExdr; - + public Tree(ModelScreen modelScreen, Element treeElement) { super(modelScreen, treeElement); @@ -870,7 +870,7 @@ } ((MapStack) context).push(); } - + String name = this.getName(context); String location = this.getLocation(context); ModelTree modelTree = null; @@ -889,7 +889,7 @@ Debug.logError(e, errMsg, module); throw new RuntimeException(errMsg); } - + // try finding the treeStringRenderer by name in the context in case one was prepared and put there TreeStringRenderer treeStringRenderer = (TreeStringRenderer) context.get("treeStringRenderer"); // if there was no treeStringRenderer put in place, now try finding the request/response in the context and creating a new one @@ -907,7 +907,7 @@ if (treeStringRenderer == null) { throw new IllegalArgumentException("Could not find a treeStringRenderer in the context, and could not find HTTP request/response objects need to create one."); } - + StringBuffer renderBuffer = new StringBuffer(); modelTree.renderTreeString(renderBuffer, context, treeStringRenderer); try { @@ -922,15 +922,15 @@ ((MapStack) context).pop(); } } - + public String getName(Map<String, Object> context) { return this.nameExdr.expandString(context); } - + public String getLocation(Map<String, Object> context) { return this.locationExdr.expandString(context); } - + public boolean shareScope(Map<String, Object> context) { String shareScopeString = this.shareScopeExdr.expandString(context); // defaults to false, so anything but true is false @@ -944,7 +944,7 @@ public static class PlatformSpecific extends ModelScreenWidget { protected Map<String, ModelScreenWidget> subWidgets; - + public PlatformSpecific(ModelScreen modelScreen, Element platformSpecificElement) { super(modelScreen, platformSpecificElement); subWidgets = new HashMap<String, ModelScreenWidget>(); @@ -997,7 +997,7 @@ } public static class Content extends ModelScreenWidget { - + protected FlexibleStringExpander contentId; protected FlexibleStringExpander editRequest; protected FlexibleStringExpander editContainerStyle; @@ -1007,7 +1007,7 @@ protected String width; protected String height; protected String border; - + public Content(ModelScreen modelScreen, Element subContentElement) { super(modelScreen, subContentElement); @@ -1067,12 +1067,12 @@ dataResource = delegator.findByPrimaryKeyCache("DataResource", UtilMisc.toMap("dataResourceId", expandedDataResourceId)); this.dataResourceId = FlexibleStringExpander.getInstance(expandedDataResourceId); } - + String mimeTypeId = null; if (dataResource != null) { mimeTypeId = dataResource.getString("mimeTypeId"); } - + if (UtilValidate.isNotEmpty(mimeTypeId) && ((mimeTypeId.indexOf("application") >= 0) || (mimeTypeId.indexOf("image")) >= 0) ) { screenStringRenderer.renderContentFrame(writer, context, this); @@ -1093,44 +1093,44 @@ } } - + public String getContentId(Map<String, Object> context) { return this.contentId.expandString(context); } - + public String getDataResourceId(Map<String, Object> context) { return this.dataResourceId.expandString(context); } - + public String getEditRequest(Map<String, Object> context) { return this.editRequest.expandString(context); } - + public String getEditContainerStyle(Map<String, Object> context) { return this.editContainerStyle.expandString(context); } - + public String getEnableEditName(Map<String, Object> context) { return this.enableEditName.expandString(context); } - + public boolean xmlEscape() { return this.xmlEscape; } - + public String rawString() { // may want to expand this a bit more return "<content content-id=\"" + this.contentId.getOriginal() + "\" xml-escape=\"" + this.xmlEscape + "\"/>"; } - + public String getWidth() { return this.width; } - + public String getHeight() { return this.height; } - + public String getBorder() { return this.border; } @@ -1143,7 +1143,7 @@ protected FlexibleStringExpander editContainerStyle; protected FlexibleStringExpander enableEditName; protected boolean xmlEscape = false; - + public SubContent(ModelScreen modelScreen, Element subContentElement) { super(modelScreen, subContentElement); @@ -1170,27 +1170,27 @@ throw new RuntimeException(errMsg); } } - + public String getContentId(Map<String, Object> context) { return this.contentId.expandString(context); } - + public String getMapKey(Map<String, Object> context) { return this.mapKey.expandString(context); } - + public String getEditRequest(Map<String, Object> context) { return this.editRequest.expandString(context); } - + public String getEditContainerStyle(Map<String, Object> context) { return this.editContainerStyle.expandString(context); } - + public String getEnableEditName(Map<String, Object> context) { return this.enableEditName.expandString(context); } - + public boolean xmlEscape() { return this.xmlEscape; } @@ -1204,7 +1204,7 @@ public static class Menu extends ModelScreenWidget { protected FlexibleStringExpander nameExdr; protected FlexibleStringExpander locationExdr; - + public Menu(ModelScreen modelScreen, Element menuElement) { super(modelScreen, menuElement); @@ -1235,11 +1235,11 @@ throw new IllegalArgumentException("Could not find a menuStringRenderer in the context, and could not find HTTP request/response objects need to create one."); } } - + ModelMenu modelMenu = getModelMenu(context); modelMenu.renderMenuString(writer, context, menuStringRenderer); } - + public ModelMenu getModelMenu(Map<String, Object> context) { String name = this.getName(context); String location = this.getLocation(context); @@ -1257,7 +1257,7 @@ public String getName(Map<String, Object> context) { return this.nameExdr.expandString(context); } - + public String getLocation(Map<String, Object> context) { return this.locationExdr.expandString(context); } @@ -1266,7 +1266,7 @@ return "<include-menu name=\"" + this.nameExdr.getOriginal() + "\" location=\"" + this.locationExdr.getOriginal() + "\"/>"; } } - + public static class Link extends ModelScreenWidget { protected FlexibleStringExpander textExdr; protected FlexibleStringExpander idExdr; @@ -1282,7 +1282,7 @@ protected boolean encode = false; protected String linkType; protected List<WidgetWorker.Parameter> parameterList = FastList.newInstance(); - + public Link(ModelScreen modelScreen, Element linkElement) { super(modelScreen, linkElement); @@ -1302,7 +1302,7 @@ if (imageElement != null) { this.image = new Image(modelScreen, imageElement); } - + this.linkType = linkElement.getAttribute("link-type"); List<? extends Element> parameterElementList = UtilXml.childElementList(linkElement, "parameter"); for (Element parameterElement: parameterElementList) { @@ -1319,7 +1319,7 @@ throw new RuntimeException(errMsg); } } - + public String getText(Map<String, Object> context) { String text = this.textExdr.expandString(context); StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder"); @@ -1328,15 +1328,15 @@ } return text; } - + public String getId(Map<String, Object> context) { return this.idExdr.expandString(context); } - + public String getStyle(Map<String, Object> context) { return this.styleExdr.expandString(context); } - + public String getTarget(Map<String, Object> context) { Map<String, Object> expanderContext = context; StringUtil.SimpleEncoder simpleEncoder = context == null ? null : (StringUtil.SimpleEncoder) context.get("simpleEncoder"); @@ -1345,35 +1345,35 @@ } return this.targetExdr.expandString(expanderContext); } - + public String getName(Map<String, Object> context) { return this.nameExdr.expandString(context); } - + public String getTargetWindow(Map<String, Object> context) { return this.targetWindowExdr.expandString(context); } - + public String getUrlMode() { return this.urlMode; } - + public String getPrefix(Map<String, Object> context) { return this.prefixExdr.expandString(context); } - + public boolean getFullPath() { return this.fullPath; } - + public boolean getSecure() { return this.secure; } - + public boolean getEncode() { return this.encode; } - + public Image getImage() { return this.image; } @@ -1381,7 +1381,7 @@ public String getLinkType() { return this.linkType; } - + public List<WidgetWorker.Parameter> getParameterList() { return this.parameterList; } @@ -1477,15 +1477,15 @@ throw new RuntimeException(errMsg); } } - + public String getSrc(Map<String, Object> context) { return this.srcExdr.expandString(context); } - + public String getId(Map<String, Object> context) { return this.idExdr.expandString(context); } - + public String getStyle(Map<String, Object> context) { return this.styleExdr.expandString(context); } @@ -1501,15 +1501,15 @@ public String getBorder(Map<String, Object> context) { return this.borderExdr.expandString(context); } - + public String getAlt(Map<String, Object> context) { return this.alt.expandString(context); } - + public String getUrlMode() { return this.urlMode; } - + public void setSrc(String val) { String textAttr = UtilFormatOut.checkNull(val); this.srcExdr = FlexibleStringExpander.getInstance(textAttr); @@ -1533,7 +1533,7 @@ String altAttr = UtilFormatOut.checkNull(val); this.alt = FlexibleStringExpander.getInstance(altAttr); } - + public void setUrlMode(String val) { if (UtilValidate.isEmpty(val)) { this.urlMode = "content"; Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFactory.java?rev=759246&r1=759245&r2=759246&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFactory.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFactory.java Fri Mar 27 16:59:28 2009 @@ -44,7 +44,7 @@ * Widget Library - Screen factory class */ public class ScreenFactory { - + public static final String module = ScreenFactory.class.getName(); public static final UtilCache<String, Map<String, ModelScreen>> screenLocationCache = new UtilCache<String, Map<String, ModelScreen>>("widget.screen.locationResource", 0, 0, false); @@ -60,7 +60,7 @@ } return true; } - + public static String getResourceNameFromCombined(String combinedName) { // split out the name on the last "#" int numSignIndex = combinedName.lastIndexOf("#"); @@ -73,7 +73,7 @@ String resourceName = combinedName.substring(0, numSignIndex); return resourceName; } - + public static String getScreenNameFromCombined(String combinedName) { // split out the name on the last "#" int numSignIndex = combinedName.lastIndexOf("#"); @@ -86,14 +86,14 @@ String screenName = combinedName.substring(numSignIndex + 1); return screenName; } - + public static ModelScreen getScreenFromLocation(String combinedName) throws IOException, SAXException, ParserConfigurationException { String resourceName = getResourceNameFromCombined(combinedName); String screenName = getScreenNameFromCombined(combinedName); return getScreenFromLocation(resourceName, screenName); } - + public static ModelScreen getScreenFromLocation(String resourceName, String screenName) throws IOException, SAXException, ParserConfigurationException { Map<String, ModelScreen> modelScreenMap = getScreensFromLocation(resourceName); @@ -116,7 +116,7 @@ if (loader == null) { loader = ScreenFactory.class.getClassLoader(); } - + URL screenFileUrl = null; screenFileUrl = FlexibleLocation.resolveLocation(resourceName, loader); if (screenFileUrl == null) { @@ -130,7 +130,7 @@ } } } - + if (modelScreenMap == null) { throw new IllegalArgumentException("Could not find screen file with name [" + resourceName + "]"); } @@ -141,15 +141,15 @@ throws IOException, SAXException, ParserConfigurationException { String webappName = UtilHttp.getApplicationName(request); String cacheKey = webappName + "::" + resourceName; - - + + Map<String, ModelScreen> modelScreenMap = screenWebappCache.get(cacheKey); if (modelScreenMap == null) { synchronized (ScreenFactory.class) { modelScreenMap = screenWebappCache.get(cacheKey); if (modelScreenMap == null) { ServletContext servletContext = (ServletContext) request.getAttribute("servletContext"); - + URL screenFileUrl = servletContext.getResource(resourceName); Document screenFileDoc = UtilXml.readXmlDocument(screenFileUrl, true); modelScreenMap = readScreenDocument(screenFileDoc, resourceName); @@ -157,14 +157,14 @@ } } } - + ModelScreen modelScreen = (ModelScreen) modelScreenMap.get(screenName); if (modelScreen == null) { throw new IllegalArgumentException("Could not find screen with name [" + screenName + "] in webapp resource [" + resourceName + "] in the webapp [" + webappName + "]"); } return modelScreen; } - + public static Map<String, ModelScreen> readScreenDocument(Document screenFileDoc, String sourceLocation) { Map<String, ModelScreen> modelScreenMap = FastMap.newInstance(); if (screenFileDoc != null) { |
Free forum by Nabble | Edit this page |