You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by er...@apache.org on 2012/08/07 21:13:05 UTC
svn commit: r1370439 [4/5] - in
/ofbiz/branches/20120329_portletWidget/framework:
base/src/org/ofbiz/base/util/ common/config/ common/data/ common/entitydef/
common/webcommon/WEB-INF/ common/widget/ images/webapp/images/
minilang/src/org/ofbiz/minilang...
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Tue Aug 7 19:13:03 2012
@@ -48,6 +48,7 @@ import org.ofbiz.base.util.UtilFormatOut
import org.ofbiz.base.util.UtilGenerics;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.base.util.UtilURL;// #Eam# portletWidget
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.UtilXml;
import org.ofbiz.base.util.collections.FlexibleMapAccessor;
@@ -67,6 +68,7 @@ import org.ofbiz.service.DispatchContext
import org.ofbiz.service.GenericServiceException;
import org.ofbiz.service.ModelParam;
import org.ofbiz.service.ModelService;
+import org.ofbiz.widget.ModelWidget; // #Eam# portletWidget
import org.ofbiz.widget.WidgetWorker;
import org.ofbiz.widget.form.ModelForm.UpdateArea;
import org.w3c.dom.Element;
@@ -116,6 +118,7 @@ public class ModelFormField {
protected Boolean sortField = null;
protected String headerLink;
protected String headerLinkStyle;
+ protected ShowPortletLink showPortletLink = null;// #Eam# portletWidget
/** On Change Event areas to be updated. */
protected List<UpdateArea> onChangeUpdateAreas;
@@ -204,6 +207,15 @@ public class ModelFormField {
else if ("image".equals(subElementName)) this.fieldInfo = new ImageField(subElement, this);
else if ("container".equals(subElementName)) this.fieldInfo = new ContainerField(subElement, this);
else if ("on-field-event-update-area".equals(subElementName)) addOnEventUpdateArea(new UpdateArea(subElement));
+ // #Bam# portletWidget
+ else if ("show-portlet".equals(subElementName)) {
+ if (this.showPortletLink == null) {
+ this.showPortletLink = new ShowPortletLink(subElement, this);
+ this.fieldInfo = this.showPortletLink;
+ }
+ addShowPortletTolink(subElement, this);
+ }
+ // #Eam# portletWidget
else throw new IllegalArgumentException("The field sub-element with name " + subElementName + " is not supported");
}
}
@@ -215,6 +227,13 @@ public class ModelFormField {
else if ("click".equals(updateArea.getEventType())) addOnClickUpdateArea(updateArea);
}
+ // #Bam# portletWidget
+ public void addShowPortletTolink(Element element, ModelFormField modelFormField) {
+ ShowPortletLink showLink = modelFormField.getShowPortletLink();
+ showLink.addShowPorletTolink(element);
+ }
+ // #Eam# portletWidget
+
protected void addOnChangeUpdateArea(UpdateArea updateArea) {
if (onChangeUpdateAreas == null) onChangeUpdateAreas = FastList.newInstance();
onChangeUpdateAreas.add(updateArea);
@@ -257,6 +276,11 @@ public class ModelFormField {
if (overrideFormField.onChangeUpdateAreas != null) this.onChangeUpdateAreas = overrideFormField.onChangeUpdateAreas;
if (overrideFormField.onClickUpdateAreas != null) this.onClickUpdateAreas = overrideFormField.onClickUpdateAreas;
this.encodeOutput = overrideFormField.encodeOutput;
+ // #Bam# portletWidget
+ if (overrideFormField.showPortletLink != null) {
+ this.showPortletLink = overrideFormField.showPortletLink;
+ }
+ // #Eam# portletWidget
}
public boolean induceFieldInfo(String defaultFieldType) {
@@ -531,6 +555,12 @@ public class ModelFormField {
return onClickUpdateAreas;
}
+ // #Bam# portletWidget
+ public ShowPortletLink getShowPortletLink() {
+ return showPortletLink;
+ }
+ // #Eam# portletWidget
+
public FieldInfo getFieldInfo() {
return fieldInfo;
}
@@ -1277,6 +1307,7 @@ public class ModelFormField {
public static final int PASSWORD = 18;
public static final int IMAGE = 19;
public static final int DISPLAY_ENTITY = 20;
+ public static final int SHOW_PORTLET = 22; // #Eam# portletWidget
// the numbering here represents the priority of the source;
//when setting a new fieldInfo on a modelFormField it will only set
@@ -1310,6 +1341,7 @@ public class ModelFormField {
fieldTypeByName.put("image", Integer.valueOf(19));
fieldTypeByName.put("display-entity", Integer.valueOf(20));
fieldTypeByName.put("container", Integer.valueOf(21));
+ fieldTypeByName.put("show-portlet", Integer.valueOf(22));// #Eam# portletWidget
}
protected int fieldType;
@@ -2392,6 +2424,373 @@ public class ModelFormField {
}
}
+ // #Bam# portletWidget
+ public static class ShowPortletLink extends FieldInfo implements ModelWidget.ShowPortletLink {
+
+ protected FlexibleStringExpander description;
+ protected FlexibleStringExpander imageTitle;
+ protected FlexibleStringExpander alternate;
+ protected FlexibleStringExpander collapseScreenlet;
+ protected FlexibleStringExpander markSelected;
+ protected FlexibleStringExpander image;
+ protected String size;
+ protected List<ShowPortletItem> showPortletItems = FastList.newInstance();
+
+ public String listToString(List<String> list) {
+ String result = "";
+ for(String s : list) {
+ if (UtilValidate.isNotEmpty(s)) {
+ result = result.concat(s).concat(";");
+ }
+ }
+ if (result.endsWith(";"))
+ return result.substring(0, result.length()-1);
+ return result;
+ }
+
+ public ShowPortletLink(Element element, ModelFormField modelFormField) {
+ super(element, modelFormField);
+ }
+
+ public void renderFieldString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException {
+ formStringRenderer.renderShowPortletLink(writer, context, this);
+ }
+
+ public void addShowPorletTolink(Element element) {
+ showPortletItems.add(new ShowPortletItem(element, this));
+ }
+
+ /**
+ * @param string
+ */
+ public void setDescription(String string) {
+ if(UtilValidate.isNotEmpty(string)) {
+ this.description = FlexibleStringExpander.getInstance(string);
+ }
+ }
+
+ /**
+ * @param string
+ */
+ public void setImageTitle(String string) {
+ if(UtilValidate.isNotEmpty(string)) {
+ this.imageTitle = FlexibleStringExpander.getInstance(string);
+ }
+ }
+
+ public List<ShowPortletItem> getShowPortletItems(){
+ return showPortletItems;
+ }
+
+ /**
+ * @param string
+ */
+ public void setAlternate(String string) {
+ if(UtilValidate.isNotEmpty(string)) {
+ this.alternate = FlexibleStringExpander.getInstance(string);
+ }
+ }
+
+ public String getDescription(Map<String, Object> context) {
+ if (UtilValidate.isNotEmpty(description)) {
+ return this.description.expandString(context);
+ }
+ return "";
+ }
+
+ public String getAlternate(Map<String, Object> context) {
+ if (UtilValidate.isNotEmpty(alternate)) {
+ return this.alternate.expandString(context);
+ }
+ return "";
+ }
+
+ public String getImageTitle(Map<String, Object> context) {
+ if (UtilValidate.isNotEmpty(imageTitle)) {
+ return this.imageTitle.expandString(context);
+ }
+ return "";
+ }
+ public String getImage(Map<String, Object> context) {
+ if (UtilValidate.isNotEmpty(imageTitle)) {
+ return this.image.expandString(context);
+ }
+ return "";
+ }
+
+ public String getSize() {
+ return this.size;
+ }
+
+ public String setSize(String size) {
+ return this.size = size;
+ }
+
+ public void setCollapseScreenlet(String collapseScreenlet) {
+ this.collapseScreenlet = FlexibleStringExpander.getInstance(collapseScreenlet);
+ }
+
+ public void setMarkSelected(String markSelected) {
+ this.markSelected = FlexibleStringExpander.getInstance(markSelected);
+ }
+
+ public String getCollapseScreenlet(Map<String, Object> context) {
+ String areaIdValue = "";
+ if (UtilValidate.isNotEmpty(collapseScreenlet)) {
+ areaIdValue = this.collapseScreenlet.expandString(context);
+ }
+ return areaIdValue;
+ }
+
+ public String getMarkSelected(Map<String, Object> context) {
+ String value = "";
+ if (UtilValidate.isNotEmpty(markSelected)) {
+ value = this.markSelected.expandString(context);
+ }
+ return value;
+ }
+ }
+
+ public static class ShowPortletItem implements ModelWidget.ShowPortletItem {
+
+ protected FlexibleStringExpander areaId;
+ protected FlexibleStringExpander target;
+ protected ShowPortletLink showPortletLink;
+ protected FlexibleStringExpander portletId;
+ protected boolean requireConfirmation;
+ protected FlexibleStringExpander confirmationMessage;
+ protected FlexibleStringExpander portalPageId;
+ protected FlexibleStringExpander portletSeqId;
+ protected List<String> formsToSerialize = FastList.newInstance();
+ protected List<WidgetWorker.Parameter> parameterList = FastList.newInstance();
+ protected FlexibleMapAccessor<Map<String, String>> parametersMapAcsr;
+
+ public ShowPortletItem(Element element, ShowPortletLink showPortletLink) {
+ this.showPortletLink = showPortletLink;
+ this.setConfirmationMessage(element.getAttribute("confirmation-message"));
+ this.setRequireConfirmation(("true".equals(element.getAttribute("request-confirmation"))));
+ this.setAreaId(element.getAttribute("area-id"));
+ this.setPortletId(element.getAttribute("portlet-id"));
+ this.setPortalPageId(element.getAttribute("portal-page-id"));
+ this.setPortletSeqId(element.getAttribute("portlet-seq-id"));
+ this.setDescription(element.getAttribute("description"));
+ this.setAlternate(element.getAttribute("alternate"));
+ this.setImageTitle(element.getAttribute("image-title"));
+ this.setTarget(element.getAttribute("target"));
+ this.setImage (element.getAttribute("image-location"));
+ this.parametersMapAcsr = FlexibleMapAccessor.getInstance(element.getAttribute("parameters-map"));
+ this.setSize(element.getAttribute("size"));
+ this.setCollapseScreenlet(element.getAttribute("collapse-screenlet"));
+ this.setMarkSelected(element.getAttribute("mark-selected"));
+
+ List<? extends Element> parameterElementList = UtilXml.childElementList(element, "parameter");
+ for (Element parameterElement: parameterElementList) {
+ this.parameterList.add(new WidgetWorker.Parameter(parameterElement));
+ }
+ List<? extends Element> parametersFroms = UtilXml.childElementList(element, "parameters-form");
+ for (Element parameterForm: parametersFroms) {
+ String formName = parameterForm.getAttribute("form-name");
+ if (UtilValidate.isEmpty(formName)) {
+ formName = this.getModelFormField().getModelForm().getName();
+ }
+ if (!formsToSerialize.contains(formName)) {
+ formsToSerialize.add(formName);
+ }
+ }
+ }
+
+ public ModelFormField getModelFormField() {
+ return showPortletLink.getModelFormField();
+ }
+
+// public void renderFieldString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException {
+// formStringRenderer.renderShowPortletLink(writer, context, this);
+// }
+
+ public List<String> getFormsToSerialize() {
+ return this.formsToSerialize;
+ }
+
+ public String getDescription(Map<String, Object> context) {
+ return showPortletLink.getDescription(context);
+ }
+
+ public String getPortalPageId(Map<String, Object> context) {
+ if (UtilValidate.isNotEmpty(portalPageId)) {
+ return this.portalPageId.expandString(context);
+ }
+ return "";
+ }
+
+ public String getPortletId(Map<String, Object> context) {
+ if (UtilValidate.isNotEmpty(portletId)) {
+ return this.portletId.expandString(context);
+ }
+ return "";
+ }
+
+ public String getPortletSeqId(Map<String, Object> context) {
+ if (UtilValidate.isNotEmpty(portletSeqId)) {
+ return this.portletSeqId.expandString(context);
+ }
+ return "";
+ }
+
+ public String getConfirmationMessage(Map<String, Object> context) {
+ String areaIdValue = "";
+ if (UtilValidate.isNotEmpty(confirmationMessage)) {
+ areaIdValue = this.confirmationMessage.expandString(context);
+ }
+ return areaIdValue;
+ }
+
+ public void setRequireConfirmation(boolean reqConfirm) {
+ requireConfirmation = reqConfirm;
+ }
+
+ public boolean getRequireConfirmation() {
+ return requireConfirmation;
+ }
+
+ public String getAreaId(Map<String, Object> context) {
+ String areaIdValue = "";
+ if (UtilValidate.isNotEmpty(areaId)) {
+ areaIdValue = this.areaId.expandString(context);
+ }
+ return areaIdValue;
+ }
+ public String getCollapseScreenlet(Map<String, Object> context) {
+ return showPortletLink.getCollapseScreenlet(context);
+ }
+
+ public String getAlternate(Map<String, Object> context) {
+ return showPortletLink.getAlternate(context);
+ }
+
+ public String getImageTitle(Map<String, Object> context) {
+ return showPortletLink.getImageTitle(context);
+ }
+
+ public String getTarget(Map<String, Object> context) {
+ if (UtilValidate.isNotEmpty(target)) {
+ return this.target.expandString(context);
+ }
+ return "";
+ }
+
+ public Map<String, String> getParameterMap(Map<String, Object> context) {
+ Map<String, String> fullParameterMap = FastMap.newInstance();
+ Map<String, String> addlParamMap = this.parametersMapAcsr.get(context);
+ if (addlParamMap != null) {
+ fullParameterMap.putAll(addlParamMap);
+ }
+ for (WidgetWorker.Parameter parameter: this.parameterList) {
+ String paramValue = parameter.getValue(context);
+ if (UtilValidate.isNotEmpty(paramValue) || parameter.sendIfEmpty(context)){
+ if ("idDescription".equals(parameter.getName())) {
+ if (UtilValidate.isNotEmpty(paramValue)) {
+ paramValue = UtilURL.removeBadCharForUrl(paramValue);
+ fullParameterMap.put(parameter.getName(), paramValue);
+ }
+ }
+ else {
+ fullParameterMap.put(parameter.getName(), paramValue);
+ }
+ }
+ }
+ return fullParameterMap;
+ }
+
+ public String getImage(Map<String, Object> context) {
+ if (UtilValidate.isNotEmpty(target)) {
+ return this.showPortletLink.image.expandString(context);
+ }
+ return "";
+ }
+
+ public void setImage(String image) {
+ showPortletLink.image = FlexibleStringExpander.getInstance(image);
+ }
+
+ public String getSize() {
+ return showPortletLink.size;
+ }
+
+ public void setSize(String size) {
+ showPortletLink.setSize(size);
+ }
+
+ /**
+ * @param string
+ */
+ public void setAreaId(String areaId) {
+ this.areaId = FlexibleStringExpander.getInstance(areaId);
+ }
+
+ /**
+ * @param string
+ */
+ public void setPortletId(String portletId) {
+ this.portletId = FlexibleStringExpander.getInstance(portletId);
+ }
+
+ /**
+ * @param string
+ */
+ public void setPortletSeqId(String portletSeqId) {
+ this.portletSeqId = FlexibleStringExpander.getInstance(portletSeqId);
+ }
+
+ public void setCollapseScreenlet(String collapseScreenlet) {
+ if(UtilValidate.isEmpty(showPortletLink.collapseScreenlet) && UtilValidate.isNotEmpty(collapseScreenlet))
+ showPortletLink.setCollapseScreenlet(collapseScreenlet);
+ }
+
+ public void setMarkSelected(String markSelected) {
+ if(UtilValidate.isEmpty(showPortletLink.markSelected) && UtilValidate.isNotEmpty(markSelected))
+ showPortletLink.setMarkSelected(markSelected);
+ }
+
+ /**
+ * @param string
+ */
+ public void setPortalPageId(String portalPageId) {
+ this.portalPageId = FlexibleStringExpander.getInstance(portalPageId);
+ }
+
+ /**
+ * @param string
+ */
+ public void setDescription(String string) {
+ showPortletLink.setDescription(string);
+ }
+
+ /**
+ * @param string
+ */
+ public void setImageTitle(String string) {
+ showPortletLink.setImageTitle(string);
+ }
+
+ /**
+ * @param string
+ */
+ public void setAlternate(String string) {
+ showPortletLink.setAlternate(string);
+ }
+
+ /**
+ * @param string
+ */
+ public void setTarget(String string) {
+ this.target = FlexibleStringExpander.getInstance(string);
+ }
+ public void setConfirmationMessage(String string) {
+ this.confirmationMessage = FlexibleStringExpander.getInstance(string);
+ }
+ }
+ // #Eam# portletWidget
+
public static class SubHyperlink {
protected FlexibleStringExpander useWhen;
protected String linkType;
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Tue Aug 7 19:13:03 2012
@@ -47,6 +47,8 @@ import org.ofbiz.webapp.control.RequestH
import org.ofbiz.webapp.taglib.ContentUrlTag;
import org.ofbiz.widget.ModelWidget;
import org.ofbiz.widget.WidgetWorker;
+import org.ofbiz.widget.ModelWidget.ShowPortletItemData; //#Eam# portletWidget
+import org.ofbiz.widget.ModelWidget.ShowPortletLinkData; //#Eam# portletWidget
import org.ofbiz.widget.form.FormStringRenderer;
import org.ofbiz.widget.form.ModelForm;
import org.ofbiz.widget.form.ModelFormField;
@@ -67,6 +69,8 @@ import org.ofbiz.widget.form.ModelFormFi
import org.ofbiz.widget.form.ModelFormField.RadioField;
import org.ofbiz.widget.form.ModelFormField.RangeFindField;
import org.ofbiz.widget.form.ModelFormField.ResetField;
+import org.ofbiz.widget.form.ModelFormField.ShowPortletItem; //#Eam# portletWidget
+import org.ofbiz.widget.form.ModelFormField.ShowPortletLink; //#Eam# portletWidget
import org.ofbiz.widget.form.ModelFormField.SubmitField;
import org.ofbiz.widget.form.ModelFormField.TextField;
import org.ofbiz.widget.form.ModelFormField.TextFindField;
@@ -1605,7 +1609,7 @@ public class HtmlFormRenderer extends Ht
public void renderFormatItemRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException {
Integer itemIndex = (Integer)context.get("itemIndex");
- writer.append(" <tr");
+ writer.append(" <tr id=\"" + modelForm.getName() + "_row_" +itemIndex+"\""); //#Eam# portletWidget : add id
if (itemIndex!=null) {
String altRowStyles = modelForm.getStyleAltRowStyle(context);
@@ -2988,4 +2992,119 @@ public class HtmlFormRenderer extends Ht
}
return ajaxUrl.toString();
}
+ //#Bam# portletWidget
+ // same as MacroFormRenderer except when populate writer
+ public void renderShowPortletLink(Appendable writer, Map<String, Object> context, ShowPortletLink showPortletLink) throws IOException {
+ ModelFormField modelFormField = showPortletLink.getModelFormField();
+ String linkStyle = "";
+ //prepare show link properties
+ String id = "";
+
+ if (UtilValidate.isNotEmpty(modelFormField.getIdName())) {
+ id = modelFormField.getIdName();
+ }
+ if (UtilValidate.isNotEmpty(context.get("itemIndex"))) {
+ id = id + "_" + context.get("itemIndex");
+ }
+ String markSelected = showPortletLink.getMarkSelected(context);
+ String event = "";
+ if (UtilValidate.isNotEmpty(modelFormField.getEvent())) {
+ event = modelFormField.getEvent();
+ }
+ String action = "";
+ if (UtilValidate.isNotEmpty(modelFormField.getAction(context))) {
+ action = modelFormField.getAction(context);
+ }
+ String collapseScreenlet = showPortletLink.getCollapseScreenlet(context);
+
+ String formName = modelFormField.getModelForm().getName();
+ List<String> areasList = FastList.newInstance();
+ List<String> targetList = FastList.newInstance();
+ List<String> paramsList = FastList.newInstance();
+ List<String> formList = FastList.newInstance();
+ List<String> collapseLis = FastList.newInstance();
+
+ ShowPortletLinkData splData = WidgetWorker.prepareShowPortletLinkData(showPortletLink, context);
+
+ for(ShowPortletItem showPortletItem : showPortletLink.getShowPortletItems()){
+
+ ShowPortletItemData spiData = WidgetWorker.prepareShowPortletItemsData(showPortletItem, context);
+
+ if (UtilValidate.isEmpty(spiData.areaId) &&
+ (UtilValidate.isEmpty(spiData.portalPageId) || UtilValidate.isEmpty(spiData.portletId) || UtilValidate.isEmpty(spiData.portletSeqId))) {
+ Debug.logWarning("The form [" + modelFormField.getModelForm().getFormLocation() + "#" + modelFormField.getModelForm().getName() +"] has a show-portlet field that should define a target-area or must have target-page-id, target-portlet-id and target-seq_id attributes", module);
+ }
+
+ if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
+ linkStyle = modelFormField.getWidgetStyle();
+ }
+ collapseScreenlet = showPortletItem.getCollapseScreenlet(context);
+
+ //check whether the current form field values should be appended to request parameters or not
+ List<String> appendFormParams = showPortletItem.getFormsToSerialize();
+ areasList.add(spiData.areaId);
+ targetList.add(spiData.target);
+ paramsList.add(spiData.params.toString());
+ String formParamsString = "";
+ if(UtilValidate.isNotEmpty(appendFormParams) && appendFormParams.size() > 0){
+ formParamsString = appendFormParams.toString();
+ if (formParamsString.startsWith("{"))
+ formParamsString = formParamsString.replace("{", "");
+ if (formParamsString.endsWith("}"))
+ formParamsString = formParamsString.replace("}", "");
+ formParamsString = formParamsString.replace(", ", ",");
+ }
+ formList.add(formParamsString);
+ collapseLis.add(collapseScreenlet);
+ }
+ if (areasList.size() != targetList.size()
+ || areasList.size() != paramsList.size()) {
+ Debug.logWarning("The form Field [" + modelFormField.getModelForm().getFormLocation() + "#" + modelFormField.getModelForm().getName() +"] has define a target and arameters list for each area it is going to refresh", module);
+ }
+ if(UtilValidate.isNotEmpty(id)) {
+ writer.append("<div id=\"" + id +"_div\"");
+ }
+ writer.append(">\n");
+ writer.append(" <a ");
+ if(UtilValidate.isNotEmpty(linkStyle)) {
+ writer.append(" class=\"" + linkStyle +"\"");
+ }
+ writer.append(" href='javascript:refrshPortlet(\"" + showPortletLink.listToString(targetList) +"\", ");
+ writer.append("\"" + showPortletLink.listToString(areasList) + "\", ");
+ writer.append("\"" + showPortletLink.listToString(paramsList) + "\", ");
+ writer.append("\"" + formName +"\", ");
+ writer.append("\"" + showPortletLink.listToString(formList) + "\", ");
+ if (UtilValidate.isNotEmpty(showPortletLink.getCollapseScreenlet(context))) {
+ writer.append("\"" + showPortletLink.getCollapseScreenlet(context) + "\", ");
+ writer.append("\"" + id + "_div\", ");
+ }
+ else {
+ writer.append("\"\", ");
+ writer.append("\"\", ");
+ }
+ if (UtilValidate.isNotEmpty(showPortletLink.getCollapseScreenlet(context))) {
+ writer.append("\"" + markSelected + "\")'");
+ }
+ else {
+ writer.append("\"\")' ");
+ }
+ if(UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) {
+ writer.append(event + "=\"" + action + "\" ");
+ }
+ if(UtilValidate.isNotEmpty(splData.imgSrc) && UtilValidate.isNotEmpty(splData.imgTitle)) {
+ writer.append("title=\"" + splData.imgTitle+ "\"");
+ }
+ writer.append(">");
+ if(UtilValidate.isNotEmpty(splData.imgSrc)) {
+ writer.append("<img src=\"" + splData.imgSrc +"\" alt=\"" + splData.alt + "\" title=\"" + splData.imgTitle +"\"/>");
+ }
+ writer.append(splData.description);
+ writer.append("</a>");
+ if(UtilValidate.isNotEmpty(id)) {
+ writer.append("</div>");
+ }
+
+ this.appendTooltip(writer, context, modelFormField);
+ }
+ //#Eam# portletWidget
}
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java Tue Aug 7 19:13:03 2012
@@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletReq
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import org.ofbiz.base.util.Debug; //#Eam# portletWidget
import org.ofbiz.base.util.StringUtil;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
@@ -37,11 +38,19 @@ import org.ofbiz.webapp.control.RequestH
import org.ofbiz.webapp.taglib.ContentUrlTag;
import org.ofbiz.widget.ModelWidget;
import org.ofbiz.widget.WidgetWorker;
+//#Bam# portletWidget
+import org.ofbiz.widget.ModelWidget.ShowPortletItemData;
+import org.ofbiz.widget.ModelWidget.ShowPortletLinkData;
+//#Eam# portletWidget
import org.ofbiz.widget.menu.MenuStringRenderer;
import org.ofbiz.widget.menu.ModelMenu;
import org.ofbiz.widget.menu.ModelMenuItem;
import org.ofbiz.widget.menu.ModelMenuItem.Image;
import org.ofbiz.widget.menu.ModelMenuItem.Link;
+//#Bam# portletWidget
+import org.ofbiz.widget.menu.ModelMenuItem.ShowPortletItem;
+import org.ofbiz.widget.menu.ModelMenuItem.ShowPortletLink;
+//#Bam# portletWidget
/**
* Widget Library - HTML Menu Renderer implementation
@@ -181,9 +190,15 @@ public class HtmlMenuRenderer extends Ht
writer.append(">");
Link link = menuItem.getLink();
+ ShowPortletLink showPortletLink = menuItem.getShowPortletLink(); //#Eam# portletWidget
//if (Debug.infoOn()) Debug.logInfo("in HtmlMenuRendererImage, link(0):" + link,"");
if (link != null) {
renderLink(writer, context, link);
+ //#Bam# portletWidget
+ }
+ else if(showPortletLink != null){
+ renderShowPortletLink(writer, context, showPortletLink);
+ //#Eam# portletWidget
} else {
String txt = menuItem.getTitle(context);
StringUtil.SimpleEncoder simpleEncoder = (StringUtil.SimpleEncoder) context.get("simpleEncoder");
@@ -565,6 +580,14 @@ public class HtmlMenuRenderer extends Ht
writer.append(border);
writer.append("\"");
}
+ //#Bam# portletWidget
+ String title = image.getTitle(context);
+ if (UtilValidate.isNotEmpty(title)) {
+ writer.append(" title=\"");
+ writer.append(title);
+ writer.append("\"");
+ }
+ //#Eam# portletWidget
String src = image.getSrc(context);
if (UtilValidate.isNotEmpty(src)) {
writer.append(" src=\"");
@@ -598,4 +621,63 @@ public class HtmlMenuRenderer extends Ht
}
writer.append("/>");
}
+ //#Bam# portletWidget
+ public void renderShowPortletLink(Appendable writer, Map<String, Object> context, ShowPortletLink showPortletLink) throws IOException {
+ ModelMenuItem modelMenuItem = showPortletLink.getModelMenuItem();
+ String linkStyle = "";
+ //prepare show link properties
+ String id = "";
+ String event = "";
+ String action = "";
+ if (UtilValidate.isNotEmpty(context.get("itemIndex"))) {
+ id = id + context.get("itemIndex");
+ }
+ StringBuilder areaCsvString = new StringBuilder();
+
+ ShowPortletLinkData splData = WidgetWorker.prepareShowPortletLinkData(showPortletLink, context);
+
+ for(ShowPortletItem showPortletItem : showPortletLink.getShowPortletItems()){
+
+ ShowPortletItemData spiData = WidgetWorker.prepareShowPortletItemsData(showPortletItem, context);
+
+ if(showPortletItem.getRequireConfirmation() && UtilValidate.isNotEmpty(showPortletItem.getConfirmationMessage(context))) {
+ event = "onclick";
+ action = "return confirm('" + showPortletItem.getConfirmationMessage(context) +"')";
+ }
+
+ if (UtilValidate.isEmpty(spiData.areaId) &&
+ (UtilValidate.isEmpty(spiData.portalPageId) || UtilValidate.isEmpty(spiData.portletId) || UtilValidate.isEmpty(spiData.portletSeqId))) {
+ Debug.logWarning("The menu [" + modelMenuItem.getModelMenu().getBoundaryCommentName() +"] has a show-portlet field that should define a target-area or must have target-page-id, target-portlet-id and target-seq_id attributes", module);
+ }
+
+ if (UtilValidate.isNotEmpty(modelMenuItem.getWidgetStyle())) {
+ linkStyle = modelMenuItem.getWidgetStyle();
+ }
+
+ if (UtilValidate.isNotEmpty( spiData.areaId )) {
+ StringBuilder areanElement = new StringBuilder();
+ areanElement.append(spiData.areaId).append(",").append(spiData.target).append(",").append(spiData.params);
+ if (UtilValidate.isNotEmpty( areaCsvString )) {
+ areaCsvString.append(",");
+ }
+ areaCsvString.append(areanElement);
+ }
+ }
+
+ writer.append(" <a ");
+ if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) {
+ writer.append(event + "=\"" + action +"\"");
+ }
+ if(UtilValidate.isNotEmpty(linkStyle)) {
+ writer.append(" class=\"" + linkStyle +"\"");
+ }
+ writer.append(" href=\"javascript:ajaxUpdateAreas(\'" + areaCsvString.toString() + "\');\" ");
+ writer.append(">");
+ if(UtilValidate.isNotEmpty(splData.imgSrc)) {
+ writer.append("<img src=\"" + splData.imgSrc +"\" alt=\"" + splData.alt + "\" title=\"" + splData.imgTitle +"\"/>");
+ }
+ writer.append(splData.description);
+ writer.append("</a>");
+ }
+ //#Eam# portletWidget
}
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/menu/MenuStringRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/menu/MenuStringRenderer.java?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/menu/MenuStringRenderer.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/menu/MenuStringRenderer.java Tue Aug 7 19:13:03 2012
@@ -35,4 +35,5 @@ public interface MenuStringRenderer {
public void setUserLoginIdHasChanged(boolean b) throws IOException ;
public void renderLink(Appendable writer, Map<String, Object> context, ModelMenuItem.Link link) throws IOException ;
public void renderImage(Appendable writer, Map<String, Object> context, ModelMenuItem.Image image) throws IOException ;
+ public void renderShowPortletLink(Appendable writer, Map<String, Object> context, ModelMenuItem.ShowPortletLink showPortletLink) throws IOException ;
}
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java Tue Aug 7 19:13:03 2012
@@ -35,11 +35,13 @@ import org.ofbiz.base.util.StringUtil;
import org.ofbiz.base.util.UtilFormatOut;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.UtilURL; // #Eam# portletWidget
import org.ofbiz.base.util.UtilXml;
import org.ofbiz.base.util.collections.FlexibleMapAccessor;
import org.ofbiz.base.util.string.FlexibleStringExpander;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entityext.permission.EntityPermissionChecker;
+import org.ofbiz.widget.ModelWidget; // #Eam# portletWidget
import org.ofbiz.widget.WidgetWorker;
import org.ofbiz.widget.PortalPageWorker;
import org.w3c.dom.Element;
@@ -53,6 +55,7 @@ public class ModelMenuItem {
public static final String module = ModelMenuItem.class.getName();
protected ModelMenu modelMenu;
+ protected ShowPortletLink showPortletLink;// #Eam# portletWidget
protected Map<String, Object> dataMap = new HashMap<String, Object>();
protected String name;
@@ -187,7 +190,15 @@ public class ModelMenuItem {
if (actionsElement != null) {
this.actions = ModelMenuAction.readSubActions(this, actionsElement);
}
-
+ // #Bam# portletWidget
+ List<? extends Element> showPortlets = UtilXml.childElementList(fieldElement, "show-portlet");
+ for (Element showPortlet: showPortlets) {
+ if (UtilValidate.isEmpty(showPortletLink)) {
+ showPortletLink= new ShowPortletLink(showPortlet, this);
+ }
+ showPortletLink.addShowPorletTolink(showPortlet);
+ }
+ // #Eam# portletWidget
}
public ModelMenuItem addUpdateMenuItem(ModelMenuItem modelMenuItem) {
@@ -559,6 +570,12 @@ public class ModelMenuItem {
return this.link;
}
+ // #BAM# portletWidget
+ public ShowPortletLink getShowPortletLink() {
+ return this.showPortletLink;
+ }
+ // #EAM# portletWidget
+
public boolean isSelected(Map<String, Object> context) {
return this.name.equals(modelMenu.getSelectedMenuItemContextFieldName(context));
}
@@ -825,6 +842,7 @@ public class ModelMenuItem {
protected FlexibleStringExpander widthExdr;
protected FlexibleStringExpander heightExdr;
protected FlexibleStringExpander borderExdr;
+ protected FlexibleStringExpander title; // #Eam# portletWidget
protected String urlMode;
public Image(Element imageElement) {
@@ -834,6 +852,7 @@ public class ModelMenuItem {
setStyle(imageElement.getAttribute("style"));
setWidth(imageElement.getAttribute("width"));
setHeight(imageElement.getAttribute("height"));
+ setTitle(imageElement.getAttribute("title"));// #Eam# portletWidget
setBorder(UtilFormatOut.checkEmpty(imageElement.getAttribute("border"), "0"));
setUrlMode(UtilFormatOut.checkEmpty(imageElement.getAttribute("url-mode"), "content"));
@@ -867,6 +886,12 @@ public class ModelMenuItem {
return this.borderExdr.expandString(context);
}
+ // #Bam# portletWidget
+ public String getTitle(Map<String, Object> context) {
+ return this.title.expandString(context);
+ }
+ // #Eam# portletWidget
+
public String getUrlMode() {
return this.urlMode;
}
@@ -903,5 +928,313 @@ public class ModelMenuItem {
this.urlMode = val;
}
+ // #Bam# portletWidget
+ public void setTitle(String val) {
+ String titleAttr = UtilFormatOut.checkNull(val);
+ this.title = FlexibleStringExpander.getInstance(titleAttr);
+ }
+ // #Eam# portletWidget
+ }
+
+ public static class ShowPortletLink implements ModelWidget.ShowPortletLink {
+ protected ModelMenuItem linkMenuItem;
+ protected FlexibleStringExpander description;
+ protected FlexibleStringExpander imageTitle;
+ protected FlexibleStringExpander alternate;
+ protected FlexibleStringExpander image;
+ protected String size;
+ protected List<ShowPortletItem> showPortletItems = FastList.newInstance();
+ public String listToString(List<String> list) {
+ String result = "";
+ for(String s : list) {
+ result = result.concat(s).concat(";");
+ }
+ if (result.endsWith(";")) {
+ return result.substring(0, result.length()-1);
+ }
+ return result;
+ }
+
+ public ShowPortletLink(Element linkElement, ModelMenuItem parentMenuItem) {
+ this.linkMenuItem = parentMenuItem;
+ }
+
+ public void renderFieldString(Appendable writer, Map<String, Object> context, MenuStringRenderer menuStringRenderer) throws IOException {
+ menuStringRenderer.renderShowPortletLink(writer, context, this);
+ }
+
+ public void addShowPorletTolink(Element element) {
+ showPortletItems.add(new ShowPortletItem(element, this));
+ }
+
+ /**
+ * @param string
+ */
+ public void setDescription(String string) {
+ if (UtilValidate.isNotEmpty(string)) {
+ this.description = FlexibleStringExpander.getInstance(string);
+ }
+ }
+
+ /**
+ * @param string
+ */
+ public void setImageTitle(String string) {
+ if (UtilValidate.isNotEmpty(string)) {
+ this.imageTitle = FlexibleStringExpander.getInstance(string);
+ }
+ }
+ public ModelMenuItem getModelMenuItem() {
+ return linkMenuItem;
+ }
+ public List<ShowPortletItem> getShowPortletItems() {
+ return showPortletItems;
+ }
+ /**
+ * @param string
+ */
+ public void setAlternate(String string) {
+ if (UtilValidate.isNotEmpty(string)) {
+ this.alternate = FlexibleStringExpander.getInstance(string);
+ }
+ }
+
+ public String getDescription(Map<String, Object> context) {
+ String description = "";
+ if (UtilValidate.isNotEmpty(this.description)) {
+ description = this.description.expandString(context);
+ }
+ if (UtilValidate.isEmpty(description)) {
+ description = this.getModelMenuItem().getTitle(context);
+ }
+ return description;
+ }
+
+ public String getAlternate(Map<String, Object> context) {
+ if (UtilValidate.isNotEmpty(alternate)) {
+ return this.alternate.expandString(context);
+ }
+ return "";
+ }
+
+ public String getImageTitle(Map<String, Object> context) {
+ if (UtilValidate.isNotEmpty(imageTitle)) {
+ return this.imageTitle.expandString(context);
+ }
+ return "";
+ }
+
+ public String getImage(Map<String, Object> context) {
+ if (UtilValidate.isNotEmpty(imageTitle)) {
+ return this.image.expandString(context);
+ }
+ return "";
+ }
+
+ public String getSize() {
+ return this.size;
+ }
+
+ public String setSize(String size) {
+ return this.size = size;
+ }
+ }
+
+ public static class ShowPortletItem implements ModelWidget.ShowPortletItem {
+
+ protected FlexibleStringExpander areaId;
+ protected FlexibleStringExpander target;
+ protected ShowPortletLink showPortletLink;
+ protected FlexibleStringExpander portletId;
+ protected boolean requireConfirmation;
+ protected FlexibleStringExpander confirmationMessage;
+ protected FlexibleStringExpander portalPageId;
+ protected FlexibleStringExpander portletSeqId;
+ protected List<WidgetWorker.Parameter> parameterList = FastList.newInstance();
+
+ public ShowPortletItem(Element element, ShowPortletLink showPortletLink) {
+ this.showPortletLink = showPortletLink;
+ this.setConfirmationMessage(element.getAttribute("confirmation-message"));
+ this.setRequireConfirmation(("true".equals(element.getAttribute("request-confirmation"))));
+ this.setAreaId(element.getAttribute("area-id"));
+ this.setPortletId(element.getAttribute("portlet-id"));
+ this.setPortalPageId(element.getAttribute("portal-page-id"));
+ this.setPortletSeqId(element.getAttribute("portlet-seq-id"));
+ this.setDescription(element.getAttribute("description"));
+ this.setAlternate(element.getAttribute("alternate"));
+ this.setImageTitle(element.getAttribute("image-title"));
+ this.setTarget(element.getAttribute("target"));
+ this.setImage (element.getAttribute("image-location"));
+ this.setSize(element.getAttribute("size"));
+
+ List<? extends Element> parameterElementList = UtilXml.childElementList(element, "parameter");
+ for (Element parameterElement: parameterElementList) {
+ this.parameterList.add(new WidgetWorker.Parameter(parameterElement));
+ }
+
+ }
+ public ModelMenuItem getModelMenuItem() {
+ return showPortletLink.getModelMenuItem();
+ }
+
+ public String getDescription(Map<String, Object> context) {
+ return showPortletLink.getDescription(context);
+ }
+
+ public String getPortalPageId(Map<String, Object> context) {
+ if (UtilValidate.isNotEmpty(portalPageId)) {
+ return this.portalPageId.expandString(context);
+ }
+ return "";
+ }
+
+ public String getPortletId(Map<String, Object> context) {
+ if (UtilValidate.isNotEmpty(portletId)) {
+ return this.portletId.expandString(context);
+ }
+ return "";
+ }
+
+ public String getPortletSeqId(Map<String, Object> context) {
+ if (UtilValidate.isNotEmpty(portletSeqId)) {
+ return this.portletSeqId.expandString(context);
+ }
+ return "";
+ }
+
+ public String getAreaId(Map<String, Object> context) {
+ String areaIdValue = "";
+ if (UtilValidate.isNotEmpty(areaId)) {
+ areaIdValue = this.areaId.expandString(context);
+ }
+ return areaIdValue;
+ }
+
+ public String getAlternate(Map<String, Object> context) {
+ return showPortletLink.getAlternate(context);
+ }
+
+ public String getImageTitle(Map<String, Object> context) {
+ return showPortletLink.getImageTitle(context);
+ }
+
+ public String getTarget(Map<String, Object> context) {
+ if (UtilValidate.isNotEmpty(target)) {
+ return this.target.expandString(context);
+ }
+ return "";
+ }
+
+ public Map<String, String> getParameterMap(Map<String, Object> context) {
+ Map<String, String> fullParameterMap = FastMap.newInstance();
+
+ for (WidgetWorker.Parameter parameter: this.parameterList) {
+ String paramValue = parameter.getValue(context);
+ if (UtilValidate.isNotEmpty(paramValue) || parameter.sendIfEmpty(context)){
+ if ("idDescription".equals(parameter.getName())) {
+ if (UtilValidate.isNotEmpty(paramValue)) {
+ paramValue = UtilURL.removeBadCharForUrl(paramValue);
+ fullParameterMap.put(parameter.getName(), paramValue);
+ }
+ }
+ else {
+ fullParameterMap.put(parameter.getName(), paramValue);
+ }
+ }
+ }
+ return fullParameterMap;
+ }
+
+ public String getImage(Map<String, Object> context) {
+ if (UtilValidate.isNotEmpty(this.showPortletLink.image)) {
+ return this.showPortletLink.image.expandString(context);
+ }
+ return "";
+ }
+ public String getSize() {
+ return showPortletLink.size;
+ }
+
+ public void setImage(String image) {
+ this.showPortletLink.image = FlexibleStringExpander.getInstance(image);
+ }
+ public void setSize(String size) {
+ showPortletLink.setSize(size);
+ }
+
+ /**
+ * @param string
+ */
+ public void setAreaId(String areaId) {
+ this.areaId = FlexibleStringExpander.getInstance(areaId);
+ }
+
+ /**
+ * @param string
+ */
+ public void setPortletId(String portletId) {
+ this.portletId = FlexibleStringExpander.getInstance(portletId);
+ }
+
+ /**
+ * @param string
+ */
+ public void setPortletSeqId(String portletSeqId) {
+ this.portletSeqId = FlexibleStringExpander.getInstance(portletSeqId);
+ }
+
+ /**
+ * @param string
+ */
+ public void setPortalPageId(String portalPageId) {
+ this.portalPageId = FlexibleStringExpander.getInstance(portalPageId);
+ }
+ /**
+ * @param string
+ */
+ public void setDescription(String string) {
+ showPortletLink.setDescription(string);
+ }
+
+ /**
+ * @param string
+ */
+ public void setImageTitle(String string) {
+ showPortletLink.setImageTitle(string);
+ }
+
+ /**
+ * @param string
+ */
+ public void setAlternate(String string) {
+ showPortletLink.setAlternate(string);
+ }
+
+ /**
+ * @param string
+ */
+ public void setTarget(String string) {
+ this.target = FlexibleStringExpander.getInstance(string);
+ }
+
+ public String getConfirmationMessage(Map<String, Object> context) {
+ String areaIdValue = "";
+ if (UtilValidate.isNotEmpty(confirmationMessage)) {
+ areaIdValue = this.confirmationMessage.expandString(context);
+ }
+ return areaIdValue;
+ }
+
+ public void setRequireConfirmation(boolean reqConfirm) {
+ requireConfirmation = reqConfirm;
+ }
+
+ public boolean getRequireConfirmation() {
+ return requireConfirmation;
+ }
+
+ public void setConfirmationMessage(String string) {
+ this.confirmationMessage = FlexibleStringExpander.getInstance(string);
+ }
}
}
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java Tue Aug 7 19:13:03 2012
@@ -47,6 +47,7 @@ import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.template.FreeMarkerWorker;
import org.ofbiz.entity.Delegator;
import org.ofbiz.entity.GenericValue;
+import org.ofbiz.service.DispatchContext;//#Eam# : portletWidget
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.webapp.control.RequestHandler;
import org.ofbiz.webapp.taglib.ContentUrlTag;
@@ -54,7 +55,7 @@ import org.ofbiz.widget.ModelWidget;
import org.ofbiz.widget.WidgetContentWorker;
import org.ofbiz.widget.WidgetDataResourceWorker;
import org.ofbiz.widget.WidgetWorker;
-import org.ofbiz.widget.form.FormStringRenderer;
+//import org.ofbiz.widget.form.FormStringRenderer; #Bam# PortletWidget : screenlet navigationForm
import org.ofbiz.widget.form.MacroFormRenderer;
import org.ofbiz.widget.form.ModelForm;
import org.ofbiz.widget.html.HtmlScreenRenderer.ScreenletMenuRenderer;
@@ -64,6 +65,10 @@ import org.xml.sax.SAXException;
import freemarker.core.Environment;
import freemarker.template.Template;
import freemarker.template.TemplateException;
+//#Bam# portletWidget
+import java.util.List;
+import org.ofbiz.base.util.string.FlexibleStringExpander;
+//#Eam# portletWidget
public class MacroScreenRenderer implements ScreenStringRenderer {
@@ -73,7 +78,7 @@ public class MacroScreenRenderer impleme
private String rendererName;
private int elementId = 999;
protected boolean widgetCommentsEnabled = false;
- private static final String formrenderer = UtilProperties.getPropertyValue("widget", "screen.formrenderer");
+ //private static final String formrenderer = UtilProperties.getPropertyValue("widget", "screen.formrenderer"); #Bam# PortletWidget : screenlet navigationForm
public MacroScreenRenderer(String name, String macroLibraryPath) throws TemplateException, IOException {
macroLibrary = FreeMarkerWorker.getTemplate(macroLibraryPath);
@@ -620,9 +625,14 @@ public class MacroScreenRenderer impleme
context.put("menuStringRenderer", renderer);
navMenu.renderWidgetString(sb, context, this);
context.put("menuStringRenderer", savedRenderer);
+ // #Bam# PortletWidget screenlet navigationForm
+ /*
} else if (navForm != null) {
renderScreenletPaginateMenu(sb, context, navForm);
}
+ */
+ }
+ // #Bam# PortletWidget screenlet navigationForm
menuString = sb.toString();
}
@@ -640,11 +650,35 @@ public class MacroScreenRenderer impleme
parameters.put("showMore", showMore);
parameters.put("collapsed", collapsed);
parameters.put("javaScriptEnabled", javaScriptEnabled);
+ // #Bam# PortletWidget screenlet navigationForm
+ /*
executeMacro(writer, "renderScreenletBegin", parameters);
+ */
+ String macroName = "renderScreenletBegin";
+ if (navForm != null) {
+ Map<String, Object> paramNav = preparePaginateData(context, navForm.getModelForm(context));
+ int listSize = (Integer) paramNav.get("listSize");
+ int viewSize = (Integer) paramNav.get("viewSize");
+ if (listSize > viewSize){
+ parameters.putAll(paramNav);
+ macroName = "renderScreenletBeginWithPaginate";
+ }
+ }
+ executeMacro(writer, macroName, parameters);
+ // #Bam# PortletWidget screenlet navigationForm
}
public void renderScreenletSubWidget(Appendable writer, Map<String, Object> context, ModelScreenWidget subWidget, ModelScreenWidget.Screenlet screenlet) throws GeneralException, IOException {
if (subWidget.equals(screenlet.getNavigationForm())) {
+ // #Bam# PortletWidget : screenlet navigationForm
+ Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext"));
+ globalCtx.put("NO_PAGINATOR", true);
+ MacroFormRenderer formRenderer = (MacroFormRenderer) context.get("formStringRenderer"); // in MacroScreenRenderer it should be a MacroForm
+ boolean previousRenderPagination = formRenderer.getRenderPagination();
+ formRenderer.setRenderPagination(false);
+ subWidget.renderWidgetString(writer, context, this);
+ formRenderer.setRenderPagination(previousRenderPagination);
+ /*
HttpServletRequest request = (HttpServletRequest) context.get("request");
HttpServletResponse response = (HttpServletResponse) context.get("response");
if (request != null && response != null) {
@@ -662,6 +696,8 @@ public class MacroScreenRenderer impleme
subWidget.renderWidgetString(writer, context, this);
context.put("formStringRenderer", savedRenderer);
}
+ */
+ // #Eam# PortletWidget : screenlet navigationForm
} else {
subWidget.renderWidgetString(writer, context, this);
}
@@ -676,6 +712,12 @@ public class MacroScreenRenderer impleme
ModelForm modelForm = form.getModelForm(context);
modelForm.runFormActions(context);
modelForm.preparePager(context);
+ //#Bam# portletWidget : screenlet navigationForm
+ context.put("forScreenlet", "Y");
+ MacroFormRenderer formStringRenderer = (MacroFormRenderer) context.get("formStringRenderer");
+ formStringRenderer.renderNextPrev(writer, context, modelForm);
+ //#Eam# portletWidget
+
String targetService = modelForm.getPaginateTarget(context);
if (targetService == null) {
targetService = "${targetService}";
@@ -793,6 +835,301 @@ public class MacroScreenRenderer impleme
executeMacro(writer, "renderScreenletPaginateMenu", parameters);
}
+ //#Bam# portletWidget screenlet navigation Form
+ public Map<String, Object> preparePaginateData(Map<String, Object> context, ModelForm modelForm) {
+ boolean ajaxEnabled = false;
+ HttpServletRequest request = (HttpServletRequest) context.get("request");
+ HttpServletResponse response = (HttpServletResponse) context.get("response");
+ ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
+ RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
+ Map<String, Object> inputFields = UtilGenerics.checkMap(context.get("requestParameters"));
+ Map<String, Object> queryStringMap = UtilGenerics.toMap(context.get("queryStringMap"));
+ if (UtilValidate.isNotEmpty(queryStringMap)) {
+ inputFields.putAll(queryStringMap);
+ }
+ if (modelForm.getType().equals("multi")) {
+ inputFields = UtilHttp.removeMultiFormParameters(inputFields);
+ }
+ String queryString = UtilHttp.urlEncodeArgs(inputFields);
+ List<ModelForm.UpdateArea> updateAreas = modelForm.getOnPaginateUpdateAreas();
+ modelForm.runFormActions(context);
+ modelForm.preparePager(context);
+ String targetService = modelForm.getPaginateTarget(context);
+ if (UtilHttp.isJavaScriptEnabled(request)) {
+ if (UtilValidate.isNotEmpty(updateAreas)) {
+ ajaxEnabled = true;
+ }
+ }
+ if (targetService == null) {
+ targetService = "${targetService}";
+ }
+
+ // get the parameterized pagination index and size fields
+ int paginatorNumber = WidgetWorker.getPaginatorNumber(context);
+ String viewIndexParam = modelForm.getMultiPaginateIndexField(context);
+ String viewSizeParam = modelForm.getMultiPaginateSizeField(context);
+
+ int viewIndex = modelForm.getViewIndex(context);
+ int viewSize = modelForm.getViewSize(context);
+ int listSize = modelForm.getListSize(context);
+
+ int lowIndex = modelForm.getLowIndex(context);
+ int highIndex = modelForm.getHighIndex(context);
+ int actualPageSize = modelForm.getActualPageSize(context);
+
+ // needed for the "Page" and "rows" labels
+ Map<String, String> uiLabelMap = UtilGenerics.checkMap(context.get("uiLabelMap"));
+ String pageLabel = "";
+ String commonDisplaying = "";
+ if (uiLabelMap == null) {
+ Debug.logWarning("Could not find uiLabelMap in context", module);
+ } else {
+ pageLabel = 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"));
+ }
+
+ // for legacy support, the viewSizeParam is VIEW_SIZE and viewIndexParam is VIEW_INDEX when the fields are "viewSize" and "viewIndex"
+ if (viewIndexParam.equals("viewIndex" + "_" + paginatorNumber)) viewIndexParam = "VIEW_INDEX" + "_" + paginatorNumber;
+ if (viewSizeParam.equals("viewSize" + "_" + paginatorNumber)) viewSizeParam = "VIEW_SIZE" + "_" + paginatorNumber;
+
+
+ // strip legacy viewIndex/viewSize params from the query string
+ queryString = UtilHttp.stripViewParamsFromQueryString(queryString, "" + paginatorNumber);
+
+ // strip parameterized index/size params from the query string
+ HashSet<String> paramNames = new HashSet<String>();
+ paramNames.add(viewIndexParam);
+ paramNames.add(viewSizeParam);
+ queryString = UtilHttp.stripNamedParamsFromQueryString(queryString, paramNames);
+
+ String anchor = "";
+ String paginateAnchor = modelForm.getPaginateTargetAnchor();
+ if (UtilValidate.isNotEmpty(paginateAnchor)) anchor = "#" + paginateAnchor;
+
+ // Create separate url path String and request parameters String,
+ // add viewIndex/viewSize parameters to request parameter String
+ String urlPath = UtilHttp.removeQueryStringFromTarget(targetService);
+ String prepLinkText = UtilHttp.getQueryStringFromTarget(targetService);
+ String prepLinkSizeText;
+
+ if (UtilValidate.isNotEmpty(queryString)) {
+ queryString = UtilHttp.encodeAmpersands(queryString);
+ }
+
+ if (prepLinkText == null) {
+ prepLinkText = "";
+ }
+ if (prepLinkText.indexOf("?") < 0) {
+ prepLinkText += "?";
+ } else if (!prepLinkText.endsWith("?")) {
+ prepLinkText += "&";
+ }
+ if (!UtilValidate.isEmpty(queryString) && !queryString.equals("null")) {
+ prepLinkText += queryString + "&";
+ }
+ prepLinkSizeText = prepLinkText + viewSizeParam + "='+this.value+'" + "&" + viewIndexParam + "=0";
+ prepLinkText += viewSizeParam + "=" + viewSize + "&" + viewIndexParam + "=";
+ if (ajaxEnabled) {
+ // Prepare params for prototype.js
+ prepLinkText = prepLinkText.replace("?", "");
+ prepLinkText = prepLinkText.replace("&", "&");
+ }
+ String linkText;
+ String paginateStyle = modelForm.getPaginateStyle();
+ String paginateFirstStyle = modelForm.getPaginateFirstStyle();
+ String paginateFirstLabel = modelForm.getPaginateFirstLabel(context);
+ String firstUrl = "";
+ String ajaxFirstUrl = "";
+ String paginatePreviousStyle = modelForm.getPaginatePreviousStyle();
+ String paginatePreviousLabel = modelForm.getPaginatePreviousLabel(context);
+ String previousUrl = "";
+ String ajaxPreviousUrl = "";
+ String selectUrl = "";
+ String ajaxSelectUrl = "";
+ String paginateViewSizeLabel = modelForm.getPaginateViewSizeLabel(context);
+ String selectSizeUrl = "";
+ String ajaxSelectSizeUrl = "";
+ String paginateNextStyle = modelForm.getPaginateNextStyle();
+ String paginateNextLabel = modelForm.getPaginateNextLabel(context);
+ String nextUrl = "";
+ String ajaxNextUrl = "";
+ String paginateLastStyle = modelForm.getPaginateLastStyle();
+ String paginateLastLabel = modelForm.getPaginateLastLabel(context);
+ String lastUrl = "";
+ String ajaxLastUrl = "";
+
+ if (viewIndex > 0) {
+ if (ajaxEnabled) {
+ ajaxFirstUrl = createAjaxParamsFromUpdateAreas(rh, request, response, updateAreas, prepLinkText + 0 + anchor, context);
+ } else {
+ linkText = prepLinkText + 0 + anchor;
+ firstUrl = rh.makeLink(request, response, urlPath + linkText);
+ }
+ }
+ if (viewIndex > 0) {
+ if (ajaxEnabled) {
+ ajaxPreviousUrl = createAjaxParamsFromUpdateAreas(rh, request, response, updateAreas, prepLinkText + (viewIndex - 1) + anchor, context);
+ } else {
+ linkText = prepLinkText + (viewIndex - 1) + anchor;
+ previousUrl = rh.makeLink(request, response, urlPath + linkText);
+ }
+ }
+ // Page select dropdown
+ if (listSize > 0 && ajaxEnabled) {
+ if (ajaxEnabled) {
+ ajaxSelectUrl = createAjaxParamsFromUpdateAreas(rh, request, response, updateAreas, prepLinkText + "' + this.value + '", context);
+ } else {
+ linkText = prepLinkText;
+ if (linkText.startsWith("/")) {
+ linkText = linkText.substring(1);
+ }
+ selectUrl = rh.makeLink(request, response, urlPath + linkText);
+ }
+ }
+
+ // Next button
+ if (highIndex < listSize) {
+ if (ajaxEnabled) {
+ ajaxNextUrl = createAjaxParamsFromUpdateAreas(rh, request, response, updateAreas, prepLinkText + (viewIndex + 1) + anchor, context);
+ } else {
+ linkText = prepLinkText + (viewIndex + 1) + anchor;
+ nextUrl = rh.makeLink(request, response, urlPath + linkText);
+ }
+ }
+
+ // Last button
+ if (highIndex < listSize) {
+ if (ajaxEnabled) {
+ ajaxLastUrl = createAjaxParamsFromUpdateAreas(rh, request, response, updateAreas, prepLinkText + (listSize / viewSize) + anchor, context);
+ } else {
+ linkText = prepLinkText + (listSize / viewSize) + anchor;
+ lastUrl = rh.makeLink(request, response, urlPath + linkText);
+ }
+ }
+
+ // Page size select dropdown
+ if (listSize > 0 && ajaxEnabled) {
+ if (ajaxEnabled) {
+ ajaxSelectSizeUrl = createAjaxParamsFromUpdateAreas(rh, request, response, updateAreas, prepLinkSizeText + anchor, context);
+ } else {
+ linkText = prepLinkSizeText;
+ if (linkText.startsWith("/")) {
+ linkText = linkText.substring(1);
+ }
+ selectSizeUrl = rh.makeLink(request, response, urlPath + linkText);
+ }
+ }
+
+ Map<String, Object> navigationData = FastMap.newInstance();
+ navigationData.put("paginateStyle", paginateStyle);
+ navigationData.put("paginateFirstStyle", paginateFirstStyle);
+ navigationData.put("viewIndex", viewIndex);
+ navigationData.put("highIndex", highIndex);
+ navigationData.put("listSize", listSize);
+ navigationData.put("viewSize", viewSize);
+ navigationData.put("ajaxEnabled", ajaxEnabled);
+// navigationData.put("javaScriptEnabled", Boolean.toString(ajaxEnabled));
+ navigationData.put("ajaxFirstUrl", ajaxFirstUrl);
+ navigationData.put("firstUrl", firstUrl);
+ navigationData.put("paginateFirstLabel", paginateFirstLabel);
+ navigationData.put("paginatePreviousStyle", paginatePreviousStyle);
+ navigationData.put("ajaxPreviousUrl", ajaxPreviousUrl);
+ navigationData.put("previousUrl", previousUrl);
+ navigationData.put("paginatePreviousLabel", paginatePreviousLabel);
+ navigationData.put("pageLabel", pageLabel);
+ navigationData.put("ajaxSelectUrl", ajaxSelectUrl);
+ navigationData.put("selectUrl", selectUrl);
+ navigationData.put("ajaxSelectSizeUrl", ajaxSelectSizeUrl);
+ navigationData.put("selectSizeUrl", selectSizeUrl);
+ navigationData.put("commonDisplaying", commonDisplaying);
+ navigationData.put("paginateNextStyle", paginateNextStyle);
+ navigationData.put("ajaxNextUrl", ajaxNextUrl);
+ navigationData.put("nextUrl", nextUrl);
+ navigationData.put("paginateNextLabel", paginateNextLabel);
+ navigationData.put("paginateLastStyle", paginateLastStyle);
+ navigationData.put("ajaxLastUrl", ajaxLastUrl);
+ navigationData.put("lastUrl", lastUrl);
+ navigationData.put("paginateLastLabel", paginateLastLabel);
+ navigationData.put("paginateViewSizeLabel", paginateViewSizeLabel);
+ return navigationData;
+
+ }
+ /** Create an ajaxXxxx JavaScript CSV string from a list of UpdateArea objects. See
+ * <code>selectall.js</code>.
+ * @param updateAreas
+ * @param extraParams Renderer-supplied additional target parameters
+ * @param context
+ * @return Parameter string or empty string if no UpdateArea objects were found
+ */
+ public String createAjaxParamsFromUpdateAreas(RequestHandler rh,HttpServletRequest request, HttpServletResponse response, List<ModelForm.UpdateArea> updateAreas, String extraParams, Map<String, ? extends Object> context) {
+ //FIXME copy from HtmlFormRenderer.java
+ if (updateAreas == null) {
+ return "";
+ }
+ String ajaxUrl = "";
+ boolean firstLoop = true;
+ for (ModelForm.UpdateArea updateArea : updateAreas) {
+ if (firstLoop) {
+ firstLoop = false;
+ } else {
+ ajaxUrl += ",";
+ }
+ Map<String, Object> ctx = UtilGenerics.checkMap(context);
+ Map<String, String> parameters = updateArea.getParameterMap(ctx);
+ String targetUrl = updateArea.getAreaTarget(context);
+ String ajaxParams = getAjaxParamsFromTarget(targetUrl);
+ if (UtilValidate.isNotEmpty(extraParams)) {
+ if (ajaxParams.length() > 0 && !extraParams.startsWith("&")) {
+ ajaxParams += "&";
+ }
+ ajaxParams += extraParams;
+ }
+ if(parameters!=null){
+ if(UtilValidate.isEmpty(ajaxParams)){
+ ajaxParams = "";
+ }
+ for (String key : parameters.keySet()) {
+ if (ajaxParams.length() > 0 && ajaxParams.indexOf(key) < 0) {
+ ajaxParams += "&";
+ }
+ if (ajaxParams.indexOf(key) < 0) {
+ ajaxParams += key + "=" + parameters.get(key);
+ }
+ }
+ StringBuilder params = new StringBuilder();
+ params.append(ajaxParams);
+ List<String> addingParams = UtilMisc.toList("portalPageId", "portalPortletId", "portletSeqId", "areaId", "idDescription");
+ for (String addingParam : addingParams) {
+ if (UtilValidate.isNotEmpty(ajaxParams) && ajaxParams.contains(addingParam + "=")) {
+ continue;
+ }
+ WidgetWorker.addToParamsIfInContext(params, ctx, addingParam, parameters);
+ }
+ ajaxParams = params.toString();
+ }
+ ajaxUrl += updateArea.getAreaId() + ",";
+ ajaxUrl += rh.makeLink(request, response, UtilHttp.removeQueryStringFromTarget(targetUrl));
+ ajaxUrl += "," + ajaxParams;
+ }
+ Locale locale = UtilMisc.ensureLocale(context.get("locale"));
+ return FlexibleStringExpander.expandString(ajaxUrl, context, locale);
+ }
+
+ /** Extracts parameters from a target URL string, prepares them for an Ajax
+ * JavaScript call. This method is currently set to return a parameter string
+ * suitable for the Prototype.js library.
+ * @param target Target URL string
+ * @return Parameter string
+ */
+ public static String getAjaxParamsFromTarget(String target) {
+ String targetParams = UtilHttp.getQueryStringFromTarget(target);
+ targetParams = targetParams.replace("?", "");
+ targetParams = targetParams.replace("&", "&");
+ return targetParams;
+ }
+ //#Eam# portletWidget
+
public void renderPortalPageBegin(Appendable writer, Map<String, Object> context, ModelScreenWidget.PortalPage portalPage) throws GeneralException, IOException {
String portalPageId = portalPage.getActualPortalPageId();
String originalPortalPageId = portalPage.getOriginalPortalPageId();
@@ -890,6 +1227,10 @@ public class MacroScreenRenderer impleme
sr.append(colWidthLabel);
sr.append("\" setColumnSizeHint=\"");
sr.append(setColumnSizeHint);
+ //#Bam# portletWidget add new field in PortalPageColumn to be able to have multiple line in a portalPage. Each line has multiple column
+ sr.append("\" newLine=\"");
+ sr.append(portalPageColumn.getString("newLine"));
+ //#Eam# portletWidget add new field in PortalPageColumn to be able to have multiple line in a portalPage. Each line has multiple column
sr.append("\" />");
executeMacro(writer, sr.toString());
}
@@ -904,8 +1245,18 @@ public class MacroScreenRenderer impleme
String portalPageId = portalPage.getActualPortalPageId();
String originalPortalPageId = portalPage.getOriginalPortalPageId();
String portalPortletId = portalPortlet.getString("portalPortletId");
+ //#Bam# portletWidget
+ /*
String portletSeqId = portalPortlet.getString("portletSeqId");
String columnSeqId = portalPortlet.getString("columnSeqId");
+ */
+ String portletSeqId = null;
+ String columnSeqId = null;
+ if (! portalPortlet.getEntityName().equals("PortalPortlet")){
+ portletSeqId = portalPortlet.getString("portletSeqId");
+ columnSeqId = portalPortlet.getString("columnSeqId");
+ }
+ //#Eam# portletWidget
String confMode = portalPage.getConfMode(context);
String editFormName = portalPortlet.getString("editFormName");
String editFormLocation = portalPortlet.getString("editFormLocation");
@@ -926,6 +1277,7 @@ public class MacroScreenRenderer impleme
delPortletHint = uiLabelMap.get("CommonDeleteThisPortlet");
editAttributeHint = uiLabelMap.get("CommonEditPortletAttributes");
}
+ String includedInPage = (String) context.get("includedInPage");//#Eam# : portletWidget
StringWriter sr = new StringWriter();
sr.append("<@renderPortalPagePortletBegin ");
@@ -957,6 +1309,10 @@ public class MacroScreenRenderer impleme
sr.append(editAttributeHint);
sr.append("\" confMode=\"");
sr.append(confMode);
+ //#Bam# : portletWidget
+ sr.append("\" includedInPage=\"");
+ sr.append(includedInPage);
+ //#Eam# : portletWidget
sr.append("\"");
if (UtilValidate.isNotEmpty(editFormName) && UtilValidate.isNotEmpty(editFormLocation)) {
sr.append(" editAttribute=\"true\"");
@@ -972,6 +1328,11 @@ public class MacroScreenRenderer impleme
sr.append("<@renderPortalPagePortletEnd ");
sr.append(" confMode=\"");
sr.append(confMode);
+ //#Bam# : portletWidget
+ String includedInPage = (String) context.get("includedInPage");
+ sr.append("\" includedInPage=\"");
+ sr.append(includedInPage);
+ //#Eam# : portletWidget
sr.append("\" />");
executeMacro(writer, sr.toString());
}
@@ -980,11 +1341,49 @@ public class MacroScreenRenderer impleme
String portalPortletId = portalPortlet.getString("portalPortletId");
String screenName = portalPortlet.getString("screenName");
String screenLocation = portalPortlet.getString("screenLocation");
+ //#Bam# : portletWidget
+ if (UtilValidate.isEmpty(screenName) || UtilValidate.isEmpty(screenLocation)){
+ Debug.logError("Impossible to show portalPortletId="+portalPortletId+" screenName="+screenName+" screenLocation="+screenLocation, module);
+ return;
+ }
+
+ LocalDispatcher dispatcher = (LocalDispatcher) context.get("dispatcher");
+ DispatchContext dctx = dispatcher.getDispatchContext();
+ Boolean hasPermission = true;
+ if (UtilValidate.isNotEmpty(portalPortlet.get("securityServiceName")) && UtilValidate.isNotEmpty(portalPortlet.get("securityMainAction"))) {
+ String serviceName = portalPortlet.getString("securityServiceName");
+ Map<String, Object> inMap = UtilMisc.toMap("mainAction", portalPortlet.get("securityMainAction"),
+ "resourceDescription", portalPortletId,
+ "userLogin",context.get("userLogin"));
+ //Add request parameters to service context
+ Map<String, Object> inputFields = UtilGenerics.checkMap(context.get("requestParameters"));
+ for (String name: inputFields.keySet()) {
+ inMap.put(name, inputFields.get(name));
+ }
+ inMap = dctx.makeValidContext(serviceName, "IN", inMap);
+ Map<String, Object> result = dispatcher.runSync(serviceName, inMap);
+ if (UtilValidate.isNotEmpty(result)) {
+ hasPermission = (Boolean) result.get("hasPermission");
+
+ //Add service result parameters to context
+ for (String name: result.keySet()) {
+ context.put(name, result.get(name));
+ }
+ }
+ }
+ //#Eam# : portletWidget
ModelScreen modelScreen = null;
if (UtilValidate.isNotEmpty(screenName) && UtilValidate.isNotEmpty(screenLocation)) {
try {
+ if (hasPermission) {//#Eam# : portletWidget
modelScreen = ScreenFactory.getScreenFromLocation(screenLocation, screenName);
+ //#Bam# : portletWidget
+ } else {
+ //Display permission error screen
+ modelScreen = ScreenFactory.getScreenFromLocation("component://common/widget/PortalPageScreens.xml","PermissionErrorScreen");
+ }
+ //#Eam# : portletWidget
} catch (IOException e) {
String errMsg = "Error rendering portlet ID [" + portalPortletId + "]: " + e.toString();
Debug.logError(e, errMsg, module);
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java Tue Aug 7 19:13:03 2012
@@ -401,31 +401,37 @@ public abstract class ModelScreenAction
@Deprecated
public static class Script extends ModelScreenAction {
- protected String location;
- protected String method;
+ protected FlexibleStringExpander scriptLocationExdr;
public Script(ModelScreen modelScreen, Element scriptElement) {
super (modelScreen, scriptElement);
- String scriptLocation = scriptElement.getAttribute("location");
- this.location = WidgetWorker.getScriptLocation(scriptLocation);
- this.method = WidgetWorker.getScriptMethodName(scriptLocation);
+ this.scriptLocationExdr = FlexibleStringExpander.getInstance(scriptElement.getAttribute("location"));
}
@Override
public void runAction(Map<String, Object> context) throws GeneralException {
+ Locale locale = (Locale) context.get("locale");
+ String scriptLocation = this.scriptLocationExdr.expandString(context, locale);
+ String location = WidgetWorker.getScriptLocation(scriptLocation);
+ String method = WidgetWorker.getScriptMethodName(scriptLocation);
if (location.endsWith(".xml")) {
- Map<String, Object> localContext = FastMap.newInstance();
- localContext.putAll(context);
DispatchContext ctx = this.modelScreen.getDispatcher(context).getDispatchContext();
- MethodContext methodContext = new MethodContext(ctx, localContext, null);
+ MethodContext methodContext = new MethodContext(ctx, context);
try {
SimpleMethod.runSimpleMethod(location, method, methodContext);
- context.putAll(methodContext.getResults());
+ Map<String, Object> resultContext = methodContext.getEnv("widget");
+ if (UtilValidate.isNotEmpty(resultContext)){
+ context.putAll(resultContext);
+ }
+ Map<String, Object> parametersUp = methodContext.getParameters();
+ if (UtilValidate.isNotEmpty(parametersUp)){
+ context.put("parameters",parametersUp);
+ }
} catch (MiniLangException e) {
throw new GeneralException("Error running simple method at location [" + location + "]", e);
}
} else {
- ScriptUtil.executeScript(this.location, this.method, context);
+ ScriptUtil.executeScript(location, method, context);
}
}
}