Fix purely empty whitespace lines, and remove trailing whitespace.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@757077 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Adam Heath
2009-03-21 23:24:58 +00:00
parent 3cd2ee4be6
commit 4161d4e2bf
58 changed files with 1321 additions and 1321 deletions
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -44,5 +44,5 @@ public interface ContentWorkerInterface {
public String renderContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException;
public void renderSubContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, Appendable out, String mapKey, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException;
public String renderSubContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, String mapKey, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException;
public String renderSubContentAsTextExt(LocalDispatcher dispatcher, GenericDelegator delegator, String contentId, String mapKey, Map<String, Object> templateContext, Locale locale, String mimeTypeId, boolean cache) throws GeneralException, IOException;
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -31,7 +31,7 @@ import org.ofbiz.entity.GenericDelegator;
public interface DataResourceWorkerInterface {
public String renderDataResourceAsTextExt(GenericDelegator delegator, String dataResourceId, Map templateContext,
Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException;
public void renderDataResourceAsTextExt(GenericDelegator delegator, String dataResourceId, Appendable out, Map templateContext,
Locale locale, String targetMimeTypeId, boolean cache) throws GeneralException, IOException;
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -41,7 +41,7 @@ public class ModelWidget implements Serializable {
* &lt;context-param&gt;<br/>
* &nbsp;&nbsp;&lt;param-name&gt;widgetVerbose&lt;/param-name&gt;<br/>
* &nbsp;&nbsp;&lt;param-value&gt;true&lt;/param-value&gt;<br/>
* &lt;/context-param&gt;
* &lt;/context-param&gt;
* </code><br/><br/>
* Screen widget example:<br/><br/>
* <code>
@@ -53,11 +53,11 @@ public class ModelWidget implements Serializable {
public static final String enableBoundaryCommentsParam = "widgetVerbose";
protected String name;
protected boolean enableWidgetBoundaryComments = false;
protected ModelWidget() {}
/**
* Derived classes must call this constructor.
* Derived classes must call this constructor.
* @param widgetElement The XML Element for the widget
*/
public ModelWidget(Element widgetElement) {
@@ -71,7 +71,7 @@ public class ModelWidget implements Serializable {
public String getName() {
return name;
}
/**
* Returns the widget's name to be used in boundary comments. The default action
* is to return the widget's name. Derived classes can override this method to
@@ -81,7 +81,7 @@ public class ModelWidget implements Serializable {
public String getBoundaryCommentName() {
return name;
}
/**
* Returns true if boundary comments are enabled for this widget, otherwise
* returns false.
@@ -115,20 +115,20 @@ public class ModelWidget implements Serializable {
}
public int getPaginatorNumber(Map<String, Object> context) {
int paginator_number = 0;
Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
int paginator_number = 0;
Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
if (globalCtx != null) {
Integer paginateNumberInt= (Integer)globalCtx.get("PAGINATOR_NUMBER");
if (paginateNumberInt == null) {
if (paginateNumberInt == null) {
paginateNumberInt = Integer.valueOf(0);
globalCtx.put("PAGINATOR_NUMBER", paginateNumberInt);
}
paginator_number = paginateNumberInt.intValue();
}
}
return paginator_number;
}
public void incrementPaginatorNumber(Map<String, Object> context) {
}
public void incrementPaginatorNumber(Map<String, Object> context) {
Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
if (globalCtx != null) {
Boolean NO_PAGINATOR = (Boolean) globalCtx.get("NO_PAGINATOR");
@@ -138,7 +138,7 @@ public class ModelWidget implements Serializable {
Integer paginateNumberInt = Integer.valueOf(getPaginatorNumber(context) + 1);
globalCtx.put("PAGINATOR_NUMBER", paginateNumberInt);
}
}
}
}
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -47,11 +47,11 @@ public class WidgetWorker {
public WidgetWorker () {}
public static void buildHyperlinkUrl(Appendable externalWriter, String target, String targetType, List<WidgetWorker.Parameter> parameterList,
public static void buildHyperlinkUrl(Appendable externalWriter, String target, String targetType, List<WidgetWorker.Parameter> parameterList,
String prefix, boolean fullPath, boolean secure, boolean encode, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException {
String localRequestName = UtilHttp.encodeAmpersands(target);
Appendable localWriter = new StringWriter();
if ("intra-app".equals(targetType)) {
if (request != null && response != null) {
ServletContext servletContext = (ServletContext) request.getSession().getServletContext();
@@ -83,7 +83,7 @@ public class WidgetWorker {
} else {
localWriter.append(localRequestName);
}
if (parameterList != null && parameterList.size() > 0) {
String localUrl = localWriter.toString();
externalWriter.append(localUrl);
@@ -92,7 +92,7 @@ public class WidgetWorker {
externalWriter.append('?');
needsAmp = false;
}
for (WidgetWorker.Parameter parameter: parameterList) {
if (needsAmp) {
externalWriter.append("&amp;");
@@ -120,8 +120,8 @@ public class WidgetWorker {
writer.append(location);
}
public static void makeHyperlinkByType(Appendable writer, String linkType, String linkStyle, String targetType, String target,
List<WidgetWorker.Parameter> parameterList, String description, String targetWindow, ModelFormField modelFormField,
public static void makeHyperlinkByType(Appendable writer, String linkType, String linkStyle, String targetType, String target,
List<WidgetWorker.Parameter> parameterList, String description, String targetWindow, ModelFormField modelFormField,
HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException {
String realLinkType = WidgetWorker.determineAutoLinkType(linkType, target, targetType, request);
if ("hidden-form".equals(realLinkType)) {
@@ -143,11 +143,11 @@ public class WidgetWorker {
} else {
WidgetWorker.makeHyperlinkString(writer, linkStyle, targetType, target, parameterList, description, modelFormField, request, response, context, targetWindow);
}
}
public static void makeHyperlinkString(Appendable writer, String linkStyle, String targetType, String target, List<WidgetWorker.Parameter> parameterList,
String description, ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context, String targetWindow)
public static void makeHyperlinkString(Appendable writer, String linkStyle, String targetType, String target, List<WidgetWorker.Parameter> parameterList,
String description, ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context, String targetWindow)
throws IOException {
if (UtilValidate.isNotEmpty(description) || UtilValidate.isNotEmpty(request.getAttribute("image"))) {
writer.append("<a");
@@ -163,7 +163,7 @@ public class WidgetWorker {
buildHyperlinkUrl(writer, target, targetType, parameterList, null, false, false, true, request, response, context);
writer.append("\"");
if (UtilValidate.isNotEmpty(targetWindow)) {
writer.append(" target=\"");
writer.append(targetWindow);
@@ -179,7 +179,7 @@ public class WidgetWorker {
}
writer.append('>');
if (UtilValidate.isNotEmpty(request.getAttribute("image"))){
writer.append("<img src=\"");
writer.append(request.getAttribute("image").toString());
@@ -190,7 +190,7 @@ public class WidgetWorker {
writer.append("</a>");
}
}
public static void makeHiddenFormLinkAnchor(Appendable writer, String linkStyle, String description, ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException {
if (UtilValidate.isNotEmpty(description) || UtilValidate.isNotEmpty(request.getAttribute("image"))) {
writer.append("<a");
@@ -204,7 +204,7 @@ public class WidgetWorker {
writer.append(" href=\"javascript:document.");
writer.append(makeLinkHiddenFormName(context, modelFormField));
writer.append(".submit()\"");
if (UtilValidate.isNotEmpty(modelFormField.getEvent()) && UtilValidate.isNotEmpty(modelFormField.getAction(context))) {
writer.append(" ");
writer.append(modelFormField.getEvent());
@@ -214,7 +214,7 @@ public class WidgetWorker {
}
writer.append('>');
if (UtilValidate.isNotEmpty(request.getAttribute("image"))){
writer.append("<img src=\"");
writer.append(request.getAttribute("image").toString());
@@ -225,7 +225,7 @@ public class WidgetWorker {
writer.append("</a>");
}
}
public static void makeHiddenFormLinkForm(Appendable writer, String target, String targetType, String targetWindow, List<WidgetWorker.Parameter> parameterList, ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException {
writer.append("<form method=\"post\"");
writer.append(" action=\"");
@@ -252,10 +252,10 @@ public class WidgetWorker {
writer.append(parameter.getValue(context));
writer.append("\" type=\"hidden\"/>");
}
writer.append("</form>");
}
public static String makeLinkHiddenFormName(Map<String, Object> context, ModelFormField modelFormField) {
ModelForm modelForm = modelFormField.getModelForm();
Integer itemIndex = (Integer) context.get("itemIndex");
@@ -303,12 +303,12 @@ public class WidgetWorker {
}
}
}
public static String determineAutoLinkType(String linkType, String target, String targetType, HttpServletRequest request) {
Debug.logInfo("determineAutoLinkType: linkType=" + linkType + ", target=[" + target + "], targetType=" + targetType, module);
if ("auto".equals(linkType)) {
if ("intra-app".equals(targetType)) {
String requestUri = (target.indexOf('?') > -1) ? target.substring(0, target.indexOf('?')) : target;
String requestUri = (target.indexOf('?') > -1) ? target.substring(0, target.indexOf('?')) : target;
ServletContext servletContext = (ServletContext) request.getSession().getServletContext();
RequestHandler rh = (RequestHandler) servletContext.getAttribute("_REQUEST_HANDLER_");
ConfigXMLReader.RequestMap requestMap = rh.getControllerConfig().requestMapMap.get(requestUri);
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -27,8 +27,8 @@ public class GenericWidgetOutput {
public GenericWidgetOutput(String output) {
this.output = new String(output);
}
public String toString() {
return this.output;
return this.output;
}
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -32,9 +32,9 @@ import javolution.util.FastSet;
public class WidgetContextCacheKey {
public static final String module = WidgetContextCacheKey.class.getName();
private static Set<String> fieldNamesToSkip;
static {
fieldNamesToSkip = FastSet.newInstance();
fieldNamesToSkip.add("globalContext");
@@ -78,7 +78,7 @@ public class WidgetContextCacheKey {
fieldNamesToSkip.add("visit");
fieldNamesToSkip.add("visitor");
}
protected Map<String, Object> context;
public WidgetContextCacheKey(Map<String, Object> context) {
@@ -133,7 +133,7 @@ public class WidgetContextCacheKey {
}
return true;
}
public String toString() {
Map<String, Object> printableMap = FastMap.newInstance();
Iterator fieldNameIt = this.context.keySet().iterator();
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -59,7 +59,7 @@ import org.ofbiz.widget.html.HtmlWidgetRenderer;
public class FoFormRenderer extends HtmlWidgetRenderer implements FormStringRenderer {
public static final String module = FoFormRenderer.class.getName();
HttpServletRequest request;
HttpServletResponse response;
@@ -408,12 +408,12 @@ public class FoFormRenderer extends HtmlWidgetRenderer implements FormStringRend
public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException {
// TODO
}
public void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner) throws IOException {
// TODO
this.makeBlockString(writer, null, "");
}
public void renderHyperlinkTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText) throws IOException {
}
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -45,12 +45,12 @@ import org.xml.sax.SAXException;
* Widget Library - Form factory class
*/
public class FormFactory {
public static final String module = FormFactory.class.getName();
public static final UtilCache<String, ModelForm> formLocationCache = new UtilCache<String, ModelForm>("widget.form.locationResource", 0, 0, false);
public static final UtilCache<String, ModelForm> formWebappCache = new UtilCache<String, ModelForm>("widget.form.webappResource", 0, 0, false);
public static Map<String, ModelForm> getFormsFromLocation(String resourceName, ModelReader entityModelReader, DispatchContext dispatchContext)
public static Map<String, ModelForm> getFormsFromLocation(String resourceName, ModelReader entityModelReader, DispatchContext dispatchContext)
throws IOException, SAXException, ParserConfigurationException {
/*
ClassLoader loader = Thread.currentThread().getContextClassLoader();
@@ -63,7 +63,7 @@ public class FormFactory {
return readFormDocument(formFileDoc, entityModelReader, dispatchContext, resourceName);
}
public static ModelForm getFormFromLocation(String resourceName, String formName, ModelReader entityModelReader, DispatchContext dispatchContext)
public static ModelForm getFormFromLocation(String resourceName, String formName, ModelReader entityModelReader, DispatchContext dispatchContext)
throws IOException, SAXException, ParserConfigurationException {
String cacheKey = resourceName + "#" + formName;
ModelForm modelForm = formLocationCache.get(cacheKey);
@@ -90,7 +90,7 @@ public class FormFactory {
return modelForm;
}
public static ModelForm getFormFromWebappContext(String resourceName, String formName, HttpServletRequest request)
public static ModelForm getFormFromWebappContext(String resourceName, String formName, HttpServletRequest request)
throws IOException, SAXException, ParserConfigurationException {
String webappName = UtilHttp.getApplicationName(request);
String cacheKey = webappName + "::" + resourceName + "::" + formName;
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -45,11 +45,11 @@ public interface FormStringRenderer {
public void renderFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException;
public void renderSingleFormFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException;
public void renderFormOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException;
public void renderFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException;
public void renderMultiFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException;
public void renderFormatListWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException;
public void renderFormatListWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException;
@@ -61,7 +61,7 @@ public interface FormStringRenderer {
public void renderFormatHeaderRowFormCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException;
public void renderFormatHeaderRowFormCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException;
public void renderFormatHeaderRowFormCellTitleSeparator(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, boolean isLast) throws IOException;
public void renderFormatItemRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException;
public void renderFormatItemRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException;
public void renderFormatItemRowCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, int positionSpan) throws IOException;
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -115,9 +115,9 @@ public class ModelForm extends ModelWidget {
protected boolean useRowSubmit = false;
protected FlexibleStringExpander targetWindowExdr;
protected String defaultRequiredFieldStyle;
protected String defaultSortFieldStyle;
protected String defaultSortFieldStyle;
protected String defaultSortFieldAscStyle;
protected String defaultSortFieldDescStyle;
protected String defaultSortFieldDescStyle;
protected String oddRowStyle;
protected String evenRowStyle;
protected String defaultTableStyle;
@@ -155,17 +155,17 @@ public class ModelForm extends ModelWidget {
* Can also include Banner objects.
*/
protected List<FieldGroupBase> fieldGroupList = FastList.newInstance();
/** This Map is keyed with the field name and has a FieldGroup for the value.
* Can also include Banner objects.
*/
protected Map<String, FieldGroupBase> fieldGroupMap = FastMap.newInstance();
/** This field group will be the "catch-all" group for fields that are not
* included in an explicit field-group.
*/
protected FieldGroup defaultFieldGroup;
/** Default hyperlink target. */
public static String DEFAULT_TARGET_TYPE = "intra-app";
@@ -179,18 +179,18 @@ public class ModelForm extends ModelWidget {
public static String DEFAULT_PAG_PREV_STYLE = "nav-previous";
public static String DEFAULT_PAG_NEXT_STYLE = "nav-next";
public static String DEFAULT_PAG_LAST_STYLE = "nav-last";
/** Sort field default styles. */
public static String DEFAULT_SORT_FIELD_STYLE = "sort-order";
public static String DEFAULT_SORT_FIELD_ASC_STYLE = "sort-order-asc";
public static String DEFAULT_SORT_FIELD_DESC_STYLE = "sort-order-desc";
protected List<ModelFormAction> actions;
protected List<ModelFormAction> rowActions;
protected FlexibleStringExpander rowCountExdr;
protected List<ModelFormField> multiSubmitFields = FastList.newInstance();
protected int rowCount = 0;
/** On Submit areas to be updated. */
protected List<UpdateArea> onSubmitUpdateAreas;
/** On Paginate areas to be updated. */
@@ -207,12 +207,12 @@ public class ModelForm extends ModelWidget {
this.dispatchContext = dispatchContext;
initForm(formElement);
}
public ModelForm(Element formElement) {
super(formElement);
initForm(formElement);
}
public void initForm(Element formElement) {
setDefaultViewSize(UtilProperties.getPropertyValue("widget.properties", "widget.form.defaultViewSize"));
@@ -293,7 +293,7 @@ public class ModelForm extends ModelWidget {
this.onSubmitUpdateAreas = parent.onSubmitUpdateAreas;
this.onPaginateUpdateAreas = parent.onPaginateUpdateAreas;
this.altRowStyles = parent.altRowStyles;
//these are done below in a special way...
//this.fieldList = parent.fieldList;
//this.fieldMap = parent.fieldMap;
@@ -399,13 +399,13 @@ public class ModelForm extends ModelWidget {
}
if (this.defaultSortFieldStyle == null || formElement.hasAttribute("default-sort-field-style")) {
this.defaultSortFieldStyle = formElement.getAttribute("default-sort-field-style");
}
}
if (this.defaultSortFieldAscStyle == null || formElement.hasAttribute("default-sort-field-asc-style")) {
this.defaultSortFieldAscStyle = formElement.getAttribute("default-sort-field-asc-style");
}
if (this.defaultSortFieldDescStyle == null || formElement.hasAttribute("default-sort-field-desc-style")) {
this.defaultSortFieldDescStyle = formElement.getAttribute("default-sort-field-desc-style");
}
}
// pagination settings
if (this.paginateTarget == null || formElement.hasAttribute("paginate-target")) {
@@ -438,7 +438,7 @@ public class ModelForm extends ModelWidget {
if (this.paginateStyle == null || formElement.hasAttribute("paginate-style")) {
setPaginateStyle(formElement.getAttribute("paginate-style"));
}
this.paginate = "true".equals(formElement.getAttribute("paginate"));
this.skipStart = "true".equals(formElement.getAttribute("skip-start"));
this.skipEnd = "true".equals(formElement.getAttribute("skip-end"));
@@ -466,7 +466,7 @@ public class ModelForm extends ModelWidget {
AltRowStyle altRowStyle = new AltRowStyle(altRowStyleElement);
this.altRowStyles.add(altRowStyle);
}
// alt-target
List altTargetElements = UtilXml.childElementList(formElement, "alt-target");
Iterator altTargetElementIter = altTargetElements.iterator();
@@ -475,14 +475,14 @@ public class ModelForm extends ModelWidget {
AltTarget altTarget = new AltTarget(altTargetElement);
this.addAltTarget(altTarget);
}
// on-event-update-area
List<? extends Element> updateAreaElements = UtilXml.childElementList(formElement, "on-event-update-area");
for (Element updateAreaElement : updateAreaElements) {
UpdateArea updateArea = new UpdateArea(updateAreaElement);
this.addOnEventUpdateArea(updateArea);
}
// auto-fields-service
List autoFieldsServiceElements = UtilXml.childElementList(formElement, "auto-fields-service");
Iterator autoFieldsServiceElementIter = autoFieldsServiceElements.iterator();
@@ -537,13 +537,13 @@ public class ModelForm extends ModelWidget {
} else if (tagName.equals("banner")) {
Banner thisBanner = new Banner(sortFieldElement, this);
this.fieldGroupList.add(thisBanner);
lastFieldGroup = new FieldGroup(null, this);
this.fieldGroupList.add(lastFieldGroup);
} else if (tagName.equals("field-group")) {
FieldGroup thisFieldGroup = new FieldGroup(sortFieldElement, this);
this.fieldGroupList.add(thisFieldGroup);
lastFieldGroup = new FieldGroup(null, this);
this.fieldGroupList.add(lastFieldGroup);
}
@@ -796,7 +796,7 @@ public class ModelForm extends ModelWidget {
*/
public void renderFormString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException {
runFormActions(context);
setWidgetBoundaryComments(context);
// if this is a list form, don't useRequestParameters
@@ -844,7 +844,7 @@ public class ModelForm extends ModelWidget {
public void renderSingleFormString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer, int positions) throws IOException {
List<ModelFormField> tempFieldList = FastList.newInstance();
tempFieldList.addAll(this.fieldList);
// Check to see if there is a field, same name and same use-when (could come from extended form)
for (int j = 0; j < tempFieldList.size(); j++) {
ModelFormField modelFormField = (ModelFormField) tempFieldList.get(j);
@@ -888,21 +888,21 @@ public class ModelForm extends ModelWidget {
if (fieldIter.hasNext()) {
nextFormField = (ModelFormField) fieldIter.next();
}
FieldGroup currentFieldGroup = null;
String currentFieldGroupName = null;
String lastFieldGroupName = null;
if (currentFormField != null) {
currentFieldGroup = (FieldGroup)fieldGroupMap.get(currentFormField.getFieldName());
currentFieldGroup = (FieldGroup)fieldGroupMap.get(currentFormField.getFieldName());
if (currentFieldGroup == null) {
currentFieldGroup = defaultFieldGroup;
}
if (currentFieldGroup != null) {
currentFieldGroupName = currentFieldGroup.getId();
}
}
}
boolean isFirstPass = true;
boolean haveRenderedOpenFieldRow = false;
while (currentFormField != null) {
@@ -913,9 +913,9 @@ public class ModelForm extends ModelWidget {
List inbetweenList = getInbetweenList(lastFieldGroup, currentFieldGroup);
Iterator iter = inbetweenList.iterator();
while (iter.hasNext()) {
Object obj = iter.next();
Object obj = iter.next();
if (obj instanceof ModelForm.Banner) {
((ModelForm.Banner) obj).renderString(writer, context, formStringRenderer);
((ModelForm.Banner) obj).renderString(writer, context, formStringRenderer);
}
}
if (currentFieldGroup != null && (lastFieldGroup == null || !lastFieldGroupName.equals(currentFieldGroupName))) {
@@ -942,29 +942,29 @@ public class ModelForm extends ModelWidget {
}
currentFieldGroup = null;
if (currentFormField != null) {
currentFieldGroup = (FieldGroup) fieldGroupMap.get(currentFormField.getName());
currentFieldGroup = (FieldGroup) fieldGroupMap.get(currentFormField.getName());
}
if (currentFieldGroup == null) {
currentFieldGroup = defaultFieldGroup;
}
currentFieldGroupName = currentFieldGroup.getId();
if (lastFieldGroup != null ) {
lastFieldGroupName = lastFieldGroup.getId();
if (!lastFieldGroupName.equals(currentFieldGroupName)) {
lastFieldGroup.renderEndString(writer, context, formStringRenderer);
List inbetweenList = getInbetweenList(lastFieldGroup, currentFieldGroup);
Iterator iter = inbetweenList.iterator();
while (iter.hasNext()) {
Object obj = iter.next();
Object obj = iter.next();
if (obj instanceof ModelForm.Banner) {
((ModelForm.Banner) obj).renderString(writer, context, formStringRenderer);
((ModelForm.Banner) obj).renderString(writer, context, formStringRenderer);
}
}
}
}
if (currentFieldGroup != null && (lastFieldGroup == null || !lastFieldGroupName.equals(currentFieldGroupName))) {
currentFieldGroup.renderStartString(writer, context, formStringRenderer);
lastFieldGroup = currentFieldGroup;
@@ -1106,7 +1106,7 @@ public class ModelForm extends ModelWidget {
this.renderItemRows(writer, context, formStringRenderer, false, numOfColumns);
formStringRenderer.renderFormatListWrapperClose(writer, context, this);
if (!skipEnd) {
formStringRenderer.renderMultiFormClose(writer, context, this);
}
@@ -1166,7 +1166,7 @@ public class ModelForm extends ModelWidget {
ModelFormField modelFormField = (ModelFormField) displayHyperlinkFieldIter.next();
ModelFormField.FieldInfo fieldInfo = modelFormField.getFieldInfo();
// if the field's title is explicitly set to "" (title="") then
// if the field's title is explicitly set to "" (title="") then
// the header is not created for it; this is useful for position list
// where one line can be rendered with more than one row, and we
// only want to display the title header for the main row
@@ -1218,7 +1218,7 @@ public class ModelForm extends ModelWidget {
if (maxNumOfColumns < numOfColumns) {
maxNumOfColumns = numOfColumns;
}
fieldRowsByPosition.add(UtilMisc.toMap("displayBefore", innerDisplayHyperlinkFieldsBegin,
"inputFields", innerFormFields,
"displayAfter", innerDisplayHyperlinkFieldsEnd));
@@ -1232,9 +1232,9 @@ public class ModelForm extends ModelWidget {
List innerDisplayHyperlinkFieldsBegin = (List)listsMap.get("displayBefore");
List innerFormFields = (List)listsMap.get("inputFields");
List innerDisplayHyperlinkFieldsEnd = (List)listsMap.get("displayAfter");
int numOfCells = innerDisplayHyperlinkFieldsBegin.size() +
innerDisplayHyperlinkFieldsEnd.size() +
innerDisplayHyperlinkFieldsEnd.size() +
(innerFormFields.size() > 0? 1: 0);
int numOfColumnsToSpan = maxNumOfColumns - numOfCells + 1;
if (numOfColumnsToSpan < 1) {
@@ -1310,7 +1310,7 @@ public class ModelForm extends ModelWidget {
}
public void preparePager(Map<String, Object> context) {
// increment the paginator
this.incrementPaginatorNumber(context);
this.rowCount = 0;
@@ -1328,7 +1328,7 @@ public class ModelForm extends ModelWidget {
Iterator iter = null;
List items = null;
if (obj instanceof Iterator) {
iter = (Iterator) obj;
iter = (Iterator) obj;
setPaginate(true);
} else if (obj instanceof List) {
items = (List) obj;
@@ -1395,7 +1395,7 @@ public class ModelForm extends ModelWidget {
Iterator iter = null;
List items = null;
if (obj instanceof Iterator) {
iter = (Iterator) obj;
iter = (Iterator) obj;
setPaginate(true);
} else if (obj instanceof List) {
items = (List) obj;
@@ -1434,7 +1434,7 @@ public class ModelForm extends ModelWidget {
if (itemIndex < lowIndex) {
continue;
}
Map<String, Object> itemMap = UtilGenerics.checkMap(item);
MapStack<String> localContext = MapStack.create(context);
if (UtilValidate.isNotEmpty(this.getListEntryName())) {
@@ -1476,7 +1476,7 @@ public class ModelForm extends ModelWidget {
}
}
// Each single item is rendered in one or more rows if its fields have
// Each single item is rendered in one or more rows if its fields have
// different "position" attributes. All the fields with the same position
// are rendered in the same row.
// The default position is 1, and represents the main row:
@@ -1587,7 +1587,7 @@ public class ModelForm extends ModelWidget {
context.put("highIndex", Integer.valueOf(isOverridenListSize() ? listSize : highIndex));
}
context.put("actualPageSize", Integer.valueOf(highIndex - lowIndex));
if (iter instanceof EntityListIterator) {
try {
((EntityListIterator) iter).close();
@@ -1603,7 +1603,7 @@ public class ModelForm extends ModelWidget {
// of one row (corresponding to one position).
public void renderItemRow(Appendable writer, Map<String, Object> localContext, FormStringRenderer formStringRenderer, boolean formPerItem, List hiddenIgnoredFieldList, List innerDisplayHyperlinkFieldsBegin, List innerFormFields, List innerDisplayHyperlinkFieldsEnd, int position, int numOfColumns) throws IOException {
int numOfCells = innerDisplayHyperlinkFieldsBegin.size() +
innerDisplayHyperlinkFieldsEnd.size() +
innerDisplayHyperlinkFieldsEnd.size() +
(innerFormFields.size() > 0? 1: 0);
int numOfColumnsToSpan = numOfColumns - numOfCells + 1;
if (numOfColumnsToSpan < 1) {
@@ -1781,9 +1781,9 @@ public class ModelForm extends ModelWidget {
}
public String getTargetType() {
return this.targetType;
return this.targetType;
}
public String getParentFormName() {
return this.parentFormName;
}
@@ -1806,22 +1806,22 @@ public class ModelForm extends ModelWidget {
public Map<String, ? extends Object> getDefaultMap(Map<String, ? extends Object> context) {
return this.defaultMapName.get(context);
}
public String getDefaultRequiredFieldStyle() {
return this.defaultRequiredFieldStyle;
}
public String getDefaultSortFieldStyle() {
return (UtilValidate.isEmpty(this.defaultSortFieldStyle) ? DEFAULT_SORT_FIELD_STYLE : this.defaultSortFieldStyle);
}
public String getDefaultSortFieldAscStyle() {
return (UtilValidate.isEmpty(this.defaultSortFieldAscStyle) ? DEFAULT_SORT_FIELD_ASC_STYLE : this.defaultSortFieldAscStyle);
}
public String getDefaultSortFieldDescStyle() {
return (UtilValidate.isEmpty(this.defaultSortFieldDescStyle) ? DEFAULT_SORT_FIELD_DESC_STYLE : this.defaultSortFieldDescStyle);
}
}
public String getDefaultServiceName() {
@@ -1847,7 +1847,7 @@ public class ModelForm extends ModelWidget {
public String getOddRowStyle() {
return this.oddRowStyle;
}
public String getEvenRowStyle() {
return this.evenRowStyle;
}
@@ -1855,11 +1855,11 @@ public class ModelForm extends ModelWidget {
public String getDefaultTableStyle() {
return this.defaultTableStyle;
}
public String getHeaderRowStyle() {
return this.headerRowStyle;
}
public String getDefaultTitleStyle() {
return this.defaultTitleStyle;
}
@@ -1919,7 +1919,7 @@ public class ModelForm extends ModelWidget {
if (simpleEncoder != null) {
expanderContext = StringUtil.HtmlEncodingMapWrapper.getHtmlEncodingMapWrapper(context, simpleEncoder);
}
try {
// use the same Interpreter (ie with the same context setup) for all evals
Interpreter bsh = this.getBshInterpreter(context);
@@ -1982,11 +1982,11 @@ public class ModelForm extends ModelWidget {
public String getBoundaryCommentName() {
return formLocation + "#" + name;
}
public void resetBshInterpreter(Map<String, Object> context) {
context.remove("bshInterpreter");
}
public Interpreter getBshInterpreter(Map<String, Object> context) throws EvalError {
Interpreter bsh = (Interpreter) context.get("bshInterpreter");
if (bsh == null) {
@@ -2044,35 +2044,35 @@ public class ModelForm extends ModelWidget {
public void setDefaultWidgetAreaStyle(String string) {
this.defaultWidgetAreaStyle = string;
}
/**
* @param string
*/
public void setOddRowStyle(String string) {
this.oddRowStyle = string;
}
/**
* @param string
*/
public void setEvenRowStyle(String string) {
this.evenRowStyle = string;
}
/**
* @param string
*/
public void setDefaultTableStyle(String string) {
this.defaultTableStyle = string;
}
/**
* @param string
*/
public void setHeaderRowStyle(String string) {
this.headerRowStyle = string;
}
/**
* @param string
*/
@@ -2111,7 +2111,7 @@ public class ModelForm extends ModelWidget {
public String getFormLocation() {
return this.formLocation;
}
/**
* @param string
*/
@@ -2193,7 +2193,7 @@ public class ModelForm extends ModelWidget {
public String getPaginateTargetAnchor() {
return this.paginateTargetAnchor;
}
public String getPaginateIndexField(Map<String, Object> context) {
String field = this.paginateIndexField.expandString(context);
if (UtilValidate.isEmpty(field)) {
@@ -2206,7 +2206,7 @@ public class ModelForm extends ModelWidget {
public int getPaginateIndex(Map<String, Object> context) {
String field = this.getPaginateIndexField(context);
int viewIndex = 0;
try {
Object value = context.get(field);
@@ -2216,22 +2216,22 @@ public class ModelForm extends ModelWidget {
Map parameters = (Map) context.get("parameters");
if (parameters != null) {
value = parameters.get("VIEW_INDEX" + "_" + getPaginatorNumber(context));
if (value == null) {
value = parameters.get(field);
}
}
}
if (value instanceof Integer) {
if (value instanceof Integer) {
viewIndex = ((Integer) value).intValue();
} else if (value instanceof String) {
} else if (value instanceof String) {
viewIndex = Integer.parseInt((String) value);
}
} catch (Exception e) {
Debug.logWarning(e, "Error getting paginate view index: " + e.toString(), module);
}
return viewIndex;
}
@@ -2335,7 +2335,7 @@ public class ModelForm extends ModelWidget {
public String getTargetWindow(Map<String, Object> context) {
return this.targetWindowExdr.expandString(context);
}
public void setTargetWindow( String val ) {
this.targetWindowExdr = FlexibleStringExpander.getInstance(val);
}
@@ -2351,7 +2351,7 @@ public class ModelForm extends ModelWidget {
public boolean getSkipStart() {
return this.skipStart;
}
public boolean getSkipEnd() {
return this.skipEnd;
}
@@ -2363,11 +2363,11 @@ public class ModelForm extends ModelWidget {
public void setSkipStart(boolean val) {
this.skipStart = val;
}
public void setSkipEnd(boolean val) {
this.skipEnd = val;
}
public boolean getHideHeader() {
return this.hideHeader;
}
@@ -2409,10 +2409,10 @@ public class ModelForm extends ModelWidget {
Integer sz = Integer.valueOf(val);
defaultViewSize = sz.intValue();
} catch (NumberFormatException e) {
defaultViewSize = DEFAULT_PAGE_SIZE;
defaultViewSize = DEFAULT_PAGE_SIZE;
}
}
public int getListSize(Map<String, Object> context) {
Integer value = (Integer) context.get("listSize");
return value != null ? value.intValue() : 0;
@@ -2469,7 +2469,7 @@ public class ModelForm extends ModelWidget {
if (listSize > 0) {
setOverridenListSize(true);
} else if (entryList instanceof EntityListIterator) {
EntityListIterator iter = (EntityListIterator) entryList;
EntityListIterator iter = (EntityListIterator) entryList;
try {
iter.last();
listSize = iter.currentIndex();
@@ -2482,11 +2482,11 @@ public class ModelForm extends ModelWidget {
List items = (List) entryList;
listSize = items.size();
}
if (paginate) {
viewIndex = this.getPaginateIndex(context);
viewSize = this.getPaginateSize(context);
lowIndex = viewIndex * viewSize;
highIndex = (viewIndex + 1) * viewSize;
} else {
@@ -2495,18 +2495,18 @@ public class ModelForm extends ModelWidget {
lowIndex = 0;
highIndex = defaultViewSize;
}
context.put("listSize", Integer.valueOf(listSize));
context.put("viewIndex", Integer.valueOf(viewIndex));
context.put("viewSize", Integer.valueOf(viewSize));
context.put("lowIndex", Integer.valueOf(lowIndex));
context.put("highIndex", Integer.valueOf(highIndex));
}
public String getPassedRowCount(Map<String, Object> context) {
return rowCountExdr.expandString(context);
}
public int getRowCount() {
return this.rowCount;
}
@@ -2525,18 +2525,18 @@ public class ModelForm extends ModelWidget {
String startFieldGroupId = null;
String endFieldGroupId = null;
if (endFieldGroup != null) {
endFieldGroupId = endFieldGroup.getId();
endFieldGroupId = endFieldGroup.getId();
}
if (startFieldGroup == null) {
firstFound = true;
} else {
startFieldGroupId = startFieldGroup.getId();
startFieldGroupId = startFieldGroup.getId();
}
Iterator iter = fieldGroupList.iterator();
while (iter.hasNext()) {
Object obj = iter.next();
if (obj instanceof ModelForm.Banner) {
if (firstFound) inbetweenList.add(obj);
if (firstFound) inbetweenList.add(obj);
} else {
FieldGroup fieldGroup = (FieldGroup)obj;
String fieldGroupId = fieldGroup.getId();
@@ -2550,14 +2550,14 @@ public class ModelForm extends ModelWidget {
if (fieldGroupId.equals(endFieldGroupId)) {
break;
} else {
inbetweenList.add(fieldGroup);
inbetweenList.add(fieldGroup);
}
}
}
}
return inbetweenList;
}
public String getSortField(Map<String, Object> context) {
String field = "sortField";
String value = null;
@@ -2573,16 +2573,16 @@ public class ModelForm extends ModelWidget {
} catch (Exception e) {
Debug.logWarning(e, "Error getting sortField: " + e.toString(), module);
}
return value;
}
}
/* Returns the list of ModelForm.UpdateArea objects.
*/
public List<UpdateArea> getOnSubmitUpdateAreas() {
return this.onSubmitUpdateAreas;
}
public static class AltRowStyle {
public String useWhen;
public String style;
@@ -2591,7 +2591,7 @@ public class ModelForm extends ModelWidget {
this.style = altRowStyleElement.getAttribute("style");
}
}
/**
* iterate through alt-row-styles list to see if should be used, then add style
* @return The style for item row
@@ -2622,7 +2622,7 @@ public class ModelForm extends ModelWidget {
return styles;
}
public static class AltTarget {
public String useWhen;
public FlexibleStringExpander targetExdr;
@@ -2727,7 +2727,7 @@ public class ModelForm extends ModelWidget {
this.defaultPosition = position;
}
}
public static interface FieldGroupBase {}
public static class FieldGroup implements FieldGroupBase {
@@ -2740,7 +2740,7 @@ public class ModelForm extends ModelWidget {
protected static int baseSeqNo = 0;
protected static String baseId = "_G";
public FieldGroup(Element sortOrderElement, ModelForm modelForm) {
this.modelForm = modelForm;
if (sortOrderElement != null) {
this.id = sortOrderElement.getAttribute("id");
@@ -2755,7 +2755,7 @@ public class ModelForm extends ModelWidget {
if (this.initiallyCollapsed) {
this.collapsible = true;
}
List sortFieldElements = UtilXml.childElementList(sortOrderElement, "sort-field");
Iterator sortFieldElementIter = sortFieldElements.iterator();
while (sortFieldElementIter.hasNext()) {
@@ -2768,36 +2768,36 @@ public class ModelForm extends ModelWidget {
this.setId(lastGroupId);
}
}
public String getId() {
return this.id;
return this.id;
}
public void setId( String id) {
this.id = id;
this.id = id;
}
public String getStyle() {
return this.style;
return this.style;
}
public String getTitle() {
return this.title;
return this.title;
}
public Boolean collapsible() {
return this.collapsible;
return this.collapsible;
}
public Boolean initiallyCollapsed() {
return this.initiallyCollapsed;
return this.initiallyCollapsed;
}
public void renderStartString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException {
formStringRenderer.renderFieldGroupOpen(writer, context, this);
formStringRenderer.renderFormatSingleWrapperOpen(writer, context, modelForm);
}
public void renderEndString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException {
formStringRenderer.renderFormatSingleWrapperClose(writer, context, modelForm);
formStringRenderer.renderFieldGroupClose(writer, context, this);
@@ -2813,7 +2813,7 @@ public class ModelForm extends ModelWidget {
public FlexibleStringExpander leftTextStyle;
public FlexibleStringExpander rightText;
public FlexibleStringExpander rightTextStyle;
public Banner(Element sortOrderElement, ModelForm modelForm) {
this.modelForm = modelForm;
this.style = FlexibleStringExpander.getInstance(sortOrderElement.getAttribute("style"));
@@ -2824,7 +2824,7 @@ public class ModelForm extends ModelWidget {
this.rightText = FlexibleStringExpander.getInstance(sortOrderElement.getAttribute("right-text"));
this.rightTextStyle = FlexibleStringExpander.getInstance(sortOrderElement.getAttribute("right-text-style"));
}
public String getStyle(Map<String, Object> context) { return this.style.expandString(context); }
public String getText(Map<String, Object> context) { return this.text.expandString(context); }
public String getTextStyle(Map<String, Object> context) { return this.textStyle.expandString(context); }
@@ -2832,7 +2832,7 @@ public class ModelForm extends ModelWidget {
public String getLeftTextStyle(Map<String, Object> context) { return this.leftTextStyle.expandString(context); }
public String getRightText(Map<String, Object> context) { return this.rightText.expandString(context); }
public String getRightTextStyle(Map<String, Object> context) { return this.rightTextStyle.expandString(context); }
public void renderString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException {
formStringRenderer.renderBanner(writer, context, this);
}
@@ -2921,7 +2921,7 @@ public class ModelForm extends ModelWidget {
String target = link.getTarget(null);
String urlMode = link.getTargetType();
// Debug.logInfo("In findRequestNamesLinkedtoInWidget found link [" + link.rawString() + "] with target [" + target + "]", module);
Set<String> controllerLocAndRequestSet = ConfigXMLReader.findControllerRequestUniqueForTargetType(target, urlMode);
if (controllerLocAndRequestSet != null) {
allRequestsUsed.addAll(controllerLocAndRequestSet);
@@ -2979,14 +2979,14 @@ public class ModelForm extends ModelWidget {
for (AltTarget altTarget: this.altTargets) {
String target = altTarget.targetExdr.getOriginal();
String urlMode = "intra-app";
Set<String> controllerLocAndRequestSet = ConfigXMLReader.findControllerRequestUniqueForTargetType(target, urlMode);
if (controllerLocAndRequestSet != null) {
allRequestsUsed.addAll(controllerLocAndRequestSet);
}
}
}
if (!this.target.isEmpty()) {
String target = this.target.getOriginal();
String urlMode = UtilValidate.isNotEmpty(this.targetType) ? this.targetType : "intra-app";
@@ -2997,7 +2997,7 @@ public class ModelForm extends ModelWidget {
}
}
}
return allRequestsUsed;
}
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -61,12 +61,12 @@ public abstract class ModelFormAction {
this.modelForm = modelForm;
if (Debug.verboseOn()) Debug.logVerbose("Reading Screen action with name: " + actionElement.getNodeName(), module);
}
public abstract void runAction(Map<String, Object> context);
public static List<ModelFormAction> readSubActions(ModelForm modelForm, Element parentElement) {
List<ModelFormAction> actions = new LinkedList<ModelFormAction>();
for (Element actionElement: UtilXml.childElementList(parentElement)) {
if ("set".equals(actionElement.getNodeName())) {
actions.add(new SetField(modelForm, actionElement));
@@ -88,19 +88,19 @@ public abstract class ModelFormAction {
throw new IllegalArgumentException("Action element not supported with name: " + actionElement.getNodeName());
}
}
return actions;
}
public static void runSubActions(List<ModelFormAction> actions, Map<String, Object> context) {
if (actions == null) return;
for (ModelFormAction action: actions) {
if (Debug.verboseOn()) Debug.logVerbose("Running screen action " + action.getClass().getName(), module);
action.runAction(context);
}
}
public static class SetField extends ModelFormAction {
protected FlexibleMapAccessor<Object> field;
protected FlexibleMapAccessor<String> fromField;
@@ -108,7 +108,7 @@ public abstract class ModelFormAction {
protected FlexibleStringExpander defaultExdr;
protected FlexibleStringExpander globalExdr;
protected String type;
public SetField(ModelForm modelForm, Element setElement) {
super (modelForm, setElement);
this.field = FlexibleMapAccessor.getInstance(setElement.getAttribute("field"));
@@ -121,12 +121,12 @@ public abstract class ModelFormAction {
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.fromField.isEmpty()) {
newValue = this.fromField.get(context);
@@ -148,18 +148,18 @@ public abstract class ModelFormAction {
Debug.logError(e, errMsg, module);
throw new IllegalArgumentException(errMsg);
}
}
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) {
@@ -167,19 +167,19 @@ public abstract class ModelFormAction {
}
}
}
public static class PropertyMap extends ModelFormAction {
protected FlexibleStringExpander resourceExdr;
protected FlexibleMapAccessor<Map<String, Object>> mapNameAcsr;
protected FlexibleStringExpander globalExdr;
public PropertyMap(ModelForm modelForm, Element setElement) {
super (modelForm, 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
@@ -198,9 +198,9 @@ public abstract class ModelFormAction {
}
}
}
public static class PropertyToField extends ModelFormAction {
protected FlexibleStringExpander resourceExdr;
protected FlexibleStringExpander propertyExdr;
protected FlexibleMapAccessor<String> fieldAcsr;
@@ -219,7 +219,7 @@ public abstract class ModelFormAction {
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
@@ -228,7 +228,7 @@ public abstract class ModelFormAction {
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);
@@ -238,8 +238,8 @@ public abstract class ModelFormAction {
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
// 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.
value = FlexibleStringExpander.expandString(value, context);
@@ -254,15 +254,15 @@ public abstract class ModelFormAction {
fieldAcsr.put(context, value);
}
}
public static class Script extends ModelFormAction {
protected String location;
public Script(ModelForm modelForm, Element scriptElement) {
super (modelForm, scriptElement);
this.location = scriptElement.getAttribute("location");
}
public void runAction(Map<String, Object> context) {
if (location.endsWith(".bsh")) {
try {
@@ -292,7 +292,7 @@ public abstract class ModelFormAction {
protected FlexibleStringExpander autoFieldMapExdr;
protected FlexibleStringExpander resultMapListNameExdr;
protected Map<FlexibleMapAccessor<Object>, Object> fieldMap;
public Service(ModelForm modelForm, Element serviceElement) {
super (modelForm, serviceElement);
this.serviceNameExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("service-name"));
@@ -315,19 +315,19 @@ public abstract class ModelFormAction {
this.resultMapListNameExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("result-map-list"));
if (this.resultMapListNameExdr.isEmpty()) this.resultMapListNameExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("result-map-list-name"));
}
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);
boolean autoFieldMapBool = !"false".equals(autoFieldMapString);
try {
Map<String, Object> serviceContext = null;
if (autoFieldMapBool) {
@@ -335,13 +335,13 @@ public abstract class ModelFormAction {
} else {
serviceContext = new HashMap<String, Object>();
}
if (this.fieldMap != null) {
EntityFinderUtil.expandFieldMapToContext(this.fieldMap, context, serviceContext);
}
Map<String, Object> result = this.modelForm.getDispatcher(context).runSync(serviceNameExpanded, serviceContext);
if (!this.resultMapNameAcsr.isEmpty()) {
this.resultMapNameAcsr.put(context, result);
String queryString = (String)result.get("queryString");
@@ -352,7 +352,7 @@ public abstract class ModelFormAction {
String queryStringEncoded = queryString.replaceAll("&", "%26");
context.put("queryStringEncoded", queryStringEncoded);
} catch (PatternSyntaxException e) {
}
}
} else {
@@ -377,12 +377,12 @@ public abstract class ModelFormAction {
public static class EntityOne extends ModelFormAction {
protected PrimaryKeyFinder finder;
public EntityOne(ModelForm modelForm, Element entityOneElement) {
super (modelForm, entityOneElement);
finder = new PrimaryKeyFinder(entityOneElement);
}
public void runAction(Map<String, Object> context) {
try {
finder.runFind(context, this.modelForm.getDelegator(context));
@@ -397,7 +397,7 @@ public abstract class ModelFormAction {
public static class EntityAnd extends ModelFormAction {
protected ByAndFinder finder;
String actualListName;
public EntityAnd(ModelForm modelForm, Element entityAndElement) {
super (modelForm, entityAndElement);
@@ -405,7 +405,7 @@ public abstract class ModelFormAction {
// Document ownerDoc = entityAndElement.getOwnerDocument();
// boolean useCache = "true".equalsIgnoreCase(entityAndElement.getAttribute("use-cache"));
// if (!useCache) UtilXml.addChildElement(entityAndElement, "use-iterator", ownerDoc);
// make list-name optional
if (UtilValidate.isEmpty(entityAndElement.getAttribute("list")) && UtilValidate.isEmpty(entityAndElement.getAttribute("list-name"))) {
String lstNm = modelForm.getListName();
@@ -418,7 +418,7 @@ public abstract class ModelFormAction {
if (UtilValidate.isEmpty(this.actualListName)) this.actualListName = entityAndElement.getAttribute("list-name");
finder = new ByAndFinder(entityAndElement);
}
public void runAction(Map<String, Object> context) {
try {
// don't want to do this: context.put("defaultFormResultList", null);
@@ -434,21 +434,21 @@ public abstract class ModelFormAction {
throw new IllegalArgumentException(errMsg);
}
}
}
public static class EntityCondition extends ModelFormAction {
ByConditionFinder finder;
String actualListName;
public EntityCondition(ModelForm modelForm, Element entityConditionElement) {
super (modelForm, entityConditionElement);
//don't want to default to the iterator, should be specified explicitly, not the default
// Document ownerDoc = entityConditionElement.getOwnerDocument();
// boolean useCache = "true".equalsIgnoreCase(entityConditionElement.getAttribute("use-cache"));
// if (!useCache) UtilXml.addChildElement(entityConditionElement, "use-iterator", ownerDoc);
// make list-name optional
if (UtilValidate.isEmpty(entityConditionElement.getAttribute("list")) && UtilValidate.isEmpty(entityConditionElement.getAttribute("list-name"))) {
String lstNm = modelForm.getListName();
@@ -461,7 +461,7 @@ public abstract class ModelFormAction {
if (UtilValidate.isEmpty(this.actualListName)) this.actualListName = entityConditionElement.getAttribute("list-name");
finder = new ByConditionFinder(entityConditionElement);
}
public void runAction(Map<String, Object> context) {
try {
// don't want to do this: context.put("defaultFormResultList", null);
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -141,9 +141,9 @@ public class ModelFormField {
this.widgetStyle = fieldElement.getAttribute("widget-style");
this.tooltipStyle = fieldElement.getAttribute("tooltip-style");
this.requiredFieldStyle = fieldElement.getAttribute("required-field-style");
this.sortFieldStyle = fieldElement.getAttribute("sort-field-style");
this.sortFieldStyle = fieldElement.getAttribute("sort-field-style");
this.sortFieldAscStyle = fieldElement.getAttribute("sort-field-asc-style");
this.sortFieldDescStyle = fieldElement.getAttribute("sort-field-desc-style");
this.sortFieldDescStyle = fieldElement.getAttribute("sort-field-desc-style");
this.redWhen = fieldElement.getAttribute("red-when");
this.setUseWhen(fieldElement.getAttribute("use-when"));
this.encodeOutput = !"false".equals(fieldElement.getAttribute("encode-output"));
@@ -285,7 +285,7 @@ public class ModelFormField {
if (UtilValidate.isNotEmpty(overrideFormField.titleAreaStyle))
this.titleAreaStyle = overrideFormField.titleAreaStyle;
if (UtilValidate.isNotEmpty(overrideFormField.widgetAreaStyle))
this.widgetAreaStyle = overrideFormField.widgetAreaStyle;
this.widgetAreaStyle = overrideFormField.widgetAreaStyle;
if (UtilValidate.isNotEmpty(overrideFormField.titleStyle))
this.titleStyle = overrideFormField.titleStyle;
if (UtilValidate.isNotEmpty(overrideFormField.widgetStyle))
@@ -669,14 +669,14 @@ public class ModelFormField {
public String getEntry(Map<String, Object> context , String defaultValue) {
Boolean isError = (Boolean) context.get("isError");
Boolean useRequestParameters = (Boolean) context.get("useRequestParameters");
Locale locale = (Locale) context.get("locale");
if (locale == null) locale = Locale.getDefault();
TimeZone timeZone = (TimeZone) context.get("timeZone");
if (timeZone == null) timeZone = TimeZone.getDefault();
String returnValue;
// if useRequestParameters is TRUE then parameters will always be used, if FALSE then parameters will never be used
// if isError is TRUE and useRequestParameters is not FALSE (ie is null or TRUE) then parameters will be used
if ((Boolean.TRUE.equals(isError) && !Boolean.FALSE.equals(useRequestParameters)) || (Boolean.TRUE.equals(useRequestParameters))) {
@@ -705,7 +705,7 @@ public class ModelFormField {
dataMapIsContext = true;
}
Object retVal = null;
if (this.entryAcsr != null && !this.entryAcsr.isEmpty()) {
if (this.entryAcsr != null && !this.entryAcsr.isEmpty()) {
//Debug.logInfo("Getting entry, using entryAcsr for field " + this.getName() + " of form " + this.modelForm.getName(), module);
if (dataMap instanceof GenericEntity) {
GenericEntity genEnt = (GenericEntity) dataMap;
@@ -722,7 +722,7 @@ public class ModelFormField {
// if no entry name was specified, use the field's name
retVal = dataMap.get(this.name);
}
// this is a special case to fill in fields during a create by default from parameters passed in
if (dataMapIsContext && retVal == null && !Boolean.FALSE.equals(useRequestParameters)) {
Map<String, ? extends Object> parameters = UtilGenerics.checkMap(context.get("parameters"));
@@ -760,7 +760,7 @@ public class ModelFormField {
returnValue = defaultValue;
}
}
if (this.getEncodeOutput() && returnValue != null) {
StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder");
if (simpleEncoder != null) {
@@ -994,7 +994,7 @@ public class ModelFormField {
// this should never happen, ie name is required
return "";
}
// search for a localized label for the field's name
Map<String, String> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap"));
if (uiLabelMap != null) {
@@ -1006,7 +1006,7 @@ public class ModelFormField {
} else {
Debug.logWarning("Could not find uiLabelMap in context while rendering form " + this.modelForm.getName(), module);
}
// create a title from the name of this field; expecting a Java method/field style name, ie productName or productCategoryId
StringBuffer autoTitlewriter = new StringBuffer();
@@ -1049,25 +1049,25 @@ public class ModelFormField {
return this.modelForm.getDefaultRequiredFieldStyle();
}
}
public String getSortFieldStyle() {
if (UtilValidate.isNotEmpty(this.sortFieldStyle)) {
return this.sortFieldStyle;
}
}
return this.modelForm.getDefaultSortFieldStyle();
}
public String getSortFieldStyleAsc() {
if (UtilValidate.isNotEmpty(this.sortFieldAscStyle)) {
return this.sortFieldAscStyle;
}
}
return this.modelForm.getDefaultSortFieldAscStyle();
}
public String getSortFieldStyleDesc() {
if (UtilValidate.isNotEmpty(this.sortFieldDescStyle)) {
return this.sortFieldDescStyle;
}
}
return this.modelForm.getDefaultSortFieldDescStyle();
}
@@ -1086,7 +1086,7 @@ public class ModelFormField {
return "";
}
}
public boolean getEncodeOutput() {
return this.encodeOutput;
}
@@ -1098,15 +1098,15 @@ public class ModelFormField {
return this.modelForm.getName() + "_" + this.getFieldName();
}
}
public String getHeaderLink() {
return headerLink;
}
public String getHeaderLinkStyle() {
return headerLinkStyle;
}
/**
* @param string
@@ -1306,7 +1306,7 @@ public class ModelFormField {
public void setUseWhen(String string) {
this.useWhen = FlexibleStringExpander.getInstance(string);
}
public void setEncodeOutput(boolean encodeOutput) {
this.encodeOutput = encodeOutput;
}
@@ -1317,7 +1317,7 @@ public class ModelFormField {
public void setWidgetAreaStyle(String string) {
this.widgetAreaStyle = string;
}
/**
* @param string
*/
@@ -1342,37 +1342,37 @@ public class ModelFormField {
public void setHeaderLink(String string) {
this.headerLink = string;
}
/**
* @param string
*/
public void setHeaderLinkStyle(String string) {
this.headerLinkStyle = string;
}
public boolean getRequiredField() {
return this.requiredField != null ? this.requiredField : false;
}
/**
* @param boolean
*/
public void setRequiredField(boolean required) {
this.requiredField = required;
}
public boolean isSortField() {
return this.sortField != null ? this.sortField.booleanValue() : false;
}
/**
* @param boolean
*/
public void setSortField(boolean sort) {
this.sortField = Boolean.valueOf(sort);
}
}
/**
* @param ModelForm
*/
@@ -1551,7 +1551,7 @@ public class ModelFormField {
return this.noCurrentSelectedKey.expandString(context);
}
public void setNoCurrentSelectedKey(String string) {
public void setNoCurrentSelectedKey(String string) {
this.noCurrentSelectedKey = FlexibleStringExpander.getInstance(string);
}
@@ -1705,10 +1705,10 @@ public class ModelFormField {
}
findCondition = EntityCondition.makeCondition(expandedConditionList);
}
try {
Locale locale = UtilMisc.ensureLocale(context.get("locale"));
List<GenericValue> values = null;
values = delegator.findList(this.entityName, findCondition, null, this.orderByList, null, this.cache);
@@ -1730,7 +1730,7 @@ public class ModelFormField {
// expand with the new localContext, which is locale aware
String optionDesc = this.description.expandString(localContext, locale);
Object keyFieldObject = value.get(this.getKeyFieldName());
if (keyFieldObject == null) {
throw new IllegalArgumentException("The value found for key-name [" + this.getKeyFieldName() + "], may not be a valid key field name.");
@@ -1770,7 +1770,7 @@ public class ModelFormField {
protected String rows;
protected String cols;
protected Map<FlexibleMapAccessor<Object>, Object> fieldMap;
public InPlaceEditor (Element element) {
this.setUrl(element.getAttribute("url"));
this.cancelControl = element.getAttribute("cancel-control");
@@ -1794,11 +1794,11 @@ public class ModelFormField {
this.textAfterControls = element.getAttribute("text-after-controls");
this.textBetweenControls = element.getAttribute("text-between-controls");
this.updateAfterRequestCall = element.getAttribute("update-after-request-call");
Element simpleElement = UtilXml.firstChildElement(element, "simple-editor");
this.rows = simpleElement.getAttribute("rows");
this.cols = simpleElement.getAttribute("cols");
this.fieldMap = EntityFinderUtil.makeFieldMap(element);
}
@@ -1823,7 +1823,7 @@ public class ModelFormField {
}
public String getFieldPostCreation() {
return this.fieldPostCreation;
return this.fieldPostCreation;
}
public String getFormClassName() {
@@ -2008,7 +2008,7 @@ public class ModelFormField {
this.fieldMap = fieldMap;
}
}
public static class DisplayField extends FieldInfo {
protected boolean alsoHidden = true;
protected FlexibleStringExpander description;
@@ -2036,7 +2036,7 @@ public class ModelFormField {
this.setDescription(element.getAttribute("description"));
this.setDate(element.getAttribute("date"));
this.alsoHidden = !"false".equals(element.getAttribute("also-hidden"));
Element inPlaceEditorElement = UtilXml.firstChildElement(element, "in-place-editor");
if (inPlaceEditorElement != null) {
this.inPlaceEditor = new InPlaceEditor(inPlaceEditorElement);
@@ -2075,13 +2075,13 @@ public class ModelFormField {
String errMsg = "Error formatting currency value [" + retVal + "]: " + e.toString();
Debug.logError(e, errMsg, module);
throw new IllegalArgumentException(errMsg);
}
}
} else if ("date".equals(type) && retVal.length() > 10) {
retVal = retVal.substring(0,10);
}
return retVal;
}
public InPlaceEditor getInPlaceEditor() {
return this.inPlaceEditor;
}
@@ -2099,7 +2099,7 @@ public class ModelFormField {
public void setDescription(String string) {
description = FlexibleStringExpander.getInstance(string);
}
/**
* @param string
*/
@@ -2112,7 +2112,7 @@ public class ModelFormField {
public void setDate(String string) {
date = FlexibleStringExpander.getInstance(string);
}
public void setInPlaceEditor(InPlaceEditor newInPlaceEditor) {
this.inPlaceEditor = newInPlaceEditor;
}
@@ -2157,7 +2157,7 @@ public class ModelFormField {
public String getDescription(Map<String, Object> context) {
Locale locale = UtilMisc.ensureLocale(context.get("locale"));
// rather than using the context to expand the string, lookup the given entity and use it to expand the string
GenericValue value = null;
String fieldKey = this.keyFieldName;
@@ -2173,7 +2173,7 @@ public class ModelFormField {
Debug.logError(e, errMsg, module);
throw new IllegalArgumentException(errMsg);
}
String retVal = null;
if (value != null) {
// expanding ${} stuff, passing locale explicitly to expand value string because it won't be found in the Entity
@@ -2200,7 +2200,7 @@ public class ModelFormField {
this.subHyperlink = newSubHyperlink;
}
}
public static class HyperlinkField extends FieldInfo {
public static String DEFAULT_TARGET_TYPE = "intra-app";
@@ -2235,7 +2235,7 @@ public class ModelFormField {
this.targetType = element.getAttribute("target-type");
this.targetWindowExdr = FlexibleStringExpander.getInstance(element.getAttribute("target-window"));
this.image = element.getAttribute("image-location");
List<? extends Element> parameterElementList = UtilXml.childElementList(element, "parameter");
for (Element parameterElement: parameterElementList) {
this.parameterList.add(new WidgetWorker.Parameter(parameterElement));
@@ -2253,7 +2253,7 @@ public class ModelFormField {
public String getLinkType() {
return this.linkType;
}
public String getTargetType() {
if (UtilValidate.isNotEmpty(this.targetType)) {
return this.targetType;
@@ -2266,7 +2266,7 @@ public class ModelFormField {
String targetWindow = this.targetWindowExdr.expandString(context);
return targetWindow;
}
public String getDescription(Map<String, Object> context) {
return this.description.expandString(context);
}
@@ -2274,11 +2274,11 @@ public class ModelFormField {
public String getTarget(Map<String, Object> context) {
return this.target.expandString(context);
}
public List<WidgetWorker.Parameter> getParameterList() {
return this.parameterList;
}
public String getImage() {
return this.image;
}
@@ -2331,12 +2331,12 @@ public class ModelFormField {
this.linkStyle = element.getAttribute("link-style");
this.targetType = element.getAttribute("target-type");
this.targetWindowExdr = FlexibleStringExpander.getInstance(element.getAttribute("target-window"));
List<? extends Element> parameterElementList = UtilXml.childElementList(element, "parameter");
for (Element parameterElement: parameterElementList) {
this.parameterList.add(new WidgetWorker.Parameter(parameterElement));
}
this.modelFormField = modelFormField;
}
@@ -2364,7 +2364,7 @@ public class ModelFormField {
String targetWindow = this.targetWindowExdr.expandString(context);
return targetWindow;
}
public String getTarget(Map<String, Object> context) {
if (this.target != null) {
return this.target.expandString(context);
@@ -2372,11 +2372,11 @@ public class ModelFormField {
return "";
}
}
public String getLinkType() {
return this.linkType;
}
public List<WidgetWorker.Parameter> getParameterList() {
return this.parameterList;
}
@@ -2388,7 +2388,7 @@ public class ModelFormField {
return "";
}
}
public ModelFormField getModelFormField() {
return this.modelFormField;
}
@@ -2458,7 +2458,7 @@ public class ModelFormField {
this.useWhen = FlexibleStringExpander.getInstance(string);
}
}
public static class AutoComplete {
protected String autoSelect;
protected String frequency;
@@ -2468,7 +2468,7 @@ public class ModelFormField {
protected String partialChars;
protected String ignoreCase;
protected String fullSearch;
public AutoComplete(Element element) {
this.autoSelect = element.getAttribute("auto-select");
this.frequency = element.getAttribute("frequency");
@@ -2479,67 +2479,67 @@ public class ModelFormField {
this.ignoreCase = element.getAttribute("ignore-case");
this.fullSearch = element.getAttribute("full-search");
}
public String getAutoSelect() {
return this.autoSelect;
}
public String getFrequency() {
return this.frequency;
}
public String getMinChars() {
return this.minChars;
}
public String getChoices() {
return this.choices;
}
public String getPartialSearch() {
return this.partialSearch;
}
public String getPartialChars() {
return this.partialChars;
}
public String getIgnoreCase() {
return this.ignoreCase;
}
public String getFullSearch() {
return this.fullSearch;
}
public void setAutoSelect(String string) {
this.autoSelect = string;
}
public void setFrequency(String string) {
this.frequency = string;
}
public void setMinChars(String string) {
this.minChars = string;
}
public void setChoices(String string) {
this.choices = string;
}
public void setPartialSearch(String string) {
this.partialSearch = string;
}
public void setPartialChars(String string) {
this.partialChars = string;
}
public void setIgnoreCase(String string) {
this.ignoreCase = string;
}
public void setFullSearch(String string) {
this.fullSearch = string;
}
@@ -2552,7 +2552,7 @@ public class ModelFormField {
protected SubHyperlink subHyperlink;
protected boolean disabled;
protected boolean clientAutocompleteField;
protected TextField() {
super();
}
@@ -2587,7 +2587,7 @@ public class ModelFormField {
Debug.logError("Could not parse the max-length value of the text element: [" + maxlengthStr + "], setting to null; default of no maxlength will be used", module);
}
}
this.disabled = "true".equals(element.getAttribute("disabled"));
this.clientAutocompleteField = !"false".equals(element.getAttribute("client-autocomplete-field"));
@@ -2609,21 +2609,21 @@ public class ModelFormField {
public int getSize() {
return size;
}
public boolean getDisabled() {
return this.disabled;
}
public void setDisabled(boolean b) {
this.disabled = b;
this.disabled = b;
}
public boolean getClientAutocompleteField() {
return this.clientAutocompleteField;
}
public void setClientAutocompleteField(boolean b) {
this.clientAutocompleteField = b;
this.clientAutocompleteField = b;
}
public String getDefaultValue(Map<String, Object> context) {
@@ -2686,7 +2686,7 @@ public class ModelFormField {
public TextareaField(Element element, ModelFormField modelFormField) {
super(element, modelFormField);
this.setDefaultValue(element.getAttribute("default-value"));
visualEditorEnable = "true".equals(element.getAttribute("visual-editor-enable"));
visualEditorButtons = FlexibleStringExpander.getInstance(element.getAttribute("visual-editor-buttons"));
readOnly = "true".equals(element.getAttribute("read-only"));
@@ -2741,7 +2741,7 @@ public class ModelFormField {
public boolean isReadOnly() {
return readOnly;
}
/**
* @param r
*/
@@ -2927,7 +2927,7 @@ public class ModelFormField {
if (subHyperlinkElement != null) {
this.subHyperlink = new SubHyperlink(subHyperlinkElement, this.getModelFormField());
}
Element autoCompleteElement = UtilXml.firstChildElement(element, "auto-complete");
if (autoCompleteElement != null) {
this.autoComplete = new AutoComplete(autoCompleteElement);
@@ -2979,23 +2979,23 @@ public class ModelFormField {
public void setSubHyperlink(SubHyperlink newSubHyperlink) {
this.subHyperlink = newSubHyperlink;
}
public AutoComplete getAutoComplete() {
return this.autoComplete;
}
public void setAutoComplete(AutoComplete newAutoComplete) {
this.autoComplete = newAutoComplete;
}
public int getOtherFieldSize() {
return this.otherFieldSize;
return this.otherFieldSize;
}
public String getSize() {
return this.size;
}
/**
* Get the name to use for the parameter for this field in the form interpreter.
* For HTML forms this is the request parameter name.
@@ -3009,7 +3009,7 @@ public class ModelFormField {
} else {
baseName = this.modelFormField.name;
}
baseName += "_OTHER";
Integer itemIndex = (Integer) context.get("itemIndex");
if (itemIndex != null && "multi".equals(this.modelFormField.modelForm.getType())) {
@@ -3067,7 +3067,7 @@ public class ModelFormField {
public void renderFieldString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException {
formStringRenderer.renderCheckField(writer, context, this);
}
public Boolean isAllChecked(Map<String, Object> context) {
String allCheckedStr = this.allChecked.expandString(context);
if (UtilValidate.isNotEmpty(allCheckedStr)) {
@@ -3127,7 +3127,7 @@ public class ModelFormField {
public void setImageLocation(String string) {
imageLocation = string;
}
public String getBackgroundSubmitRefreshTarget(Map<String, Object> context) {
return this.backgroundSubmitRefreshTargetExdr.expandString(context);
}
@@ -3246,11 +3246,11 @@ public class ModelFormField {
public String getDefaultOption() {
return this.defaultOption;
}
public boolean getHideIgnoreCase() {
return this.hideIgnoreCase;
}
public boolean getHideOptions() {
return this.hideOptions;
}
@@ -3319,7 +3319,7 @@ public class ModelFormField {
protected String descriptionFieldName;
protected String targetParameter;
protected SubHyperlink subHyperlink;
public LookupField(Element element, ModelFormField modelFormField) {
super(element, modelFormField);
this.formName = FlexibleStringExpander.getInstance(element.getAttribute("target-form-name"));
@@ -3358,7 +3358,7 @@ public class ModelFormField {
public void setFormName(String str) {
this.formName = FlexibleStringExpander.getInstance(str);
}
public String getDescriptionFieldName() {
return this.descriptionFieldName;
}
@@ -3366,7 +3366,7 @@ public class ModelFormField {
public void setDescriptionFieldName(String str) {
this.descriptionFieldName = str;
}
public SubHyperlink getSubHyperlink() {
return this.subHyperlink;
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -76,7 +76,7 @@ import org.ofbiz.widget.form.ModelFormField.TextareaField;
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 class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
}
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
if (displayField instanceof DisplayEntityField) {
this.makeHyperlinkString(writer, ((DisplayEntityField) displayField).getSubHyperlink(), context);
}
this.appendTooltip(writer, context, modelFormField);
//appendWhitespace(writer);
@@ -336,11 +336,11 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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,
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);
}
@@ -351,8 +351,8 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
}
if (subHyperlink.shouldUse(context)) {
writer.append(' ');
WidgetWorker.makeHyperlinkByType(writer, subHyperlink.getLinkType(), subHyperlink.getLinkStyle(), subHyperlink.getTargetType(), subHyperlink.getTarget(context),
subHyperlink.getParameterList(), subHyperlink.getDescription(context), subHyperlink.getTargetWindow(context), subHyperlink.getModelFormField(),
WidgetWorker.makeHyperlinkByType(writer, subHyperlink.getLinkType(), subHyperlink.getLinkStyle(), subHyperlink.getTargetType(), subHyperlink.getTarget(context),
subHyperlink.getParameterList(), subHyperlink.getDescription(context), subHyperlink.getTargetWindow(context), subHyperlink.getModelFormField(),
this.request, this.response, context);
}
}
@@ -413,7 +413,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
}
writer.append("/>");
this.addAsterisks(writer, context, modelFormField);
this.makeHyperlinkString(writer, textField.getSubHyperlink(), context);
@@ -476,11 +476,11 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
}
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(\"");
if (UtilValidate.isNotEmpty(idName)) {
if (UtilValidate.isNotEmpty(idName)) {
writer.append(idName);
} else {
writer.append("htmlEditArea");
@@ -509,7 +509,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append(value);
writer.append('"');
}
writer.append(" size=\"");
writer.append(Integer.toString(size));
writer.append('"');
@@ -603,7 +603,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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,9 +612,9 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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())) {
if ("time-dropdown".equals(dateTimeField.getInputMethod())) {
String className = modelFormField.getWidgetStyle();
String classString = (className != null ? " class=\"" + className + "\" " : "");
boolean isTwelveHour = "12".equals(dateTimeField.getClock());
@@ -626,7 +626,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
cal = Calendar.getInstance();
cal.setTime(defaultTimestamp);
} catch (IllegalArgumentException e) {
Debug.logWarning("Form widget field [" + paramName + "] with input-method=\"time-dropdown\" was not able to understand the default time ["
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);
}
@@ -638,7 +638,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
if (isTwelveHour) {
for (int i = 1; i <= 12; i++) {
writer.append("<option value=\"" + Integer.toString(i) + "\"");
if (cal != null) {
if (cal != null) {
int hour = cal.get(Calendar.HOUR_OF_DAY);
if (hour == 0) hour = 12;
if (hour > 12) hour -= 12;
@@ -655,7 +655,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append(modelFormField.getParameterName(context));
String idName = modelFormField.getIdName();
if (ajaxEnabled) {
writer.append("_description\"");
@@ -742,7 +742,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append(textFieldIdName);
writer.append('"');
}
if (UtilValidate.isNotEmpty(currentValue)) {
writer.append(" value=\"");
String explicitDescription = (currentDescription != null ? currentDescription : dropDownField.getCurrentDescription(context));
@@ -754,7 +754,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append('"');
}
writer.append("/>");
appendWhitespace(writer);
writer.append("<input type=\"hidden\"");
writer.append(" name=\"");
@@ -765,14 +765,14 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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);
@@ -790,10 +790,10 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
}
writer.append("};");
appendWhitespace(writer);
writer.append("ajaxAutoCompleteDropDown('" + textFieldIdName + "', '" + idName + "', data, {autoSelect: " +
autoComplete.getAutoSelect() + ", frequency: " + autoComplete.getFrequency() + ", minChars: " + autoComplete.getMinChars() +
", choices: " + autoComplete.getChoices() + ", partialSearch: " + autoComplete.getPartialSearch() +
", partialChars: " + autoComplete.getPartialChars() + ", ignoreCase: " + autoComplete.getIgnoreCase() +
writer.append("ajaxAutoCompleteDropDown('" + textFieldIdName + "', '" + idName + "', data, {autoSelect: " +
autoComplete.getAutoSelect() + ", frequency: " + autoComplete.getFrequency() + ", minChars: " + autoComplete.getMinChars() +
", choices: " + autoComplete.getChoices() + ", partialSearch: " + autoComplete.getPartialSearch() +
", partialChars: " + autoComplete.getPartialChars() + ", ignoreCase: " + autoComplete.getIgnoreCase() +
", fullSearch: " + autoComplete.getFullSearch() + "});");
appendWhitespace(writer);
writer.append("</script>");
@@ -809,7 +809,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
if (dropDownField.isAllowMultiple()) {
writer.append(" multiple=\"multiple\"");
}
int otherFieldSize = dropDownField.getOtherFieldSize();
String otherFieldName = dropDownField.getParameterNameOther(context);
if (otherFieldSize > 0) {
@@ -819,7 +819,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append(modelForm.getName());
writer.append(".");
writer.append(otherFieldName);
writer.append(")\" ");
writer.append(")\" ");
}
@@ -879,12 +879,12 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
}
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
}
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append("\n//--></script>");
}
}
this.makeHyperlinkString(writer, dropDownField.getSubHyperlink(), context);
this.appendTooltip(writer, context, modelFormField);
@@ -943,7 +943,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append(action);
writer.append('"');
}
writer.append("/>");
writer.append(optionValue.getDescription());
@@ -1011,7 +1011,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append(action);
writer.append('"');
}
writer.append("/>");
writer.append(optionValue.getDescription());
@@ -1052,7 +1052,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
ModelFormField modelFormField = submitField.getModelFormField();
ModelForm modelForm = modelFormField.getModelForm();
String event = null;
String action = null;
String action = null;
if ("text-link".equals(submitField.getButtonType())) {
writer.append("<a");
@@ -1085,7 +1085,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append(action);
writer.append('"');
}
writer.append("/>");
} else {
// default to "button"
@@ -1132,7 +1132,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append('"');
}
event = modelFormField.getEvent();
action = modelFormField.getAction(context);
if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) {
@@ -1145,7 +1145,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
//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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append("', '" + createAjaxParamsFromUpdateAreas(updateAreas, null, context));
writer.append("')\"");
}
writer.append("/>");
}
@@ -1229,7 +1229,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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,18 +1258,18 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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);
writer.append("\">");
}
renderHyperlinkTitle(writer, context, modelFormField, modelFormField.getTitle(context));
renderHyperlinkTitle(writer, context, modelFormField, modelFormField.getTitle(context));
if (UtilValidate.isNotEmpty(requiredStyle)) {
writer.append("</span>");
}
@@ -1324,7 +1324,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append("basic-form");
}
writer.append("\"");
writer.append(" onSubmit=\"javascript:submitFormDisableSubmits(this)\"");
if (!modelForm.getClientAutocompleteFields()) {
@@ -1373,7 +1373,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
// Threw this in that as a hack to keep the submit button from expanding the first field
// Needs a more rugged solution
// WARNING: this method (renderMultiFormClose) must be called after the
// WARNING: this method (renderMultiFormClose) must be called after the
// table that contains the list has been closed (to avoid validation errors) so
// we cannot call here the methods renderFormatItemRowCell*: for this reason
// they are now commented.
@@ -1391,7 +1391,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
}
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append(postMultiFormWriter.toString());
appendWhitespace(writer);
}
renderEndingBoundaryComment(writer, "Form Widget - Form Element (Multi)", modelForm);
}
@@ -1518,7 +1518,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
* @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=\"");
@@ -1539,11 +1539,11 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
* @see org.ofbiz.widget.form.FormStringRenderer#renderFormatItemRowOpen(java.io.Writer, java.util.Map, org.ofbiz.widget.form.ModelForm)
*/
public void renderFormatItemRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException {
Integer itemIndex = (Integer)context.get("itemIndex");
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();
@@ -1722,8 +1722,8 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append(" <td");
if (positionSpan > 0) {
writer.append(" colspan=\"");
// do a span of 1 for this column, plus 3 columns for each spanned
//position or each blank position that this will be filling in
// do a span of 1 for this column, plus 3 columns for each spanned
//position or each blank position that this will be filling in
writer.append(Integer.toString(1 + (positionSpan * 3)));
writer.append("\"");
}
@@ -1756,7 +1756,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append(modelFormField.getParameterName(context));
writer.append("_op\" value=\"" + defaultOption + "\"/>");
}
writer.append("<input type=\"text\"");
appendClassNames(writer, context, modelFormField);
@@ -1831,7 +1831,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append(modelFormField.getParameterName(context));
writer.append("_ic\" value=\"" + (ignCase ? "Y" : "") + "\"/>");
}
if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
writer.append("</span>");
}
@@ -1964,7 +1964,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
String opEquals = UtilProperties.getMessage("conditional", "equals", locale);
String opGreaterThan = UtilProperties.getMessage("conditional", "greater_than", locale);
String opSameDay = UtilProperties.getMessage("conditional", "same_day", locale);
String opGreaterThanFromDayStart = UtilProperties.getMessage("conditional",
String opGreaterThanFromDayStart = UtilProperties.getMessage("conditional",
"greater_than_from_day_start", locale);
String opLessThan = UtilProperties.getMessage("conditional", "less_than", locale);
String opUpToDay = UtilProperties.getMessage("conditional", "up_to_day", locale);
@@ -2031,14 +2031,14 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
// search for a localized label for the icon
if (uiLabelMap != null) {
localizedIconTitle = (String) uiLabelMap.get("CommonViewCalendar");
}
}
// add calendar pop-up button and seed data IF this is not a "time" type date-find
if (!"time".equals(dateFindField.getType())) {
if ("date".equals(dateFindField.getType())) {
writer.append("<a href=\"javascript:call_cal_notime(document.");
} else {
writer.append("<a href=\"javascript:call_cal(document.");
writer.append("<a href=\"javascript:call_cal(document.");
}
writer.append(modelFormField.getModelForm().getCurrentFormName(context));
writer.append('.');
@@ -2115,7 +2115,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
if ("date".equals(dateFindField.getType())) {
writer.append("<a href=\"javascript:call_cal_notime(document.");
} else {
writer.append("<a href=\"javascript:call_cal(document.");
writer.append("<a href=\"javascript:call_cal(document.");
}
writer.append(modelFormField.getModelForm().getCurrentFormName(context));
writer.append('.');
@@ -2204,8 +2204,8 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
}
writer.append("/>");
// add lookup pop-up button
// add lookup pop-up button
String descriptionFieldName = lookupField.getDescriptionFieldName();
if (UtilValidate.isNotEmpty(descriptionFieldName)) {
writer.append("<a href=\"javascript:call_fieldlookup3(document.");
@@ -2239,7 +2239,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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);
@@ -2282,7 +2282,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
}
if (UtilValidate.isEmpty(targetService) && updateAreas == null) {
Debug.logWarning("Cannot paginate because TargetService is empty for the form: " + modelForm.getName(), module);
return;
return;
}
// get the parameterized pagination index and size fields
@@ -2309,8 +2309,8 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
Debug.logWarning("Could not find uiLabelMap in context", module);
} else {
pageLabel = (String) uiLabelMap.get("CommonPage");
Map<String, Integer> messageMap = UtilMisc.toMap("lowCount", Integer.valueOf(lowIndex + 1), "highCount", Integer.valueOf(lowIndex + actualPageSize), "total", Integer.valueOf(listSize));
commonDisplaying = UtilProperties.getMessage("CommonUiLabels", "CommonDisplaying", messageMap, (Locale) context.get("locale"));
Map<String, Integer> messageMap = UtilMisc.toMap("lowCount", Integer.valueOf(lowIndex + 1), "highCount", Integer.valueOf(lowIndex + actualPageSize), "total", Integer.valueOf(listSize));
commonDisplaying = UtilProperties.getMessage("CommonUiLabels", "CommonDisplaying", messageMap, (Locale) context.get("locale"));
}
// for legacy support, the viewSizeParam is VIEW_SIZE and viewIndexParam is VIEW_INDEX when the fields are "viewSize" and "viewIndex"
@@ -2434,7 +2434,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append(commonDisplaying);
writer.append("</li>");
appendWhitespace(writer);
// Next button
writer.append(" <li class=\"" + modelForm.getPaginateNextStyle());
if (highIndex < listSize) {
@@ -2492,13 +2492,13 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
}
if (UtilValidate.isEmpty(targetService) && updateAreas == null) {
Debug.logWarning("Cannot sort because TargetService is empty for the form: " + modelForm.getName(), module);
return;
return;
}
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)) {
@@ -2520,7 +2520,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
// strip sortField param from the query string
HashSet<String> paramName = new HashSet<String>();
paramName.add("sortField");
String queryString = UtilHttp.stripNamedParamsFromQueryString(str, paramName);
String queryString = UtilHttp.stripNamedParamsFromQueryString(str, paramName);
String urlPath = UtilHttp.removeQueryStringFromTarget(targetService);
String prepLinkText = UtilHttp.getQueryStringFromTarget(targetService);
if (prepLinkText == null) {
@@ -2535,7 +2535,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
prepLinkText += queryString + "&amp;";
}
prepLinkText += "sortField" + "=" + newSortField;
if (ajaxEnabled) {
if (ajaxEnabled) {
prepLinkText = prepLinkText.replace("?", "");
prepLinkText = prepLinkText.replace("&amp;", "&");
}
@@ -2543,19 +2543,19 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append("<a");
if (UtilValidate.isNotEmpty(sortFieldStyle)) {
writer.append(" class=\"");
writer.append(sortFieldStyle);
writer.append(sortFieldStyle);
writer.append("\"");
}
writer.append(" href=\"");
writer.append(" href=\"");
if (ajaxEnabled) {
writer.append("javascript:ajaxUpdateAreas('" + createAjaxParamsFromUpdateAreas(updateAreas, prepLinkText, context) + "')");
} else {
writer.append(rh.makeLink(this.request, this.response, urlPath + prepLinkText));
}
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,11 +2710,11 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
//appendWhitespace(writer);
}
public void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException {
String style = fieldGroup.getStyle();
String id = fieldGroup.getId();
FlexibleStringExpander titleNotExpanded = FlexibleStringExpander.getInstance(fieldGroup.getTitle());
FlexibleStringExpander titleNotExpanded = FlexibleStringExpander.getInstance(fieldGroup.getTitle());
String title = titleNotExpanded.expandString(context);
Boolean collapsed = fieldGroup.initiallyCollapsed();
String collapsibleAreaId = fieldGroup.getId() + "_body";
@@ -2765,7 +2765,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
writer.append(title);
writer.append("</div>");
}
writer.append("</td></tr></table></div>");
writer.append("<div id=\"" + collapsibleAreaId + "\" class=\"fieldgroup-body\"");
@@ -2775,7 +2775,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
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 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
}
writer.append("</td>");
}
String text = banner.getText(context);
if (UtilValidate.isNotEmpty(text)) {
writer.append(" <td align=\"center\">");
@@ -2828,7 +2828,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
}
writer.append("</td>");
}
String rightText = banner.getRightText(context);
if (UtilValidate.isNotEmpty(rightText)) {
writer.append(" <td align=\"right\">");
@@ -2847,7 +2847,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
}
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.
@@ -2859,7 +2859,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
public void renderHyperlinkTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText) throws IOException {
if (UtilValidate.isNotEmpty(modelFormField.getHeaderLink())) {
StringBuffer targetBuffer = new StringBuffer();
FlexibleStringExpander target = FlexibleStringExpander.getInstance(modelFormField.getHeaderLink());
FlexibleStringExpander target = FlexibleStringExpander.getInstance(modelFormField.getHeaderLink());
String fullTarget = target.expandString(context);
targetBuffer.append(fullTarget);
String targetType = HyperlinkField.DEFAULT_TARGET_TYPE;
@@ -2868,7 +2868,7 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe
}
WidgetWorker.makeHyperlinkString(writer, modelFormField.getHeaderLinkStyle(), targetType, targetBuffer.toString(), null, titleText, modelFormField, this.request, this.response, null, null);
} else if (modelFormField.isSortField()) {
renderSortField (writer, context, modelFormField, titleText);
renderSortField (writer, context, modelFormField, titleText);
} else if (modelFormField.isRowSubmit()) {
if (UtilValidate.isNotEmpty(titleText)) writer.append(titleText + "<br/>");
writer.append("<input type=\"checkbox\" name=\"selectAll\" value=\"Y\" onclick=\"javascript:toggleAll(this, '");
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -43,9 +43,9 @@ import org.xml.sax.SAXException;
* 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;
@@ -56,13 +56,13 @@ public class HtmlFormWrapper {
protected HtmlFormWrapper() {}
public HtmlFormWrapper(String resourceName, String formName, HttpServletRequest request, HttpServletResponse response)
public HtmlFormWrapper(String resourceName, String formName, HttpServletRequest request, HttpServletResponse response)
throws IOException, SAXException, ParserConfigurationException {
this.resourceName = resourceName;
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 @@ public class HtmlFormWrapper {
}
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) {
@@ -125,17 +125,17 @@ public class HtmlFormWrapper {
return buffer;
}
/**
/**
* Tells the form library whether this is a response to an error or not.
* Defaults on initialization according to the presense of an errorMessage
* in the request or if an isError parameter was passed to the page with
* in the request or if an isError parameter was passed to the page with
* the value "true". If true then the prefilled values will come from the
* parameters Map instead of the value Map.
* parameters Map instead of the value Map.
*/
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,20 +144,20 @@ public class HtmlFormWrapper {
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.
* This is generally used when it is an empty form to pre-set inital values.
* This is automatically set to false for list and multi forms. For related
* functionality see the setIsError method.
*
*
* @param useRequestParameters
*/
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 @@ public class HtmlFormWrapper {
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;
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -141,7 +141,7 @@ public class HtmlMenuRenderer extends HtmlWidgetRenderer implements MenuStringRe
}
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 @@ public class HtmlMenuRenderer extends HtmlWidgetRenderer implements MenuStringRe
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,15 +178,15 @@ public class HtmlMenuRenderer extends HtmlWidgetRenderer implements MenuStringRe
writer.append(" title=\"" + toolTip + "\"");
}
writer.append(">");
Link link = menuItem.getLink();
//if (Debug.infoOn()) Debug.logInfo("in HtmlMenuRendererImage, link(0):" + link,"");
if (link != null) {
renderLink(writer, context, link);
}
}
writer.append("</li>");
appendWhitespace(writer);
}
@@ -249,7 +249,7 @@ public class HtmlMenuRenderer extends HtmlWidgetRenderer implements MenuStringRe
}
appendWhitespace(writer);
writer.append(" <ul>");
appendWhitespace(writer);
}
@@ -273,8 +273,8 @@ public class HtmlMenuRenderer extends HtmlWidgetRenderer implements MenuStringRe
writer.append("</div>");
appendWhitespace(writer);
renderEndingBoundaryComment(writer, "Menu Widget", modelMenu);
userLoginIdHasChanged = userLoginIdHasChanged();
userLoginIdHasChanged = userLoginIdHasChanged();
GenericValue userLogin = (GenericValue)request.getSession().getAttribute("userLogin");
if (userLogin != null) {
String userLoginId = userLogin.getString("userLoginId");
@@ -368,7 +368,7 @@ public class HtmlMenuRenderer extends HtmlWidgetRenderer implements MenuStringRe
if (menuItem.getDisabled()) {
target = null;
}
if (UtilValidate.isNotEmpty(target)) {
HttpServletResponse response = (HttpServletResponse) context.get("response");
HttpServletRequest request = (HttpServletRequest) context.get("request");
@@ -381,7 +381,7 @@ public class HtmlMenuRenderer extends HtmlWidgetRenderer implements MenuStringRe
writer.append("<form method=\"post\"");
writer.append(" action=\"");
// note that this passes null for the parameterList on purpose so they won't be put into the URL
WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), null, link.getPrefix(context),
WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), null, link.getPrefix(context),
link.getFullPath(), link.getSecure(), link.getEncode(), request, response, context);
writer.append("\"");
@@ -404,10 +404,10 @@ public class HtmlMenuRenderer extends HtmlWidgetRenderer implements MenuStringRe
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 @@ public class HtmlMenuRenderer extends HtmlWidgetRenderer implements MenuStringRe
writer.append(id);
writer.append("\"");
}
String style = link.getStyle(context);
if (UtilValidate.isNotEmpty(style)) {
writer.append(" class=\"");
@@ -440,12 +440,12 @@ public class HtmlMenuRenderer extends HtmlWidgetRenderer implements MenuStringRe
writer.append(uniqueItemName);
writer.append(".submit()");
} else {
WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), link.getParameterList(), link.getPrefix(context),
WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), link.getParameterList(), link.getPrefix(context),
link.getFullPath(), link.getSecure(), link.getEncode(), request, response, context);
}
writer.append("\">");
}
// the text
Image img = link.getImage();
if (img == null) {
@@ -453,31 +453,31 @@ public class HtmlMenuRenderer extends HtmlWidgetRenderer implements MenuStringRe
} 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 {
style = link.getStyle(context);
if (UtilValidate.isEmpty(style))
if (UtilValidate.isEmpty(style))
style = menuItem.getTitleStyle();
if (UtilValidate.isEmpty(style))
if (UtilValidate.isEmpty(style))
style = menuItem.getWidgetStyle();
}
if (menuItem.getDisabled()) {
style = menuItem.getDisabledTitleStyle();
}
if (UtilValidate.isNotEmpty(style)) {
writer.append(" class=\"");
writer.append(style);
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -71,9 +71,9 @@ public class HtmlMenuRendererImage extends HtmlMenuRenderer {
String cellWidth = menuItem.getCellWidth();
imgStr += "\"";
String widthStr = "";
if (UtilValidate.isNotEmpty(cellWidth))
if (UtilValidate.isNotEmpty(cellWidth))
widthStr = " width=\"" + cellWidth + "\" ";
imgStr += widthStr;
imgStr += " border=\"0\" />";
return imgStr;
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -45,9 +45,9 @@ import org.xml.sax.SAXException;
* 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;
@@ -58,22 +58,22 @@ public class HtmlMenuWrapper {
protected HtmlMenuWrapper() {}
public HtmlMenuWrapper(String resourceName, String menuName, HttpServletRequest request, HttpServletResponse response)
public HtmlMenuWrapper(String resourceName, String menuName, HttpServletRequest request, HttpServletResponse response)
throws IOException, SAXException, ParserConfigurationException {
init(resourceName, menuName, request, response);
}
public void init(String resourceName, String menuName, HttpServletRequest request, HttpServletResponse response)
public void init(String resourceName, String menuName, HttpServletRequest request, HttpServletResponse response)
throws IOException, SAXException, ParserConfigurationException {
this.resourceName = resourceName;
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 @@ public class HtmlMenuWrapper {
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 class HtmlMenuWrapper {
public MenuStringRenderer getMenuRenderer() {
return new HtmlMenuRenderer(request, response);
}
public String renderMenuString() throws IOException {
HttpServletRequest req = ((HtmlMenuRenderer)renderer).request;
ServletContext ctx = (ServletContext) req.getAttribute("servletContext");
@@ -121,17 +121,17 @@ public class HtmlMenuWrapper {
return writer.toString();
}
/**
/**
* Tells the menu library whether this is a response to an error or not.
* Defaults on initialization according to the presense of an errorMessage
* in the request or if an isError parameter was passed to the page with
* in the request or if an isError parameter was passed to the page with
* the value "true". If true then the prefilled values will come from the
* parameters Map instead of the value Map.
* parameters Map instead of the value Map.
*/
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 @@ public class HtmlMenuWrapper {
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 @@ public class HtmlMenuWrapper {
}
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 @@ public class HtmlMenuWrapper {
}
return valueMap.get(valueName);
}
public ModelMenu getModelMenu() {
return modelMenu;
}
@@ -202,9 +202,9 @@ public class HtmlMenuWrapper {
}
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);
@@ -229,14 +229,14 @@ public class HtmlMenuWrapper {
throw new RuntimeException(e6.getMessage());
}
} else {
menuWrapper.setRequest(request);
menuWrapper.setResponse(response);
menuWrapper.setRequest(request);
menuWrapper.setResponse(response);
Map parameterMap = UtilHttp.getParameterMap(request);
menuWrapper.setParameters( parameterMap);
GenericValue userLogin = (GenericValue)session.getAttribute("userLogin");
menuWrapper.putInContext("userLogin", userLogin);
}
if (session != null) {
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -40,12 +40,12 @@ import org.xml.sax.SAXException;
* 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() {}
public HtmlMenuWrapperImage(String resourceName, String menuName, HttpServletRequest request, HttpServletResponse response)
public HtmlMenuWrapperImage(String resourceName, String menuName, HttpServletRequest request, HttpServletResponse response)
throws IOException, SAXException, ParserConfigurationException {
super(resourceName, menuName, request, response);
}
@@ -53,10 +53,10 @@ public class HtmlMenuWrapperImage extends HtmlMenuWrapper {
public MenuStringRenderer getMenuRenderer() {
return new HtmlMenuRendererImage(request, response);
}
public void init(String resourceName, String menuName, HttpServletRequest request, HttpServletResponse 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);
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -101,14 +101,14 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
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 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
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 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
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 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
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 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
writer.append("\"");
}
writer.append(">");
// the text
writer.append(labelText);
// close tag
writer.append("</span>");
} else {
writer.append(labelText);
}
appendWhitespace(writer);
}
@@ -456,7 +456,7 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
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);
@@ -464,7 +464,7 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
writer.append("<form method=\"post\"");
writer.append(" action=\"");
// note that this passes null for the parameterList on purpose so they won't be put into the URL
WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), null, link.getPrefix(context),
WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), null, link.getPrefix(context),
link.getFullPath(), link.getSecure(), link.getEncode(), request, response, context);
writer.append("\"");
@@ -487,10 +487,10 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
writer.append(parameter.getValue(context));
writer.append("\" type=\"hidden\"/>");
}
writer.append("</form>");
}
writer.append("<a");
String id = link.getId(context);
if (UtilValidate.isNotEmpty(id)) {
@@ -522,13 +522,13 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
writer.append(uniqueItemName);
writer.append(".submit()");
} else {
WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), link.getParameterList(), link.getPrefix(context),
WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), link.getParameterList(), link.getPrefix(context),
link.getFullPath(), link.getSecure(), link.getEncode(), request, response, context);
}
writer.append("\"");
}
writer.append(">");
// the text
ModelScreenWidget.Image img = link.getImage();
if (img == null) {
@@ -536,10 +536,10 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
} else {
renderImage(writer, context, img);
}
// close tag
writer.append("</a>");
appendWhitespace(writer);
}
@@ -586,7 +586,7 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
writer.append(alt);
writer.append("\"");
}
writer.append(" src=\"");
String urlMode = image.getUrlMode();
boolean fullPath = false;
@@ -613,9 +613,9 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
} else {
writer.append(src);
}
writer.append("\"/>");
appendWhitespace(writer);
}
@@ -624,9 +624,9 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
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 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
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 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
if (content.xmlEscape()) {
renderedContent = UtilFormatOut.encodeXmlValue(renderedContent);
}
writer.append(renderedContent);
}
@@ -711,7 +711,7 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
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 class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
}
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 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
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 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
if (UtilValidate.isNotEmpty(editRequest) && "true".equals(enableEditValue)) {
writer.append("<div");
writer.append(" class=\"" + editContainerStyle + "\"> ");
appendWhitespace(writer);
}
}
@@ -804,7 +804,7 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri
if (content.xmlEscape()) {
renderedContent = UtilFormatOut.encodeXmlValue(renderedContent);
}
writer.append(renderedContent);
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -43,7 +43,7 @@ import org.ofbiz.widget.tree.TreeStringRenderer;
public class HtmlTreeRenderer extends HtmlWidgetRenderer implements TreeStringRenderer {
ScreenStringRenderer screenStringRenderer = null;
public static final String module = HtmlTreeRenderer.class.getName();
public static final String module = HtmlTreeRenderer.class.getName();
public HtmlTreeRenderer() {}
@@ -77,7 +77,7 @@ public class HtmlTreeRenderer extends HtmlWidgetRenderer implements TreeStringRe
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 @@ public class HtmlTreeRenderer extends HtmlWidgetRenderer implements TreeStringRe
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 @@ public class HtmlTreeRenderer extends HtmlWidgetRenderer implements TreeStringRe
writer.append("\"");
}
writer.append(">");
// the text
writer.append(label.getText(context));
// close tag
writer.append("</span>");
appendWhitespace(writer);
}
@@ -205,7 +205,7 @@ public class HtmlTreeRenderer extends HtmlWidgetRenderer implements TreeStringRe
writer.append(" title=\"");
writer.append(title);
writer.append("\"");
}
}
String targetWindow = link.getTargetWindow(context);
if (UtilValidate.isNotEmpty(targetWindow)) {
writer.append(" target=\"");
@@ -254,7 +254,7 @@ public class HtmlTreeRenderer extends HtmlWidgetRenderer implements TreeStringRe
writer.append("\"");
}
writer.append(">");
// the text
ModelTree.ModelNode.Image img = link.getImage();
if (img == null) {
@@ -330,11 +330,11 @@ public class HtmlTreeRenderer extends HtmlWidgetRenderer implements TreeStringRe
writer.append("\"");
}
writer.append("/>");
}
public ScreenStringRenderer getScreenStringRenderer(Map<String, Object> context) {
ScreenRenderer screenRenderer = (ScreenRenderer)context.get("screens");
ScreenRenderer screenRenderer = (ScreenRenderer)context.get("screens");
if (screenRenderer != null) {
screenStringRenderer = screenRenderer.getScreenStringRenderer();
} else {
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -43,7 +43,7 @@ public class HtmlWidgetRenderer {
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 class HtmlWidgetRenderer {
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;
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -45,18 +45,18 @@ import org.xml.sax.SAXException;
* 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)
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 @@ public class MenuFactory {
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 @@ public class MenuFactory {
}
}
}
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) {
@@ -102,7 +102,7 @@ public class MenuFactory {
return modelMenuMap;
}
public static ModelMenu getMenuFromLocation(String resourceName, String menuName, GenericDelegator delegator, LocalDispatcher dispatcher)
public static ModelMenu getMenuFromLocation(String resourceName, String menuName, GenericDelegator delegator, LocalDispatcher dispatcher)
throws IOException, SAXException, ParserConfigurationException {
Map<String, ModelMenu> modelMenuMap = menuLocationCache.get(resourceName);
if (modelMenuMap == null) {
@@ -113,7 +113,7 @@ public class MenuFactory {
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 @@ public class MenuFactory {
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;
}
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License") throws IOException ; you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -47,7 +47,7 @@ import freemarker.template.TransformControl;
//import com.clarkware.profiler.Profiler;
/**
* MenuWrapTransform - Freemarker Transform for URLs (links)
*
*
* This is an interactive FreeMarker tranform that allows the user to modify the contents that are placed within it.
*/
public class MenuWrapTransform implements TemplateTransformModel {
@@ -55,7 +55,7 @@ public class MenuWrapTransform implements TemplateTransformModel {
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 class MenuWrapTransform implements TemplateTransformModel {
}
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 @@ public class MenuWrapTransform implements TemplateTransformModel {
String menuStr = menuWrapper.renderMenuString();
out.write(menuStr);
}
};
}
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -100,10 +100,10 @@ public class ModelMenu extends ModelWidget {
* with conditions is not possible.
*/
protected Map<String, ModelMenuItem> menuItemMap = new HashMap<String, ModelMenuItem>();
protected List<ModelMenuAction> actions;
// ===== CONSTRUCTORS =====
/** Default Constructor */
public ModelMenu() {}
@@ -222,7 +222,7 @@ public class ModelMenu extends ModelWidget {
//Debug.logInfo("in ModelMenu, hideIfSelected, val:" + val, module);
if (val != null && val.equalsIgnoreCase("true"))
defaultHideIfSelected = Boolean.TRUE;
else
else
defaultHideIfSelected = Boolean.FALSE;
}
if (this.defaultDisabledTitleStyle == null || menuElement.hasAttribute("default-disabled-title-style"))
@@ -350,7 +350,7 @@ public class ModelMenu extends ModelWidget {
List <GenericValue> portalPages = null;
try {
// first get public pages
EntityCondition cond =
EntityCondition cond =
EntityCondition.makeCondition(UtilMisc.toList(
EntityCondition.makeCondition("ownerUserLoginId", EntityOperator.EQUALS, "_NA_"),
EntityCondition.makeCondition(UtilMisc.toList(
@@ -371,7 +371,7 @@ public class ModelMenu extends ModelWidget {
portalPages.remove(portalPage);
portalPages.add(privatePortalPages.get(0));
}
}
}
// add any other created private pages
cond = EntityCondition.makeCondition(UtilMisc.toList(
EntityCondition.makeCondition("ownerUserLoginId", EntityOperator.EQUALS, userLoginId),
@@ -385,8 +385,8 @@ public class ModelMenu extends ModelWidget {
}
for (GenericValue portalPage : portalPages) {
if (UtilValidate.isNotEmpty(portalPage.getString("portalPageName"))) {
item.setName(portalPage.getString("portalPageId"));
item.setTitle(portalPage.getString("portalPageName"));
item.setName(portalPage.getString("portalPageId"));
item.setTitle(portalPage.getString("portalPageName"));
item.link = new Link(item);
item.link.setTarget("showPortalPage?portalPageId=" + portalPage.getString("portalPageId") + "&parentPortalPageId=" + parentPortalPageId);
item.renderMenuItemString(writer, context, menuStringRenderer);
@@ -484,7 +484,7 @@ public class ModelMenu extends ModelWidget {
public String getBoundaryCommentName() {
return menuLocation + "#" + name;
}
public Interpreter getBshInterpreter(Map<String, Object> context) throws EvalError {
Interpreter bsh = (Interpreter) context.get("bshInterpreter");
if (bsh == null) {
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -63,19 +63,19 @@ public abstract class ModelMenuAction {
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 @@ public abstract class ModelMenuAction {
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 @@ public abstract class ModelMenuAction {
action.runAction(context);
}
}
public static class SetField extends ModelMenuAction {
protected FlexibleMapAccessor<Object> field;
protected FlexibleMapAccessor<Object> fromField;
@@ -121,7 +121,7 @@ public abstract class ModelMenuAction {
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 @@ public abstract class ModelMenuAction {
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 @@ public abstract class ModelMenuAction {
} 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 @@ public abstract class ModelMenuAction {
} else if (!this.valueExdr.isEmpty()) {
newValue = this.valueExdr.expandString(context);
}
} else {
if (!this.fromField.isEmpty()) {
newValue = this.fromField.get(context);
@@ -182,7 +182,7 @@ public abstract class ModelMenuAction {
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 @@ public abstract class ModelMenuAction {
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 @@ public abstract class ModelMenuAction {
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 @@ public abstract class ModelMenuAction {
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 abstract class ModelMenuAction {
}
}
}
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 abstract class ModelMenuAction {
}
}
}
public static class PropertyToField extends ModelMenuAction {
protected FlexibleStringExpander resourceExdr;
protected FlexibleStringExpander propertyExdr;
protected FlexibleMapAccessor<Object> fieldAcsr;
@@ -280,14 +280,14 @@ public abstract class ModelMenuAction {
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,8 +297,8 @@ public abstract class ModelMenuAction {
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
// 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.
value = FlexibleStringExpander.expandString(value, context);
@@ -313,15 +313,15 @@ public abstract class ModelMenuAction {
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,34 +350,34 @@ public abstract class ModelMenuAction {
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();
for (Element fieldMapElement: fieldMapElementList) {
// set the env-name for each field-name, noting that if no field-name is specified it defaults to the env-name
this.fieldMap.put(
FlexibleMapAccessor.getInstance(UtilFormatOut.checkEmpty(fieldMapElement.getAttribute("field-name"), fieldMapElement.getAttribute("env-name"))),
FlexibleMapAccessor.getInstance(UtilFormatOut.checkEmpty(fieldMapElement.getAttribute("field-name"), fieldMapElement.getAttribute("env-name"))),
FlexibleMapAccessor.getInstance(fieldMapElement.getAttribute("env-name")));
}
}
}
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 @@ public abstract class ModelMenuAction {
} 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 @@ public abstract class ModelMenuAction {
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 abstract class ModelMenuAction {
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 abstract class ModelMenuAction {
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 abstract class ModelMenuAction {
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());
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -77,30 +77,30 @@ public class ModelMenuCondition {
if (cond) {
String passStyle = passStyleExdr.expandString(context);
if (UtilValidate.isNotEmpty(passStyle)) {
modelMenuItem.setWidgetStyle(passStyle);
modelMenuItem.setWidgetStyle(passStyle);
}
modelMenuItem.setDisabled(false);
} else {
String failStyle = failStyleExdr.expandString(context);
if (UtilValidate.isNotEmpty(failStyle)) {
modelMenuItem.setDisabledTitleStyle(failStyle);
modelMenuItem.setDisabledTitleStyle(failStyle);
modelMenuItem.setDisabled(true);
cond = true;
}
}
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 @@ public class ModelMenuCondition {
}
return condList;
}
public static MenuCondition readCondition(ModelMenuItem modelMenuItem, Element conditionElement) {
if (conditionElement == null) {
return null;
@@ -142,15 +142,15 @@ public class ModelMenuCondition {
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 @@ public class ModelMenuCondition {
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 @@ public class ModelMenuCondition {
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 @@ public class ModelMenuCondition {
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);
}
@@ -229,7 +229,7 @@ public class ModelMenuCondition {
super(modelMenuItem, condElement);
this.serviceExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("service-name"));
this.actionExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("main-action"));
this.resExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("resource-description"));
this.resExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("resource-description"));
}
public boolean eval(Map<String, Object> context) {
@@ -294,20 +294,20 @@ public class ModelMenuCondition {
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 @@ public class ModelMenuCondition {
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 @@ public class ModelMenuCondition {
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 @@ public class ModelMenuCondition {
return resultBool.booleanValue();
}
}
public static class IfCompare extends MenuCondition {
protected FlexibleMapAccessor<Object> fieldAcsr;
protected FlexibleStringExpander valueExdr;
@@ -392,25 +392,25 @@ public class ModelMenuCondition {
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 @@ public class ModelMenuCondition {
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 @@ public class ModelMenuCondition {
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 @@ public class ModelMenuCondition {
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 @@ public class ModelMenuCondition {
}
// 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 class ModelMenuCondition {
}
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;
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -68,13 +68,13 @@ public class ModelMenuItem {
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 @@ public class ModelMenuItem {
protected List<ModelMenuAction> actions;
protected String align;
protected String alignStyle;
// ===== CONSTRUCTORS =====
/** Default Constructor */
public ModelMenuItem(ModelMenu modelMenu) {
@@ -94,12 +94,12 @@ public class ModelMenuItem {
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 @@ public class ModelMenuItem {
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 class ModelMenuItem {
}
}
public ModelMenuItem addUpdateMenuItem(ModelMenuItem modelMenuItem) {
// not a conditional item, see if a named item exists in Map
@@ -213,11 +213,11 @@ public class ModelMenuItem {
}
public void setDisabled(boolean val) {
this.disabled = val;
this.disabled = val;
}
public boolean getDisabled() {
return this.disabled;
return this.disabled;
}
public void mergeOverrideModelMenuItem(ModelMenuItem overrideMenuItem) {
@@ -247,7 +247,7 @@ public class ModelMenuItem {
}
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 @@ public class ModelMenuItem {
return this.modelMenu.getDefaultDisabledTitleStyle();
}
}
public void setDisabledTitleStyle(String style) {
this.disabledTitleStyle = style;
}
@@ -509,7 +509,7 @@ public class ModelMenuItem {
public Link getLink() {
return this.link;
}
public boolean isSelected(Map<String, Object> context) {
return this.name.equals(modelMenu.getSelectedMenuItemContextFieldName(context));
}
@@ -548,7 +548,7 @@ public class ModelMenuItem {
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 @@ public class ModelMenuItem {
if (simpleEncoder != null) {
txt = simpleEncoder.encode(txt);
}
return txt;
}
@@ -643,7 +643,7 @@ public class ModelMenuItem {
public String getLinkType() {
return this.linkType;
}
public List<WidgetWorker.Parameter> getParameterList() {
return this.parameterList;
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -65,7 +65,7 @@ public class HtmlWidget extends ModelScreenWidget {
/* NOTE: don't use this and the StringHtmlWrapperForFtl or things will be double-encoded
if (object instanceof GenericValue) {
return new GenericValueHtmlWrapperForFtl((GenericValue) object, this);
}*/
}*/
// This StringHtmlWrapperForFtl option seems to be the best option
// and handles most things without causing too many problems
if (object instanceof String) {
@@ -83,11 +83,11 @@ public class HtmlWidget extends ModelScreenWidget {
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 @@ public class HtmlWidget extends ModelScreenWidget {
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,19 +137,19 @@ public class HtmlWidget extends ModelScreenWidget {
// 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
// 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
// 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
// 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)) {
contextMs = MapStack.create(context);
@@ -174,15 +174,15 @@ public class HtmlWidget extends ModelScreenWidget {
}
}
// TODO and NOTE: should get most stuff, but we could support Maps
// 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
// 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 @@ public class HtmlWidget extends ModelScreenWidget {
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 @@ public class HtmlWidget extends ModelScreenWidget {
template = FreeMarkerWorker.getTemplate(location, specialTemplateCache, specialConfig);
}
FreeMarkerWorker.renderTemplate(template, context, writer);
if (insertWidgetBoundaryComments) {
writer.append(HtmlWidgetRenderer.formatBoundaryComment("End", "Template", location));
}
@@ -235,7 +235,7 @@ public class HtmlWidget extends ModelScreenWidget {
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 class HtmlWidget extends ModelScreenWidget {
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 @@ public class HtmlWidget extends ModelScreenWidget {
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 class HtmlWidget extends ModelScreenWidget {
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");
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -53,7 +53,7 @@ import org.w3c.dom.Element;
@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 @@ public class IterateSectionWidget extends ModelScreenWidget {
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 @@ public class IterateSectionWidget extends ModelScreenWidget {
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 @@ public class IterateSectionWidget extends ModelScreenWidget {
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 class IterateSectionWidget extends ModelScreenWidget {
}
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);
@@ -111,7 +111,7 @@ public class IterateSectionWidget extends ModelScreenWidget {
}
List theList = null;
if (obj instanceof Map ) {
Set entrySet = ((Map)obj).entrySet();
Set entrySet = ((Map)obj).entrySet();
Object [] a = entrySet.toArray();
theList = Arrays.asList(a);
isEntrySet = true;
@@ -137,13 +137,13 @@ public class IterateSectionWidget extends ModelScreenWidget {
continue;
}
if (isEntrySet) {
contextMs.put(entryName, ((Map)item).get("value"));
contextMs.put(keyName, ((Map)item).get("key"));
contextMs.put(entryName, ((Map)item).get("value"));
contextMs.put(keyName, ((Map)item).get("key"));
} else {
contextMs.put(entryName, item);
}
contextMs.put("itemIndex", Integer.valueOf(itemIndex));
rowCount++;
for (ModelScreenWidget.Section section: this.sectionList) {
section.renderWidgetString(writer, contextMs, screenStringRenderer);
@@ -157,19 +157,19 @@ public class IterateSectionWidget extends ModelScreenWidget {
if (paginate) {
try {
Integer lastPageNumber = null;
Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
if (globalCtx != null) {
lastPageNumber = (Integer)globalCtx.get("PAGINATOR_NUMBER");
globalCtx.put("PAGINATOR_NUMBER", Integer.valueOf(startPageNumber));
}
renderNextPrev(writer, context);
}
renderNextPrev(writer, context);
if (globalCtx != null) {
globalCtx.put("PAGINATOR_NUMBER", lastPageNumber);
}
} catch (IOException e) {
Debug.logError(e, module);
Debug.logError(e, module);
throw new RuntimeException(e.getMessage());
}
}
@@ -181,15 +181,15 @@ public class IterateSectionWidget extends ModelScreenWidget {
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;
}
@@ -202,7 +202,7 @@ public class IterateSectionWidget extends ModelScreenWidget {
try {
viewSize = Integer.parseInt(val);
} catch (NumberFormatException e) {
viewSize = DEFAULT_PAGE_SIZE;
viewSize = DEFAULT_PAGE_SIZE;
}
}
@@ -240,14 +240,14 @@ public class IterateSectionWidget extends ModelScreenWidget {
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,14 +273,14 @@ public class IterateSectionWidget extends ModelScreenWidget {
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)) {
@@ -290,13 +290,13 @@ public class IterateSectionWidget extends ModelScreenWidget {
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;
Debug.logWarning("TargetService is empty.", module);
return;
}
int viewIndex = -1;
@@ -334,8 +334,8 @@ public class IterateSectionWidget extends ModelScreenWidget {
} catch (Exception e) {
lowIndex = 0;
}
*/
*/
int lowIndex = viewIndex * viewSize;
int highIndex = (viewIndex + 1) * viewSize;
int actualPageSize = this.getActualPageSize();
@@ -366,13 +366,13 @@ public class IterateSectionWidget extends ModelScreenWidget {
linkText.append("VIEW_SIZE_"+ paginatorNumber + "=").append(viewSize).append("&amp;VIEW_INDEX_" + paginatorNumber + "=").append(viewIndex - 1).append("\"");
// make the link
writer.append(rh.makeLink(request, response, linkText.toString(), false, false, false));
writer.append(rh.makeLink(request, response, linkText.toString(), false, false, false));
String previous = UtilProperties.getMessage("CommonUiLabels", "CommonPrevious", (Locale) context.get("locale"));
writer.append(" class=\"buttontext\">[").append(previous).append("]</a>\n");
}
if (listSize > 0) {
Map<String, Integer> messageMap = UtilMisc.toMap("lowCount", Integer.valueOf(lowIndex + 1), "highCount", Integer.valueOf(lowIndex + actualPageSize), "total", Integer.valueOf(listSize));
Map<String, Integer> messageMap = UtilMisc.toMap("lowCount", Integer.valueOf(lowIndex + 1), "highCount", Integer.valueOf(lowIndex + actualPageSize), "total", Integer.valueOf(listSize));
String commonDisplaying = UtilProperties.getMessage("CommonUiLabels", "CommonDisplaying", messageMap, (Locale) context.get("locale"));
writer.append(" <span class=\"tabletext\">").append(commonDisplaying).append("</span> \n");
}
@@ -383,7 +383,7 @@ public class IterateSectionWidget extends ModelScreenWidget {
else linkText.append("&amp;");
if (UtilValidate.isNotEmpty(queryString)) {
linkText.append(queryString).append("&amp;");
}
}
linkText.append("VIEW_SIZE_" + paginatorNumber + "=").append(viewSize).append("&amp;VIEW_INDEX_" + paginatorNumber + "=").append(viewIndex + 1).append("\"");
// make the link
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -75,7 +75,7 @@ public class MacroFormRenderer implements FormStringRenderer {
public static final String module = MacroFormRenderer.class.getName();
private Template macroLibrary;
private Environment environment;
public MacroFormRenderer(String macroLibraryPath, Appendable writer) throws TemplateException, IOException {
macroLibrary = FreeMarkerWorker.getTemplate(macroLibraryPath);
Map<String, Object> input = UtilMisc.toMap("key", null);
@@ -324,11 +324,11 @@ public class MacroFormRenderer implements FormStringRenderer {
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
}
public void renderHyperlinkTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText) {
}
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -61,7 +61,7 @@ public class MacroScreenRenderer implements ScreenStringRenderer {
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);
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -49,7 +49,7 @@ import freemarker.template.TemplateException;
import freemarker.template.utility.StandardCompress;
public class MacroScreenViewHandler extends AbstractViewHandler {
public static final String module = MacroScreenViewHandler.class.getName();
protected ServletContext servletContext = null;
@@ -79,14 +79,14 @@ public class MacroScreenViewHandler extends AbstractViewHandler {
}
boolean compressOutput = "compressed".equals(encoding);
if (!compressOutput && this.servletContext != null) {
compressOutput = "true".equals((String) this.servletContext.getAttribute("compressHTML"));
compressOutput = "true".equals((String) this.servletContext.getAttribute("compressHTML"));
}
if (compressOutput) {
// StandardCompress defaults to a 2k buffer. That could be increased
// 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);
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -52,7 +52,7 @@ public class ModelScreen extends ModelWidget implements Serializable {
protected FlexibleStringExpander transactionTimeoutExdr;
protected Map<String, ModelScreen> modelScreenMap;
protected boolean useCache;
protected ModelScreenWidget.Section section;
// ===== CONSTRUCTORS =====
@@ -75,7 +75,7 @@ public class ModelScreen extends ModelWidget implements Serializable {
this.section = new ModelScreenWidget.Section(this, sectionElement);
this.section.isMainSection = true;
}
public String getSourceLocation() {
return sourceLocation;
}
@@ -263,7 +263,7 @@ public class ModelScreen extends ModelWidget implements Serializable {
}
}
}
public Set<String> getAllRequestsLocationAndUri() throws GeneralException {
Set<String> allRequestNamesIncluded = FastSet.newInstance();
findRequestNamesLinkedtoInWidget(this.section, allRequestNamesIncluded);
@@ -275,7 +275,7 @@ public class ModelScreen extends ModelWidget implements Serializable {
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 @@ public class ModelScreen extends ModelWidget implements Serializable {
}
}
}
/**
* Renders this screen to a String, i.e. in a text format, as defined with the
@@ -335,10 +335,10 @@ public class ModelScreen extends ModelWidget implements Serializable {
* - userLogin (if a user is logged in)
* - autoUserLogin (if a user is automatically logged in, ie no password has been entered)
* - formStringRenderer
* - request, response, session, application (special case, only in HTML contexts, etc)
* - request, response, session, application (special case, only in HTML contexts, etc)
* - delegator, dispatcher, security
* - null (represents a null field value for entity operations)
* - sections (used for decorators to reference the sections to be decorated and render them)
* - sections (used for decorators to reference the sections to be decorated and render them)
* @param screenStringRenderer An implementation of the ScreenStringRenderer
* interface that is responsible for the actual text generation for
* different screen elements; implementing your own makes it possible to
@@ -365,7 +365,7 @@ public class ModelScreen extends ModelWidget implements Serializable {
}
}
}
if (transactionTimeout < 0 && !transactionTimeoutExdr.isEmpty()) {
// no TRANSACTION_TIMEOUT parameter, check screen attribute
String transactionTimeoutStr = transactionTimeoutExdr.expandString(context);
@@ -377,7 +377,7 @@ public class ModelScreen extends ModelWidget implements Serializable {
}
}
}
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 @@ public class ModelScreen extends ModelWidget implements Serializable {
} 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 {
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -74,12 +74,12 @@ public abstract class ModelScreenAction implements Serializable {
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 @@ public abstract class ModelScreenAction implements Serializable {
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 @@ public abstract class ModelScreenAction implements Serializable {
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 @@ public abstract class ModelScreenAction implements Serializable {
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 @@ public abstract class ModelScreenAction implements Serializable {
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 @@ public abstract class ModelScreenAction implements Serializable {
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 @@ public abstract class ModelScreenAction implements Serializable {
this.field.put(context, newValue);
}
}
if (global) {
Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
if (globalCtx != null) {
@@ -234,14 +234,14 @@ public abstract class ModelScreenAction implements Serializable {
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 @@ public abstract class ModelScreenAction implements Serializable {
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 @@ public abstract class ModelScreenAction implements Serializable {
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 @@ public abstract class ModelScreenAction implements Serializable {
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 @@ public abstract class ModelScreenAction implements Serializable {
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 abstract class ModelScreenAction implements Serializable {
}
}
}
public static class PropertyToField extends ModelScreenAction {
protected FlexibleStringExpander resourceExdr;
protected FlexibleStringExpander propertyExdr;
protected FlexibleMapAccessor<Object> fieldAcsr;
@@ -346,7 +346,7 @@ public abstract class ModelScreenAction implements Serializable {
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 @@ public abstract class ModelScreenAction implements Serializable {
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,8 +365,8 @@ public abstract class ModelScreenAction implements Serializable {
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
// 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.
value = FlexibleStringExpander.expandString(value, context);
@@ -381,15 +381,15 @@ public abstract class ModelScreenAction implements Serializable {
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 @@ public abstract class ModelScreenAction implements Serializable {
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 @@ public abstract class ModelScreenAction implements Serializable {
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)) {
@@ -463,17 +463,17 @@ public abstract class ModelScreenAction implements Serializable {
if (autoFieldMap != null) {
serviceContext = this.modelScreen.getDispatcher(context).getDispatchContext().makeValidContext(serviceNameExpanded, ModelService.IN_PARAM, autoFieldMap);
}
}
}
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 @@ public abstract class ModelScreenAction implements Serializable {
String queryStringEncoded = queryString.replaceAll("&", "%26");
context.put("queryStringEncoded", queryStringEncoded);
} catch (PatternSyntaxException e) {
}
}
} else {
@@ -500,12 +500,12 @@ public abstract class ModelScreenAction implements Serializable {
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 abstract class ModelScreenAction implements Serializable {
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 abstract class ModelScreenAction implements Serializable {
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 @@ public abstract class ModelScreenAction implements Serializable {
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 @@ public abstract class ModelScreenAction implements Serializable {
throw new IllegalArgumentException(errMsg);
}
}
}
public static class GetRelated extends ModelScreenAction {
@@ -605,7 +605,7 @@ public abstract class ModelScreenAction implements Serializable {
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"));
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -74,17 +74,17 @@ public class ModelScreenCondition implements Serializable {
}
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 @@ public class ModelScreenCondition implements Serializable {
}
return condList;
}
public static ScreenCondition readCondition(ModelScreen modelScreen, Element conditionElement) {
if (conditionElement == null) {
return null;
@@ -126,15 +126,15 @@ public class ModelScreenCondition implements Serializable {
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 @@ public class ModelScreenCondition implements Serializable {
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 @@ public class ModelScreenCondition implements Serializable {
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 @@ public class ModelScreenCondition implements Serializable {
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 @@ public class ModelScreenCondition implements Serializable {
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 class ModelScreenCondition implements Serializable {
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 @@ public class ModelScreenCondition implements Serializable {
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 @@ public class ModelScreenCondition implements Serializable {
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 @@ public class ModelScreenCondition implements Serializable {
return resultBool.booleanValue();
}
}
public static class IfCompare extends ScreenCondition {
protected FlexibleMapAccessor<Object> fieldAcsr;
protected FlexibleStringExpander valueExdr;
@@ -388,25 +388,25 @@ public class ModelScreenCondition implements Serializable {
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 @@ public class ModelScreenCondition implements Serializable {
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 @@ public class ModelScreenCondition implements Serializable {
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 @@ public class ModelScreenCondition implements Serializable {
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 @@ public class ModelScreenCondition implements Serializable {
}
// 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 class ModelScreenCondition implements Serializable {
}
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);
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -71,17 +71,17 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
throw new RuntimeException(errMsg);
}
}
}
public String getBoundaryCommentName() {
if (isMainSection) {
return modelScreen.getSourceLocation() + "#" + modelScreen.getName();
@@ -257,7 +257,7 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
return name;
}
}
public String rawString() {
return "<section" + (UtilValidate.isNotEmpty(this.name)?" name=\"" + this.name + "\"":"") + ">";
}
@@ -269,7 +269,7 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
throw new RuntimeException(errMsg + e);
}
}
public boolean collapsible() {
return this.collapsible;
}
@@ -428,7 +428,7 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
((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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
}
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
protected FlexibleStringExpander locationExdr;
protected FlexibleStringExpander shareScopeExdr;
protected ModelForm modelForm = null;
public Form(ModelScreen modelScreen, Element formElement) {
super(modelScreen, formElement);
@@ -785,7 +785,7 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
}
((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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
((MapStack) context).pop();
}
}
public ModelForm getModelForm(Map<String, Object> context) {
ModelForm modelForm = null;
String name = this.getName(context);
@@ -829,15 +829,15 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
}
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
protected FlexibleStringExpander nameExdr;
protected FlexibleStringExpander locationExdr;
protected FlexibleStringExpander shareScopeExdr;
public Tree(ModelScreen modelScreen, Element treeElement) {
super(modelScreen, treeElement);
@@ -870,7 +870,7 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
}
((MapStack) context).push();
}
String name = this.getName(context);
String location = this.getLocation(context);
ModelTree modelTree = null;
@@ -889,7 +889,7 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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
@@ -897,17 +897,17 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
treeStringRenderer = new HtmlTreeRenderer();
/*
String renderClassStyle = modelTree.getRenderStyle();
if (UtilValidate.isNotEmpty(renderClassStyle) && renderClassStyle.equals("simple"))
if (UtilValidate.isNotEmpty(renderClassStyle) && renderClassStyle.equals("simple"))
treeStringRenderer = new HtmlTreeRenderer();
else
treeStringRenderer = new HtmlTreeExpandCollapseRenderer();
*/
*/
}
// still null, throw an error
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
((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 abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 abstract class ModelScreenWidget extends ModelWidget implements Serializa
}
public static class Content extends ModelScreenWidget {
protected FlexibleStringExpander contentId;
protected FlexibleStringExpander editRequest;
protected FlexibleStringExpander editContainerStyle;
@@ -1007,7 +1007,7 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
protected String width;
protected String height;
protected String border;
public Content(ModelScreen modelScreen, Element subContentElement) {
super(modelScreen, subContentElement);
@@ -1067,13 +1067,13 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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)
if (UtilValidate.isNotEmpty(mimeTypeId)
&& ((mimeTypeId.indexOf("application") >= 0) || (mimeTypeId.indexOf("image")) >= 0) ) {
screenStringRenderer.renderContentFrame(writer, context, this);
} else {
@@ -1093,44 +1093,44 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
}
}
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
protected FlexibleStringExpander editContainerStyle;
protected FlexibleStringExpander enableEditName;
protected boolean xmlEscape = false;
public SubContent(ModelScreen modelScreen, Element subContentElement) {
super(modelScreen, subContentElement);
@@ -1170,27 +1170,27 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
}
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
}
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 abstract class ModelScreenWidget extends ModelWidget implements Serializa
public String getLinkType() {
return this.linkType;
}
public List<WidgetWorker.Parameter> getParameterList() {
return this.parameterList;
}
@@ -1462,7 +1462,7 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
setId(imageElement.getAttribute("id"));
setStyle(imageElement.getAttribute("style"));
setWidth(imageElement.getAttribute("width"));
setHeight(imageElement.getAttribute("height"));
setHeight(imageElement.getAttribute("height"));
setBorder(imageElement.getAttribute("border"));
setAlt(imageElement.getAttribute("alt"));
setUrlMode(UtilFormatOut.checkEmpty(imageElement.getAttribute("url-mode"), "content"));
@@ -1477,15 +1477,15 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 abstract class ModelScreenWidget extends ModelWidget implements Serializa
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 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa
String altAttr = UtilFormatOut.checkNull(val);
this.alt = FlexibleStringExpander.getInstance(altAttr);
}
public void setUrlMode(String val) {
if (UtilValidate.isEmpty(val)) {
this.urlMode = "content";
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -44,7 +44,7 @@ import org.xml.sax.SAXException;
* 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 @@ public class ScreenFactory {
}
return true;
}
public static String getResourceNameFromCombined(String combinedName) {
// split out the name on the last "#"
int numSignIndex = combinedName.lastIndexOf("#");
@@ -73,7 +73,7 @@ public class ScreenFactory {
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,15 +86,15 @@ public class ScreenFactory {
String screenName = combinedName.substring(numSignIndex + 1);
return screenName;
}
public static ModelScreen getScreenFromLocation(String combinedName)
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)
public static ModelScreen getScreenFromLocation(String resourceName, String screenName)
throws IOException, SAXException, ParserConfigurationException {
Map<String, ModelScreen> modelScreenMap = getScreensFromLocation(resourceName);
ModelScreen modelScreen = modelScreenMap.get(screenName);
@@ -104,7 +104,7 @@ public class ScreenFactory {
return modelScreen;
}
public static Map<String, ModelScreen> getScreensFromLocation(String resourceName)
public static Map<String, ModelScreen> getScreensFromLocation(String resourceName)
throws IOException, SAXException, ParserConfigurationException {
Map<String, ModelScreen> modelScreenMap = screenLocationCache.get(resourceName);
if (modelScreenMap == null) {
@@ -116,7 +116,7 @@ public class ScreenFactory {
if (loader == null) {
loader = ScreenFactory.class.getClassLoader();
}
URL screenFileUrl = null;
screenFileUrl = FlexibleLocation.resolveLocation(resourceName, loader);
if (screenFileUrl == null) {
@@ -130,26 +130,26 @@ public class ScreenFactory {
}
}
}
if (modelScreenMap == null) {
throw new IllegalArgumentException("Could not find screen file with name [" + resourceName + "]");
}
return modelScreenMap;
}
public static ModelScreen getScreenFromWebappContext(String resourceName, String screenName, HttpServletRequest request)
public static ModelScreen getScreenFromWebappContext(String resourceName, String screenName, HttpServletRequest request)
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 @@ public class ScreenFactory {
}
}
}
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) {
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -35,7 +35,7 @@ public class ScreenRenderException extends GeneralException {
}
public ScreenRenderException(Throwable nested) {
super(nested);
super(nested);
}
public ScreenRenderException(String str) {
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -66,21 +66,21 @@ import freemarker.ext.servlet.HttpSessionHashModel;
public class ScreenRenderer {
public static final String module = ScreenRenderer.class.getName();
protected Appendable writer;
protected MapStack<String> context;
protected ScreenStringRenderer screenStringRenderer;
public ScreenRenderer(Appendable writer, MapStack<String> context, ScreenStringRenderer screenStringRenderer) {
this.writer = writer;
this.context = context;
if (this.context == null) this.context = MapStack.create();
this.screenStringRenderer = screenStringRenderer;
}
/**
* Renders the named screen using the render environment configured when this ScreenRenderer was created.
*
*
* @param combinedName A combination of the resource name/location for the screen XML file and the name of the screen within that file, separated by a pound sign ("#"). This is the same format that is used in the view-map elements on the controller.xml file.
* @throws IOException
* @throws SAXException
@@ -95,7 +95,7 @@ public class ScreenRenderer {
/**
* Renders the named screen using the render environment configured when this ScreenRenderer was created.
*
*
* @param resourceName The name/location of the resource to use, can use "component://[component-name]/" and "ofbiz://" and other special OFBiz style URLs
* @param screenName The name of the screen within the XML file specified by the resourceName.
* @throws IOException
@@ -109,7 +109,7 @@ public class ScreenRenderer {
// then try to get an already built screen output from the cache:
// 1) if we find it then we get it and attach it to the passed in writer
// 2) if we can't find one, we create a new StringWriter,
// and pass it to the renderScreenString;
// and pass it to the renderScreenString;
// then we wrap its content and put it in the cache;
// and we attach it to the passed in writer
WidgetContextCacheKey wcck = new WidgetContextCacheKey(context);
@@ -158,11 +158,11 @@ public class ScreenRenderer {
context.put("userLogin", userLogin);
context.put("nowTimestamp", UtilDateTime.nowTimestamp());
}
/**
* This method populates the context for this ScreenRenderer based on the HTTP Request and Response objects and the ServletContext.
* It leverages various conventions used in other places, namely the ControlServlet and so on, of OFBiz to get the different resources needed.
*
*
* @param request
* @param response
* @param servletContext
@@ -176,12 +176,12 @@ public class ScreenRenderer {
// attribute names to skip for session and application attributes; these are all handled as special cases, duplicating results and causing undesired messages
Set<String> attrNamesToSkip = UtilMisc.toSet("delegator", "dispatcher", "security", "webSiteId");
Map<String, Object> parameterMap = UtilHttp.getCombinedMap(request, attrNamesToSkip);
Map<String, Object> parameterMap = UtilHttp.getCombinedMap(request, attrNamesToSkip);
GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
populateBasicContext(context, screens, parameterMap, (GenericDelegator) request.getAttribute("delegator"),
(LocalDispatcher) request.getAttribute("dispatcher"), (Security) request.getAttribute("security"),
(LocalDispatcher) request.getAttribute("dispatcher"), (Security) request.getAttribute("security"),
UtilHttp.getLocale(request), userLogin);
context.put("autoUserLogin", session.getAttribute("autoUserLogin"));
@@ -193,7 +193,7 @@ public class ScreenRenderer {
// set up the user's time zone
context.put("timeZone", UtilHttp.getTimeZone(request));
// ========== setup values that are specific to OFBiz webapps
context.put("request", request);
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -38,7 +38,7 @@ import org.ofbiz.widget.text.TextFormRenderer;
import org.ofbiz.widget.text.TextScreenRenderer;
public class ScreenTextViewHandler extends AbstractViewHandler {
public static final String module = ScreenTextViewHandler.class.getName();
protected ServletContext servletContext = null;
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -49,17 +49,17 @@ import freemarker.template.utility.StandardCompress;
public class ScreenWidgetViewHandler extends AbstractViewHandler {
public static final String module = ScreenWidgetViewHandler.class.getName();
protected ServletContext servletContext = null;
protected HtmlScreenRenderer htmlScreenRenderer = new HtmlScreenRenderer();
/**
* @see org.ofbiz.webapp.view.ViewHandler#init(javax.servlet.ServletContext)
*/
public void init(ServletContext context) throws ViewHandlerException {
this.servletContext = context;
}
/**
* @see org.ofbiz.webapp.view.ViewHandler#render(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@@ -88,7 +88,7 @@ public class ScreenWidgetViewHandler extends AbstractViewHandler {
// to speed up output.
writer = new StandardCompress().getWriter(writer, null);
}
ScreenRenderer screens = new ScreenRenderer(writer, null, htmlScreenRenderer);
screens.populateContextForRequest(request, response, servletContext);
// this is the object used to render forms from their definitions
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -37,9 +37,9 @@ import org.ofbiz.widget.screen.ScreenWidgetViewHandler;
import org.ofbiz.widget.xml.XmlFormRenderer;
public class ScreenXmlViewHandler extends ScreenWidgetViewHandler {
public static final String module = ScreenXmlViewHandler.class.getName();
public void render(String name, String page, String info, String contentType, String encoding, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException {
Writer writer = null;
try {
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -58,7 +58,7 @@ import org.ofbiz.widget.form.ModelFormField.TextareaField;
public class TextFormRenderer implements FormStringRenderer {
public static final String module = TextFormRenderer.class.getName();
HttpServletRequest request;
HttpServletResponse response;
@@ -290,11 +290,11 @@ public class TextFormRenderer implements FormStringRenderer {
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
}
public void renderHyperlinkTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText) {
}
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -79,13 +79,13 @@ public class ModelTree extends ModelWidget {
protected String defaultEntityName;
protected String defaultPkName;
protected boolean forceChildCheck;
// ===== CONSTRUCTORS =====
/** Default Constructor */
/** XML Constructor */
public ModelTree() {}
public ModelTree(Element treeElement, GenericDelegator delegator, LocalDispatcher dispatcher) {
super(treeElement);
this.rootNodeName = treeElement.getAttribute("root-node-name");
@@ -124,13 +124,13 @@ public class ModelTree extends ModelWidget {
nodeList.add(node);
nodeMap.put(nodeName,node);
}
if (nodeList.size() == 0) {
throw new IllegalArgumentException("No node elements found for the tree definition with name: " + this.name);
}
}
public void setDefaultEntityName(String name) {
String nm = name;
if (UtilValidate.isEmpty(nm)) {
@@ -143,15 +143,15 @@ public class ModelTree extends ModelWidget {
this.defaultPkName = modelField.getName();
}
}
public String getDefaultEntityName() {
return this.defaultEntityName;
}
public String getDefaultPkName() {
return this.defaultPkName;
}
public String getRootNodeName() {
return rootNodeName;
}
@@ -159,15 +159,15 @@ public class ModelTree extends ModelWidget {
public String getWrapStyle(Map<String, Object> context) {
return this.defaultWrapStyleExdr.expandString(context);
}
public int getOpenDepth() {
return openDepth;
}
public int getPostTrailOpenDepth() {
return postTrailOpenDepth;
}
public String getExpandCollapseRequest(Map<String, Object> context) {
String expColReq = this.expandCollapseRequestExdr.expandString(context);
if (UtilValidate.isEmpty(expColReq)) {
@@ -176,24 +176,24 @@ public class ModelTree extends ModelWidget {
int pos = s1.lastIndexOf("/");
if (pos >= 0)
expColReq = s1.substring(pos + 1);
else
else
expColReq = s1;
}
return expColReq;
}
public String getTrailName(Map<String, Object> context) {
return this.trailNameExdr.expandString(context);
}
public String getBoundaryCommentName() {
return treeLocation + "#" + name;
}
public void setTreeLocation(String treeLocation) {
this.treeLocation = treeLocation;
}
/**
* Renders this tree to a String, i.e. in a text format, as defined with the
* TreeStringRenderer implementation.
@@ -225,7 +225,7 @@ public class ModelTree extends ModelWidget {
trail = StringUtil.split(treeString, "|");
if (trail == null || trail.size() == 0)
throw new RuntimeException("Tree 'trail' value is empty.");
context.put("rootEntityId", trail.get(0));
context.put(defaultPkName, trail.get(0));
} else {
@@ -255,7 +255,7 @@ public class ModelTree extends ModelWidget {
public String getRenderStyle() {
return this.defaultRenderStyle;
}
public static class ModelNode {
@@ -287,48 +287,48 @@ public class ModelTree extends ModelWidget {
this.expandCollapseStyle = nodeElement.getAttribute("expand-collapse-style");
this.wrapStyleExdr = FlexibleStringExpander.getInstance(nodeElement.getAttribute("wrap-style"));
this.renderStyle = nodeElement.getAttribute("render-style");
this.entryName = UtilFormatOut.checkEmpty(nodeElement.getAttribute("entry-name"), null);
this.entryName = UtilFormatOut.checkEmpty(nodeElement.getAttribute("entry-name"), null);
setEntityName(nodeElement.getAttribute("entity-name"));
if (this.pkName == null || nodeElement.hasAttribute("join-field-name"))
this.pkName = nodeElement.getAttribute("join-field-name");
Element actionElement = UtilXml.firstChildElement(nodeElement, "entity-one");
if (actionElement != null) {
actions.add(new ModelTreeAction.EntityOne(this, actionElement));
}
actionElement = UtilXml.firstChildElement(nodeElement, "service");
if (actionElement != null) {
actions.add(new ModelTreeAction.Service(this, actionElement));
}
actionElement = UtilXml.firstChildElement(nodeElement, "script");
if (actionElement != null) {
actions.add(new ModelTreeAction.Script(this, actionElement));
}
Element screenElement = UtilXml.firstChildElement(nodeElement, "include-screen");
if (screenElement != null) {
this.screenNameExdr = FlexibleStringExpander.getInstance(screenElement.getAttribute("name"));
this.screenLocationExdr = FlexibleStringExpander.getInstance(screenElement.getAttribute("location"));
this.shareScope = screenElement.getAttribute("share-scope");
}
Element labelElement = UtilXml.firstChildElement(nodeElement, "label");
if (labelElement != null) {
this.label = new Label(labelElement);
}
Element linkElement = UtilXml.firstChildElement(nodeElement, "link");
if (linkElement != null) {
this.link = new Link(linkElement);
}
Element imageElement = UtilXml.firstChildElement(nodeElement, "image");
if (imageElement != null) {
this.image = new Image(imageElement);
}
/* there are situations in which nothing should be displayed
if (screenElement == null && labelElement == null && linkElement == null) {
throw new IllegalArgumentException("Neither 'screen' nor 'label' nor 'link' found for the node definition with name: " + this.name);
@@ -346,10 +346,10 @@ public class ModelTree extends ModelWidget {
ModelSubNode subNode = new ModelSubNode(subNodeElementEntry, this);
subNodeList.add(subNode);
}
}
public void renderNodeString(Appendable writer, Map<String, Object> context,
TreeStringRenderer treeStringRenderer, int depth)
throws IOException, GeneralException {
@@ -415,7 +415,7 @@ public class ModelTree extends ModelWidget {
newContext.push();
String nodeEntryName = node.getEntryName();
if (UtilValidate.isNotEmpty(nodeEntryName)) {
newContext.put(nodeEntryName, val);
newContext.put(nodeEntryName, val);
} else {
newContext.putAll(val);
}
@@ -433,7 +433,7 @@ public class ModelTree extends ModelWidget {
String errMsg = "Error rendering included label with name ["
+ name + "] : " + e.toString();
Debug.logError(e, errMsg, module);
throw new RuntimeException(errMsg);
throw new RuntimeException(errMsg);
} catch (SAXException e) {
String errMsg = "Error rendering included label with name ["
+ name + "] : " + e.toString();
@@ -494,7 +494,7 @@ public class ModelTree extends ModelWidget {
if (obj != null)
nodeCount = (Long)obj;
} catch (GenericEntityException e) {
Debug.logError(e, module);
Debug.logError(e, module);
throw new RuntimeException(e.getMessage());
}
}
@@ -581,37 +581,37 @@ public class ModelTree extends ModelWidget {
rStyle = modelTree.getRenderStyle();
return rStyle;
}
public boolean isExpandCollapse() {
boolean isExpCollapse = false;
String rStyle = getRenderStyle();
if (rStyle != null && rStyle.equals("expand-collapse"))
isExpCollapse = true;
return isExpCollapse;
}
public boolean isFollowTrail() {
boolean isFollowTrail = false;
String rStyle = getRenderStyle();
if (rStyle != null && (rStyle.equals("follow-trail") || rStyle.equals("show-peers") || rStyle.equals("follow-trail"))) {
isFollowTrail = true;
}
return isFollowTrail;
}
public boolean isRootNode() {
return name.equals(modelTree.getRootNodeName());
}
public boolean showPeers(int currentDepth, Map<String, Object> context) {
int trailSize = 0;
List trail = UtilGenerics.checkList(context.get("targetNodeTrail"));
int openDepth = modelTree.getOpenDepth();
int postTrailOpenDepth = modelTree.getPostTrailOpenDepth();
if (trail != null) trailSize = trail.size();
boolean showPeers = false;
String rStyle = getRenderStyle();
if (rStyle == null) {
@@ -626,10 +626,10 @@ public class ModelTree extends ModelWidget {
int depthAfterTrail = currentDepth - trailSize;
if (depthAfterTrail >= 0 && depthAfterTrail <= postTrailOpenDepth) showPeers = true;
}
return showPeers;
}
public String getExpandCollapseStyle() {
return expandCollapseStyle;
}
@@ -641,11 +641,11 @@ public class ModelTree extends ModelWidget {
}
return val;
}
public ModelTree getModelTree() {
return this.modelTree;
}
public void setEntityName(String name) {
this.entityName = name;
if (UtilValidate.isNotEmpty(this.entityName)) {
@@ -658,7 +658,7 @@ public class ModelTree extends ModelWidget {
}
}
}
public String getEntityName() {
if (UtilValidate.isNotEmpty(this.entityName)) {
return this.entityName;
@@ -666,7 +666,7 @@ public class ModelTree extends ModelWidget {
return this.modelTree.getDefaultEntityName();
}
}
public String getPkName() {
if (UtilValidate.isNotEmpty(this.pkName)) {
return this.pkName;
@@ -674,85 +674,85 @@ public class ModelTree extends ModelWidget {
return this.modelTree.getDefaultPkName();
}
}
public void setPkName(String pkName) {
this.pkName = pkName;
}
public static class ModelSubNode {
protected ModelNode rootNode;
protected FlexibleStringExpander nodeNameExdr;
protected List<ModelTreeAction> actions = FastList.newInstance();
protected ListIterator<? extends Map<String, ? extends Object>> listIterator;
public ModelSubNode() {}
public ModelSubNode(Element nodeElement, ModelNode modelNode) {
this.rootNode = modelNode;
this.nodeNameExdr = FlexibleStringExpander.getInstance(nodeElement.getAttribute("node-name"));
Element actionElement = UtilXml.firstChildElement(nodeElement, "entity-and");
if (actionElement != null) {
actions.add(new ModelTreeAction.EntityAnd(this, actionElement));
}
actionElement = UtilXml.firstChildElement(nodeElement, "service");
if (actionElement != null) {
actions.add(new ModelTreeAction.Service(this, actionElement));
}
actionElement = UtilXml.firstChildElement(nodeElement, "entity-condition");
if (actionElement != null) {
actions.add(new ModelTreeAction.EntityCondition(this, actionElement));
}
actionElement = UtilXml.firstChildElement(nodeElement, "script");
if (actionElement != null) {
actions.add(new ModelTreeAction.Script(this, actionElement));
}
}
public ModelTree.ModelNode getNode() {
return this.rootNode;
}
public String getNodeName(Map<String, Object> context) {
return this.nodeNameExdr.expandString(context);
}
public List<ModelTreeAction> getActions() {
return actions;
}
public void setListIterator(ListIterator<? extends Map<String, ? extends Object>> iter) {
listIterator = iter;
}
public ListIterator<? extends Map<String, ? extends Object>> getListIterator() {
return listIterator;
}
}
public static class Label {
protected FlexibleStringExpander textExdr;
protected FlexibleStringExpander idExdr;
protected FlexibleStringExpander styleExdr;
public Label(Element labelElement) {
// put the text attribute first, then the pcdata under the element, if both are there of course
String textAttr = UtilFormatOut.checkNull(labelElement.getAttribute("text"));
String pcdata = UtilFormatOut.checkNull(UtilXml.elementValue(labelElement));
this.textExdr = FlexibleStringExpander.getInstance(textAttr + pcdata);
this.idExdr = FlexibleStringExpander.getInstance(labelElement.getAttribute("id"));
this.styleExdr = FlexibleStringExpander.getInstance(labelElement.getAttribute("style"));
}
public void renderLabelString(Appendable writer, Map<String, Object> context, TreeStringRenderer treeStringRenderer) {
try {
treeStringRenderer.renderLabel(writer, context, this);
@@ -762,7 +762,7 @@ public class ModelTree extends ModelWidget {
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");
@@ -771,17 +771,17 @@ public class ModelTree extends ModelWidget {
}
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 static class Link {
protected FlexibleStringExpander textExdr;
protected FlexibleStringExpander idExdr;
@@ -796,7 +796,7 @@ public class ModelTree extends ModelWidget {
protected boolean fullPath = false;
protected boolean secure = false;
protected boolean encode = false;
public Link() {
setText(null);
setId(null);
@@ -813,7 +813,7 @@ public class ModelTree extends ModelWidget {
}
public Link(Element linkElement) {
setText(linkElement.getAttribute("text"));
setId(linkElement.getAttribute("id"));
setStyle(linkElement.getAttribute("style"));
@@ -830,9 +830,9 @@ public class ModelTree extends ModelWidget {
if (imageElement != null) {
this.image = new Image(imageElement);
}
}
public void renderLinkString(Appendable writer, Map<String, Object> context, TreeStringRenderer treeStringRenderer) {
try {
treeStringRenderer.renderLink(writer, context, this);
@@ -842,7 +842,7 @@ public class ModelTree extends ModelWidget {
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");
@@ -851,15 +851,15 @@ public class ModelTree extends ModelWidget {
}
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 getName(Map<String, Object> context) {
return this.nameExdr.expandString(context);
}
@@ -871,7 +871,7 @@ public class ModelTree extends ModelWidget {
}
return title;
}
public String getTarget(Map<String, Object> context) {
StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder");
if (simpleEncoder != null) {
@@ -880,31 +880,31 @@ public class ModelTree extends ModelWidget {
return this.targetExdr.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;
}
@@ -964,7 +964,7 @@ public class ModelTree extends ModelWidget {
public void setImage(Image img) {
this.image = img;
}
}
public static class Image {
@@ -976,7 +976,7 @@ public class ModelTree extends ModelWidget {
protected FlexibleStringExpander heightExdr;
protected FlexibleStringExpander borderExdr;
protected String urlMode;
public Image() {
setSrc(null);
@@ -989,7 +989,7 @@ public class ModelTree extends ModelWidget {
}
public Image(Element imageElement) {
setSrc(imageElement.getAttribute("src"));
setId(imageElement.getAttribute("id"));
setStyle(imageElement.getAttribute("style"));
@@ -997,9 +997,9 @@ public class ModelTree extends ModelWidget {
setHeight(imageElement.getAttribute("height"));
setBorder(UtilFormatOut.checkEmpty(imageElement.getAttribute("border"), "0"));
setUrlMode(UtilFormatOut.checkEmpty(imageElement.getAttribute("url-mode"), "content"));
}
public void renderImageString(Appendable writer, Map<String, Object> context, TreeStringRenderer treeStringRenderer) {
try {
treeStringRenderer.renderImage(writer, context, this);
@@ -1009,15 +1009,15 @@ public class ModelTree extends ModelWidget {
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);
}
@@ -1033,11 +1033,11 @@ public class ModelTree extends ModelWidget {
public String getBorder(Map<String, Object> context) {
return this.borderExdr.expandString(context);
}
public String getUrlMode() {
return this.urlMode;
}
public void setSrc(String val) {
String textAttr = UtilFormatOut.checkNull(val);
this.srcExdr = FlexibleStringExpander.getInstance(textAttr);
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -62,20 +62,20 @@ public abstract class ModelTreeAction {
this.modelNode = modelNode;
this.modelTree = modelNode.getModelTree();
}
public ModelTreeAction(ModelTree.ModelNode.ModelSubNode modelSubNode, Element actionElement) {
if (Debug.verboseOn()) Debug.logVerbose("Reading Tree action with name: " + actionElement.getNodeName(), module);
this.modelSubNode = modelSubNode;
this.modelNode = this.modelSubNode.getNode();
this.modelTree = this.modelNode.getModelTree();
}
public abstract void runAction(Map<String, Object> context);
/*
public static List readSubActions(ModelTree.ModelNode modelNode, Element parentElement) {
List actions = new LinkedList();
List actionElementList = UtilXml.childElementList(parentElement);
Iterator actionElementIter = actionElementList.iterator();
while (actionElementIter.hasNext()) {
@@ -96,25 +96,25 @@ public abstract class ModelTreeAction {
throw new IllegalArgumentException("Action element not supported with name: " + actionElement.getNodeName());
}
}
return actions;
}
*/
public static void runSubActions(List<ModelTreeAction> actions, Map<String, Object> context) {
for (ModelTreeAction action: actions) {
if (Debug.verboseOn()) Debug.logVerbose("Running tree action " + action.getClass().getName(), module);
action.runAction(context);
}
}
public static class SetField extends ModelTreeAction {
protected FlexibleMapAccessor<Object> field;
protected FlexibleMapAccessor<Object> fromField;
protected FlexibleStringExpander valueExdr;
protected FlexibleStringExpander globalExdr;
protected String type;
public SetField(ModelTree.ModelNode modelNode, Element setElement) {
super (modelNode, setElement);
this.field = FlexibleMapAccessor.getInstance(setElement.getAttribute("field"));
@@ -126,12 +126,12 @@ public abstract class ModelTreeAction {
throw new IllegalArgumentException("Cannot specify a from-field [" + setElement.getAttribute("from-field") + "] and a value [" + setElement.getAttribute("value") + "] on the set action in a tree 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.fromField.isEmpty()) {
newValue = this.fromField.get(context);
@@ -146,17 +146,17 @@ public abstract class ModelTreeAction {
Debug.logError(e, errMsg, module);
throw new IllegalArgumentException(errMsg);
}
}
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) {
@@ -164,20 +164,20 @@ public abstract class ModelTreeAction {
}
}
}
public static class Script extends ModelTreeAction {
protected String location;
public Script(ModelTree.ModelNode modelNode, Element scriptElement) {
super (modelNode, scriptElement);
this.location = scriptElement.getAttribute("location");
}
public Script(ModelTree.ModelNode.ModelSubNode modelSubNode, Element scriptElement) {
super (modelSubNode, scriptElement);
this.location = scriptElement.getAttribute("location");
}
public void runAction(Map<String, Object> context) {
if (location.endsWith(".bsh")) {
try {
@@ -214,19 +214,19 @@ public abstract class ModelTreeAction {
protected FlexibleStringExpander resultMapValueNameExdr;
protected FlexibleStringExpander valueNameExdr;
protected Map<FlexibleMapAccessor<Object>, Object> fieldMap;
public Service(ModelTree.ModelNode modelNode, Element serviceElement) {
super (modelNode, serviceElement);
initService(serviceElement);
}
public Service(ModelTree.ModelNode.ModelSubNode modelSubNode, Element serviceElement) {
super (modelSubNode, serviceElement);
initService(serviceElement);
}
public void initService( Element serviceElement ) {
this.serviceNameExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("service-name"));
this.resultMapNameAcsr = FlexibleMapAccessor.getInstance(serviceElement.getAttribute("result-map"));
if (this.resultMapNameAcsr.isEmpty()) this.resultMapNameAcsr = FlexibleMapAccessor.getInstance(serviceElement.getAttribute("result-map-name"));
@@ -240,16 +240,16 @@ public abstract class ModelTreeAction {
if (this.valueNameExdr.isEmpty()) this.valueNameExdr = FlexibleStringExpander.getInstance(serviceElement.getAttribute("value-name"));
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);
boolean autoFieldMapBool = !"false".equals(autoFieldMapString);
try {
Map<String, Object> serviceContext = null;
if (autoFieldMapBool) {
@@ -257,13 +257,13 @@ public abstract class ModelTreeAction {
} else {
serviceContext = FastMap.newInstance();
}
if (this.fieldMap != null) {
EntityFinderUtil.expandFieldMapToContext(this.fieldMap, context, serviceContext);
}
Map<String, Object> result = this.modelTree.getDispatcher().runSync(serviceNameExpanded, serviceContext);
if (!this.resultMapNameAcsr.isEmpty()) {
this.resultMapNameAcsr.put(context, result);
String queryString = (String)result.get("queryString");
@@ -274,7 +274,7 @@ public abstract class ModelTreeAction {
String queryStringEncoded = queryString.replaceAll("&", "%26");
context.put("queryStringEncoded", queryStringEncoded);
} catch (PatternSyntaxException e) {
}
}
} else {
@@ -284,7 +284,7 @@ public abstract class ModelTreeAction {
//String resultMapListIteratorName = resultMapListIteratorNameExdr.expandString(context);
String resultMapValueName = resultMapValueNameExdr.expandString(context);
String valueName = valueNameExdr.expandString(context);
if (this.modelSubNode != null) {
//ListIterator iter = null;
if (UtilValidate.isNotEmpty(resultMapListName)) {
@@ -318,17 +318,17 @@ public abstract class ModelTreeAction {
public static class EntityOne extends ModelTreeAction {
protected PrimaryKeyFinder finder;
String valueName;
public EntityOne(ModelTree.ModelNode modelNode, Element entityOneElement) {
super (modelNode, entityOneElement);
this.valueName = UtilFormatOut.checkEmpty(entityOneElement.getAttribute("value"), entityOneElement.getAttribute("value-name"));
if (UtilValidate.isEmpty(this.valueName)) this.valueName = null;
entityOneElement.setAttribute("value", this.valueName);
finder = new PrimaryKeyFinder(entityOneElement);
}
public void runAction(Map<String, Object> context) {
try {
finder.runFind(context, this.modelTree.getDelegator());
@@ -343,20 +343,20 @@ public abstract class ModelTreeAction {
public static class EntityAnd extends ModelTreeAction {
protected ByAndFinder finder;
String listName;
public EntityAnd(ModelTree.ModelNode.ModelSubNode modelSubNode, Element entityAndElement) {
super (modelSubNode, entityAndElement);
boolean useCache = "true".equalsIgnoreCase(entityAndElement.getAttribute("use-cache"));
Document ownerDoc = entityAndElement.getOwnerDocument();
if (!useCache) UtilXml.addChildElement(entityAndElement, "use-iterator", ownerDoc);
this.listName = UtilFormatOut.checkEmpty(entityAndElement.getAttribute("list"), entityAndElement.getAttribute("list-name"));
this.listName = UtilFormatOut.checkEmpty(entityAndElement.getAttribute("list"), entityAndElement.getAttribute("list-name"));
if (UtilValidate.isEmpty(this.listName)) this.listName = "_LIST_ITERATOR_";
entityAndElement.setAttribute( "list-name", this.listName);
finder = new ByAndFinder(entityAndElement);
}
public void runAction(Map<String, Object> context) {
try {
context.put(this.listName, null);
@@ -382,20 +382,20 @@ public abstract class ModelTreeAction {
public static class EntityCondition extends ModelTreeAction {
ByConditionFinder finder;
String listName;
public EntityCondition(ModelTree.ModelNode.ModelSubNode modelSubNode, Element entityConditionElement) {
super (modelSubNode, entityConditionElement);
Document ownerDoc = entityConditionElement.getOwnerDocument();
boolean useCache = "true".equalsIgnoreCase(entityConditionElement.getAttribute("use-cache"));
if (!useCache) UtilXml.addChildElement(entityConditionElement, "use-iterator", ownerDoc);
this.listName = UtilFormatOut.checkEmpty(entityConditionElement.getAttribute("list"), entityConditionElement.getAttribute("list-name"));
this.listName = UtilFormatOut.checkEmpty(entityConditionElement.getAttribute("list"), entityConditionElement.getAttribute("list-name"));
if (UtilValidate.isEmpty(this.listName)) this.listName = "_LIST_ITERATOR_";
entityConditionElement.setAttribute( "list-name", this.listName);
finder = new ByConditionFinder(entityConditionElement);
}
public void runAction(Map<String, Object> context) {
try {
context.put(this.listName, null);
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -65,17 +65,17 @@ public class ModelTreeCondition {
}
return rootCondition.eval(context);
}
public static abstract class TreeCondition {
protected ModelTree modelTree;
public TreeCondition(ModelTree modelTree, Element conditionElement) {
this.modelTree = modelTree;
}
public abstract boolean eval(Map<String, Object> context);
}
public static List<TreeCondition> readSubConditions(ModelTree modelTree, Element conditionElement) {
List<TreeCondition> condList = FastList.newInstance();
for (Element subElement: UtilXml.childElementList(conditionElement)) {
@@ -83,7 +83,7 @@ public class ModelTreeCondition {
}
return condList;
}
public static TreeCondition readCondition(ModelTree modelTree, Element conditionElement) {
if (conditionElement == null) {
return null;
@@ -114,15 +114,15 @@ public class ModelTreeCondition {
throw new IllegalArgumentException("Condition element not supported with name: " + conditionElement.getNodeName());
}
}
public static class And extends TreeCondition {
protected List<TreeCondition> subConditions;
public And(ModelTree modelTree, Element condElement) {
super (modelTree, condElement);
this.subConditions = readSubConditions(modelTree, condElement);
}
public boolean eval(Map<String, Object> context) {
// return false for the first one in the list that is false, basic and algo
for (TreeCondition subCondition: subConditions) {
@@ -133,15 +133,15 @@ public class ModelTreeCondition {
return true;
}
}
public static class Xor extends TreeCondition {
protected List<TreeCondition> subConditions;
public Xor(ModelTree modelTree, Element condElement) {
super (modelTree, condElement);
this.subConditions = readSubConditions(modelTree, 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;
@@ -158,15 +158,15 @@ public class ModelTreeCondition {
return foundOneTrue;
}
}
public static class Or extends TreeCondition {
protected List<TreeCondition> subConditions;
public Or(ModelTree modelTree, Element condElement) {
super (modelTree, condElement);
this.subConditions = readSubConditions(modelTree, condElement);
}
public boolean eval(Map<String, Object> context) {
// return true for the first one in the list that is true, basic or algo
for (TreeCondition subCondition: subConditions) {
@@ -177,38 +177,38 @@ public class ModelTreeCondition {
return false;
}
}
public static class Not extends TreeCondition {
protected TreeCondition subCondition;
public Not(ModelTree modelTree, Element condElement) {
super (modelTree, condElement);
Element firstChildElement = UtilXml.firstChildElement(condElement);
this.subCondition = readCondition(modelTree, firstChildElement);
}
public boolean eval(Map<String, Object> context) {
return !this.subCondition.eval(context);
}
}
public static class IfHasPermission extends TreeCondition {
protected FlexibleStringExpander permissionExdr;
protected FlexibleStringExpander actionExdr;
public IfHasPermission(ModelTree modelTree, Element condElement) {
super (modelTree, 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
@@ -230,7 +230,7 @@ public class ModelTreeCondition {
protected FlexibleMapAccessor<Object> fieldAcsr;
protected FlexibleStringExpander methodExdr;
protected FlexibleStringExpander classExdr;
public IfValidateMethod(ModelTree modelTree, Element condElement) {
super (modelTree, condElement);
this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field"));
@@ -238,11 +238,11 @@ public class ModelTreeCondition {
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) {
@@ -285,7 +285,7 @@ public class ModelTreeCondition {
return resultBool.booleanValue();
}
}
public static class IfCompare extends TreeCondition {
protected FlexibleMapAccessor<Object> fieldAcsr;
protected FlexibleStringExpander valueExdr;
@@ -293,25 +293,25 @@ public class ModelTreeCondition {
protected String operator;
protected String type;
protected FlexibleStringExpander formatExdr;
public IfCompare(ModelTree modelTree, Element condElement) {
super (modelTree, 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 = "";
@@ -330,11 +330,11 @@ public class ModelTreeCondition {
throw new IllegalArgumentException(fullString.toString());
}
return resultBool.booleanValue();
}
}
public static class IfCompareField extends TreeCondition {
protected FlexibleMapAccessor<Object> fieldAcsr;
protected FlexibleMapAccessor<Object> toFieldAcsr;
@@ -342,26 +342,26 @@ public class ModelTreeCondition {
protected String operator;
protected String type;
protected FlexibleStringExpander formatExdr;
public IfCompareField(ModelTree modelTree, Element condElement) {
super (modelTree, 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 = "";
@@ -380,25 +380,25 @@ public class ModelTreeCondition {
throw new IllegalArgumentException(fullString.toString());
}
return resultBool.booleanValue();
}
}
public static class IfRegexp extends TreeCondition {
static PatternMatcher matcher = new Perl5Matcher();
static PatternCompiler compiler = new Perl5Compiler();
protected FlexibleMapAccessor<Object> fieldAcsr;
protected FlexibleStringExpander exprExdr;
public IfRegexp(ModelTree modelTree, Element condElement) {
super (modelTree, 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);
@@ -419,20 +419,20 @@ public class ModelTreeCondition {
}
// always use an empty string by default
if (fieldString == null) fieldString = "";
return matcher.matches(fieldString, pattern);
}
}
public static class IfEmpty extends TreeCondition {
protected FlexibleMapAccessor<Object> fieldAcsr;
public IfEmpty(ModelTree modelTree, Element condElement) {
super (modelTree, 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);
@@ -440,14 +440,14 @@ public class ModelTreeCondition {
}
public static class IfEntityPermission extends TreeCondition {
protected EntityPermissionChecker permissionChecker;
public IfEntityPermission(ModelTree modelTree, Element condElement) {
super (modelTree, condElement);
this.permissionChecker = new EntityPermissionChecker(condElement);
}
public boolean eval(Map<String, Object> context) {
boolean passed = permissionChecker.runPermissionCheck(context);
return passed;
}
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -44,13 +44,13 @@ import org.xml.sax.SAXException;
* Widget Library - Tree factory class
*/
public class TreeFactory {
public static final String module = TreeFactory.class.getName();
public static final UtilCache<String, Map<String, ModelTree>> treeLocationCache = new UtilCache<String, Map<String, ModelTree>>("widget.tree.locationResource", 0, 0, false);
public static final UtilCache<String, Map<String, ModelTree>> treeWebappCache = new UtilCache<String, Map<String, ModelTree>>("widget.tree.webappResource", 0, 0, false);
public static ModelTree getTreeFromLocation(String resourceName, String treeName, GenericDelegator delegator, LocalDispatcher dispatcher)
public static ModelTree getTreeFromLocation(String resourceName, String treeName, GenericDelegator delegator, LocalDispatcher dispatcher)
throws IOException, SAXException, ParserConfigurationException {
Map<String, ModelTree> modelTreeMap = treeLocationCache.get(resourceName);
if (modelTreeMap == null) {
@@ -61,7 +61,7 @@ public class TreeFactory {
if (loader == null) {
loader = TreeFactory.class.getClassLoader();
}
URL treeFileUrl = null;
treeFileUrl = FlexibleLocation.resolveLocation(resourceName); //, loader);
Document treeFileDoc = UtilXml.readXmlDocument(treeFileUrl, true);
@@ -70,20 +70,20 @@ public class TreeFactory {
}
}
}
ModelTree modelTree = (ModelTree) modelTreeMap.get(treeName);
if (modelTree == null) {
throw new IllegalArgumentException("Could not find tree with name [" + treeName + "] in class resource [" + resourceName + "]");
}
return modelTree;
}
public static ModelTree getTreeFromWebappContext(String resourceName, String treeName, HttpServletRequest request)
public static ModelTree getTreeFromWebappContext(String resourceName, String treeName, HttpServletRequest request)
throws IOException, SAXException, ParserConfigurationException {
String webappName = UtilHttp.getApplicationName(request);
String cacheKey = webappName + "::" + resourceName;
Map<String, ModelTree> modelTreeMap = treeWebappCache.get(cacheKey);
if (modelTreeMap == null) {
synchronized (TreeFactory.class) {
@@ -92,7 +92,7 @@ public class TreeFactory {
ServletContext servletContext = (ServletContext) request.getAttribute("servletContext");
GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
URL treeFileUrl = servletContext.getResource(resourceName);
Document treeFileDoc = UtilXml.readXmlDocument(treeFileUrl, true);
modelTreeMap = readTreeDocument(treeFileDoc, delegator, dispatcher, cacheKey);
@@ -100,14 +100,14 @@ public class TreeFactory {
}
}
}
ModelTree modelTree = (ModelTree) modelTreeMap.get(treeName);
if (modelTree == null) {
throw new IllegalArgumentException("Could not find tree with name [" + treeName + "] in webapp resource [" + resourceName + "] in the webapp [" + webappName + "]");
}
return modelTree;
}
public static Map<String, ModelTree> readTreeDocument(Document treeFileDoc, GenericDelegator delegator, LocalDispatcher dispatcher, String treeLocation) {
Map<String, ModelTree> modelTreeMap = new HashMap<String, ModelTree>();
if (treeFileDoc != null) {
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -57,7 +57,7 @@ import org.ofbiz.widget.form.ModelFormField.TextareaField;
public class XmlFormRenderer implements FormStringRenderer {
public static final String module = XmlFormRenderer.class.getName();
HttpServletRequest request;
HttpServletResponse response;
@@ -328,11 +328,11 @@ public class XmlFormRenderer implements FormStringRenderer {
public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException {
// TODO
}
public void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner) throws IOException {
// TODO
}
public void renderHyperlinkTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText) throws IOException {
}
}