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 [3/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/dtd/widget-form.xsd
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/dtd/widget-form.xsd?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/dtd/widget-form.xsd (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/dtd/widget-form.xsd Tue Aug 7 19:13:03 2012
@@ -230,6 +230,19 @@ under the License.
</xs:annotation>
</xs:attribute>
-->
+ <xs:attribute name="validate-link-on-enter" default="false">
+ <xs:annotation><xs:documentation>in some case, a single form doest not include a submit button, instead it includes an hypperlink. setting this attribute to true wil result in click on the link when enter button is pressed on any form other input</xs:documentation></xs:annotation>
+ <xs:simpleType>
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="true"/>
+ <xs:enumeration value="false"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="validate-link-id" default="submit">
+ <xs:annotation><xs:documentation>in some case, a single form doest not include a submit button, instead it includes an hypperlink. setting this attribute to true wil result in click on the link when enter button is pressed on any form other input</xs:documentation></xs:annotation>
+ </xs:attribute>
+
</xs:attributeGroup>
<xs:element name="alt-target">
<xs:complexType>
@@ -383,6 +396,24 @@ under the License.
</xs:attribute>
<xs:attribute name="area-id" type="xs:string" use="required"/>
<xs:attribute name="area-target" type="xs:string" use="required"/>
+ <!--
+ <xs:attribute name="use-when" type="xs:string">
+ <xs:annotation><xs:documentation>
+ Used to specify a condition that must be true to use this field; the condition should be written using the
+ Java syntax and can operate on values in the form context; conditional fields are evaluated in reverse
+ order so the last field defined that evaluates to true is the one that is rendered.
+ </xs:documentation></xs:annotation>
+ </xs:attribute>
+ -->
+ <xs:attribute name="redirect-all-parameter" default="false">
+ <xs:annotation><xs:documentation>Usable only for type="submit", use all parameters returned by the submit as parameter for area-target.</xs:documentation></xs:annotation>
+ <xs:simpleType>
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="true"/>
+ <xs:enumeration value="false"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
</xs:attributeGroup>
<xs:element name="on-event-update-area">
<xs:annotation>
@@ -391,6 +422,10 @@ under the License.
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="parameter"/>
+ <xs:element minOccurs="0" maxOccurs="unbounded" ref="redirect-parameter">
+ <xs:annotation><xs:documentation>
+ Usable only for type="submit", give parameter name returned by the submit to put as parameter for area-target.</xs:documentation></xs:annotation>
+ </xs:element>
</xs:sequence>
<xs:attributeGroup ref="attlist.on-form-event-update-area"/>
</xs:complexType>
@@ -402,6 +437,9 @@ under the License.
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" ref="AllFields"/>
+ <xs:element minOccurs="0" maxOccurs="unbounded" ref="show-portlet">
+ <xs:annotation><xs:documentation>it's possible to generate multiple show-portlet with one click.</xs:documentation></xs:annotation>
+ </xs:element>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="on-field-event-update-area"/>
</xs:sequence>
<xs:attributeGroup ref="attlist.field"/>
@@ -929,7 +967,113 @@ under the License.
<xs:attribute type="xs:string" name="param-name" use="required"/>
<xs:attribute type="xs:string" name="from-field"/>
<xs:attribute type="xs:string" name="value"/>
+ <xs:attribute name="send-if-empty" default="false">
+ <xs:annotation><xs:documentation>if true param-name will be included in parameters list even if value is empty or from-field is null </xs:documentation></xs:annotation>
+ <xs:simpleType>
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="true"/>
+ <xs:enumeration value="false"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:attributeGroup>
+ <xs:element name="show-portlet">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" maxOccurs="unbounded" ref="parameters-form">
+ <xs:annotation><xs:documentation>used to give a form name which will used to send all field content as parameters, form-name attribute is optional, if not present current form name is used</xs:documentation></xs:annotation>
+ </xs:element>
+ <xs:element minOccurs="0" maxOccurs="unbounded" ref="parameter"/>
+ </xs:sequence>
+ <xs:attributeGroup ref="attlist.showPortlet"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.showPortlet">
+ <xs:attribute name="also-hidden" default="true">
+ <xs:annotation><xs:documentation>If set to true, an hidden form field is also rendered, with the name of the field and its content.</xs:documentation></xs:annotation>
+ <xs:simpleType>
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="true"/>
+ <xs:enumeration value="false"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="portlet-id" use="required">
+ <xs:annotation><xs:documentation>The portalPortletId which want to show, will pass as parameter to target; can use the ${} syntax to substitute values from the context.</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="portal-page-id">
+ <xs:annotation><xs:documentation>if a field named portalPageId is present in context it will be used, will be pass as parameter to target if has content otherwise generate a warning message; can use the ${} syntax to substitute values from the context.</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="portlet-seq-id">
+ <xs:annotation><xs:documentation>if a field named portletSeqId is present in context it will be used, will be pass as parameter to target if has content otherwise generate a warning message; can use the ${} syntax to substitute values from the context.</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="target">
+ <xs:annotation><xs:documentation>The target uri, default value is refreshPortlet; can use the ${} syntax to substitute values from the context.</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="description">
+ <xs:annotation><xs:documentation>Specifies the string to display, can use the ${} syntax to insert context values; if empty the value of the field will be printed for a default.</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="area-id">
+ <xs:annotation><xs:documentation>Area where to show the portlet, default value is "PP_${targetPageId}${targetPortletId}${targetSeqId}", will be pass as parameter to target if has content otherwise generate a warning message;can use the ${} syntax to insert context values; if empty the value of the field will be printed for a default.</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="alternate">
+ <xs:annotation><xs:documentation>Alternate text if the image is not found at image-location</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="image-title">
+ <xs:annotation><xs:documentation>Use as a title for the HTML img tag</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="image-location"/>
+ <xs:attribute name="request-confirmation" default="false">
+ <xs:annotation><xs:documentation>If true then the user is presented with a dialog box, if confirmation-message is empty, use default</xs:documentation></xs:annotation>
+ <xs:simpleType>
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="true"/>
+ <xs:enumeration value="false"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="confirmation-message" type="xs:string"><xs:annotation><xs:documentation>The message displayed in confirmation box</xs:documentation></xs:annotation></xs:attribute>
+ <xs:attribute name="parameters-map" type="xs:string">
+ <xs:annotation><xs:documentation>A Map in the context that will be used as additional name/value pairs.</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:integer" name="size">
+ <xs:annotation><xs:documentation>Specifies the size of the field (as a number of characters), when the text to display exceed the given size it is truncated and add the complete text as a hint</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="collapse-screenlet">
+ <xs:annotation><xs:documentation>Specifies the name of screenlet to collapse, can use the ${} syntax to insert context values, if value is empty nothing will be done</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="mark-selected" default="false">
+ <xs:annotation><xs:documentation>If true, when user click a selected css is apply to the line to show the selected line; only one line can be selected, a click on a second line unselected the first before select the new one.</xs:documentation></xs:annotation>
+ <xs:simpleType>
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="true"/>
+ <xs:enumeration value="false"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="parameters-form">
+ <xs:annotation><xs:documentation>Specifies the name of a form, all field of it will be put as parameters, can use the ${} syntax to insert context values, if value is empty nothing will be done</xs:documentation></xs:annotation>
+ </xs:attribute>
</xs:attributeGroup>
+ <xs:element name="redirect-parameter">
+ <xs:complexType>
+ <xs:attribute type="xs:string" name="param-name" use="required"/>
+ <xs:attribute name="send-if-empty" default="false">
+ <xs:annotation><xs:documentation>if true param-name will be included in parameters list even if value is empty or from-field is null </xs:documentation></xs:annotation>
+ <xs:simpleType>
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="true"/>
+ <xs:enumeration value="false"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="parameters-form">
+ <xs:complexType>
+ <xs:attribute type="xs:string" name="form-name"/>
+ </xs:complexType>
+ </xs:element>
<xs:element name="ignored" substitutionGroup="AllFields">
<xs:complexType/>
</xs:element>
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/dtd/widget-menu.xsd
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/dtd/widget-menu.xsd?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/dtd/widget-menu.xsd (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/dtd/widget-menu.xsd Tue Aug 7 19:13:03 2012
@@ -96,6 +96,7 @@ under the License.
<xs:element minOccurs="0" ref="condition"/>
<xs:element minOccurs="0" ref="actions"/>
<xs:element minOccurs="0" ref="link"/>
+ <xs:element minOccurs="0" ref="show-portlet"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="menu-item"/>
</xs:sequence>
<xs:attributeGroup ref="attlist.menu-item"/>
@@ -135,6 +136,7 @@ under the License.
</xs:element>
<xs:attributeGroup name="attlist.image">
<xs:attribute type="xs:string" name="src"/>
+ <xs:attribute type="xs:string" name="title"/>
<xs:attribute type="xs:string" name="id"/>
<xs:attribute type="xs:string" name="style"/>
<xs:attribute type="xs:string" name="width"/>
@@ -605,4 +607,69 @@ under the License.
<xs:attributeGroup name="attlist.if-empty">
<xs:attribute name="field" use="required"/>
</xs:attributeGroup>
+ <xs:element name="show-portlet">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" maxOccurs="unbounded" ref="parameter"/>
+ </xs:sequence>
+ <xs:attributeGroup ref="attlist.showPortlet"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:attributeGroup name="attlist.showPortlet">
+ <xs:attribute name="also-hidden" default="true">
+ <xs:annotation><xs:documentation>If set to true, an hidden form field is also rendered, with the name of the field and its content.</xs:documentation></xs:annotation>
+ <xs:simpleType>
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="true"/>
+ <xs:enumeration value="false"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="portlet-id" use="required">
+ <xs:annotation><xs:documentation>The portalPortletId which want to show, will pass as parameter to target; can use the ${} syntax to substitute values from the context.</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="portal-page-id">
+ <xs:annotation><xs:documentation>if a field named portalPageId is present in context it will be used, will be pass as parameter to target if has content otherwise generate a warning message; can use the ${} syntax to substitute values from the context.</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="portlet-seq-id">
+ <xs:annotation><xs:documentation>if a field named portletSeqId is present in context it will be used, will be pass as parameter to target if has content otherwise generate a warning message; can use the ${} syntax to substitute values from the context.</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="target">
+ <xs:annotation><xs:documentation>The target uri, default value is refreshPortlet; can use the ${} syntax to substitute values from the context.</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="description">
+ <xs:annotation><xs:documentation>Specifies the string to display, can use the ${} syntax to insert context values; if empty the value of the field will be printed for a default.</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="area-id">
+ <xs:annotation><xs:documentation>Area where to show the portlet, default value is "PP_${targetPageId}${targetPortletId}${targetSeqId}", will be pass as parameter to target if has content otherwise generate a warning message;can use the ${} syntax to insert context values; if empty the value of the field will be printed for a default.</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="alternate">
+ <xs:annotation><xs:documentation>Alternate text if the image is not found at image-location</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="image-title">
+ <xs:annotation><xs:documentation>Use as a title for the HTML img tag</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="image-location"/>
+ <xs:attribute name="request-confirmation" default="false">
+ <xs:annotation><xs:documentation>If true then the user is presented with a dialog box, if confirmation-message is empty, use default</xs:documentation></xs:annotation>
+ <xs:simpleType>
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="true"/>
+ <xs:enumeration value="false"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="confirmation-message" type="xs:string"><xs:annotation><xs:documentation>The message displayed in confirmation box</xs:documentation></xs:annotation></xs:attribute>
+ <xs:attribute name="parameters-map" type="xs:string">
+ <xs:annotation><xs:documentation>A Map in the context that will be used as additional name/value pairs.</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:integer" name="size">
+ <xs:annotation><xs:documentation>Specifies the size of the field (as a number of characters), when the text to display exceed the given size it is truncated and add the complete text as a hint</xs:documentation></xs:annotation>
+ </xs:attribute>
+ </xs:attributeGroup>
+ <xs:element name="parameters-form">
+ <xs:complexType>
+ <xs:attribute type="xs:string" name="form-name"/>
+ </xs:complexType>
+ </xs:element>
</xs:schema>
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/dtd/widget-screen.xsd
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/dtd/widget-screen.xsd?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/dtd/widget-screen.xsd (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/dtd/widget-screen.xsd Tue Aug 7 19:13:03 2012
@@ -1124,6 +1124,14 @@ under the License.
</xs:restriction>
</xs:simpleType>
</xs:attribute>
+ <!-- #Bam# : portletWidget -->
+ <xs:attribute type="xs:string" name="portalPortletId">
+ <xs:annotation><xs:documentation>Retrieve only the attributes for this portalPortlet</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <xs:attribute type="xs:string" name="portletSeqId">
+ <xs:annotation><xs:documentation>Specify the portletSeqId of the portalPortlet to look for when retrieving the attributes</xs:documentation></xs:annotation>
+ </xs:attribute>
+ <!-- #Eam# : portletWidget -->
</xs:attributeGroup>
<xs:element name="sub-content" substitutionGroup="AllWidgets">
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/ModelWidget.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/ModelWidget.java?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/ModelWidget.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/ModelWidget.java Tue Aug 7 19:13:03 2012
@@ -32,6 +32,35 @@ import org.w3c.dom.Element;
@SuppressWarnings("serial")
public class ModelWidget implements Serializable {
+ public interface ShowPortletLink {
+ public String getImage(Map<String, Object> context);
+ public String getImageTitle(Map<String, Object> context);
+ public String getAlternate(Map<String, Object> context);
+ public String getDescription(Map<String, Object> context);
+ }
+ public static class ShowPortletLinkData {
+ public String imgSrc;
+ public String imgTitle;
+ public String alt;
+ public String description;
+ }
+ public interface ShowPortletItem {
+ public String getPortalPageId(Map<String, Object> context);
+ public String getPortletId(Map<String, Object> context);
+ public String getPortletSeqId(Map<String, Object> context);
+ public String getAreaId(Map<String, Object> context);
+ public String getTarget(Map<String, Object> context);
+ public Map<String, String> getParameterMap(Map<String, Object> context);
+ }
+ public static class ShowPortletItemData {
+ public String portalPageId;
+ public String portletId;
+ public String portletSeqId;
+ public String areaId;
+ public String target;
+ public Map<String, String> parameterMap;
+ public StringBuilder params;
+ }
/**
* The parameter name used to control widget boundary comments. Currently
* set to "widgetVerbose".
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/ModelWidgetAction.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/ModelWidgetAction.java?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/ModelWidgetAction.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/ModelWidgetAction.java Tue Aug 7 19:13:03 2012
@@ -387,31 +387,37 @@ public abstract class ModelWidgetAction
}
public static class Script extends ModelWidgetAction {
- protected String location;
- protected String method;
+ protected FlexibleStringExpander scriptLocationExdr;
public Script(ModelWidget modelWidget, Element scriptElement) {
super (modelWidget, 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 = WidgetWorker.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);
}
}
}
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/WidgetWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/WidgetWorker.java?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/WidgetWorker.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/WidgetWorker.java Tue Aug 7 19:13:03 2012
@@ -37,6 +37,7 @@ import org.ofbiz.base.util.StringUtil;
import org.ofbiz.base.util.UtilDateTime;
import org.ofbiz.base.util.UtilGenerics;
import org.ofbiz.base.util.UtilHttp;
+import org.ofbiz.base.util.UtilURL;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.base.util.collections.FlexibleMapAccessor;
import org.ofbiz.base.util.string.FlexibleStringExpander;
@@ -45,6 +46,8 @@ import org.ofbiz.service.LocalDispatcher
import org.ofbiz.webapp.control.ConfigXMLReader;
import org.ofbiz.webapp.control.RequestHandler;
import org.ofbiz.webapp.taglib.ContentUrlTag;
+import org.ofbiz.widget.ModelWidget.ShowPortletItemData;
+import org.ofbiz.widget.ModelWidget.ShowPortletLinkData;
import org.ofbiz.widget.form.ModelForm;
import org.ofbiz.widget.form.ModelFormField;
import org.w3c.dom.Element;
@@ -141,6 +144,12 @@ public class WidgetWorker {
}
}
+ //#Bam# portletWidget
+ public static void buildShowPortletUrl(Appendable externalWriter, String target, Map<String, String> parameterMap,
+ String prefix, boolean fullPath, boolean secure, boolean encode, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException {
+ }
+ //#Eam# portletWidget
+
public static void appendContentUrl(Appendable writer, String location, HttpServletRequest request) throws IOException {
StringBuilder buffer = new StringBuilder();
ContentUrlTag.appendContentPrefix(request, buffer);
@@ -319,12 +328,14 @@ public class WidgetWorker {
public static class Parameter {
protected String name;
protected FlexibleStringExpander value;
+ protected FlexibleStringExpander sendIfEmpty; //#Eam# portletWidget
protected FlexibleMapAccessor<Object> fromField;
public Parameter(Element element) {
this.name = element.getAttribute("param-name");
this.value = UtilValidate.isNotEmpty(element.getAttribute("value")) ? FlexibleStringExpander.getInstance(element.getAttribute("value")) : null;
this.fromField = UtilValidate.isNotEmpty(element.getAttribute("from-field")) ? FlexibleMapAccessor.getInstance(element.getAttribute("from-field")) : null;
+ this.sendIfEmpty = UtilValidate.isNotEmpty(element.getAttribute("send-if-empty")) ? FlexibleStringExpander.getInstance(element.getAttribute("send-if-empty")) : null; //#Eam# portletWidget
}
public Parameter(String paramName, String paramValue, boolean isField) {
@@ -389,6 +400,13 @@ public class WidgetWorker {
return null;
}
}
+ //#Bam# portletWidget
+ public boolean sendIfEmpty(Map<String, Object> context) {
+ if (this.sendIfEmpty != null)
+ return "true".equals(this.sendIfEmpty.expandString(context));
+ else return false;
+ }
+ //#Eam# portletWidget
}
public static String determineAutoLinkType(String linkType, String target, String targetType, HttpServletRequest request) {
@@ -476,4 +494,115 @@ public class WidgetWorker {
Delegator delegator = (Delegator) context.get("delegator");
return delegator;
}
+ //#Bam# portletWidget
+ /**
+ * Prepare data for Form and Menu show-portlet
+ */
+ public static ShowPortletLinkData prepareShowPortletLinkData(ModelWidget.ShowPortletLink showPortletLink, Map<String, Object> context) {
+ ShowPortletLinkData splData = new ShowPortletLinkData();
+ splData.imgSrc = showPortletLink.getImage(context);
+ if (UtilValidate.isEmpty(splData.imgSrc)) {
+ splData.imgSrc = "";
+ }
+ splData.imgTitle = showPortletLink.getImageTitle(context);
+ if (UtilValidate.isEmpty(splData.imgTitle)) {
+ splData.imgTitle = "";
+ }
+ splData.alt = showPortletLink.getAlternate(context);
+ if (UtilValidate.isEmpty(splData.alt)) {
+ splData.alt = "";
+ }
+ splData.description = showPortletLink.getDescription(context);
+ if(UtilValidate.isEmpty(splData.description)) {
+ splData.description = "";
+ }
+ return splData;
+ }
+ public static ShowPortletItemData prepareShowPortletItemsData(ModelWidget.ShowPortletItem showPortletItem, Map<String, Object> context) {
+ ShowPortletItemData spiData = new ShowPortletItemData();
+ spiData.portalPageId = showPortletItem.getPortalPageId(context);
+ spiData.portletId = showPortletItem.getPortletId(context);
+ spiData.portletSeqId = showPortletItem.getPortletSeqId(context);
+ if (UtilValidate.isEmpty(spiData.portalPageId) && context.containsKey("portalPageId")) {
+ spiData.portalPageId = (String) context.get("portalPageId");
+ }
+ // portletID is mandatory in show-portlet so, if value is null it's a choice
+ //if (UtilValidate.isEmpty(portletId) && context.containsKey("portalPortletId"))
+ // portletId = (String) context.get("portalPortletId");
+ if (UtilValidate.isEmpty(spiData.portletSeqId) && context.containsKey("portletSeqId")) {
+ spiData.portletSeqId = (String) context.get("portletSeqId");
+ }
+ spiData.areaId = showPortletItem.getAreaId(context);
+ if (UtilValidate.isEmpty(spiData.areaId)) {
+ if (UtilValidate.isNotEmpty(spiData.portalPageId) && UtilValidate.isNotEmpty(spiData.portletId) && UtilValidate.isNotEmpty(spiData.portletSeqId)) {
+ spiData.areaId = "PP_" + spiData.portalPageId + spiData.portletId + spiData.portletSeqId;
+ }
+ else {
+ //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);
+ }
+ }
+ spiData.target = "showPortlet";
+ if (UtilValidate.isNotEmpty(showPortletItem.getTarget(context))) {
+ spiData.target = showPortletItem.getTarget(context);
+ }
+
+ StringBuilder params = new StringBuilder();
+ Map<String, String> parameters = showPortletItem.getParameterMap(context);
+ for (String key : parameters.keySet()) {
+ WidgetWorker.addToParams(params, key, parameters.get(key));
+ }
+
+ if (UtilValidate.isNotEmpty(spiData.portalPageId)) {
+ WidgetWorker.addToParams(params, "portalPageId", spiData.portalPageId);
+ } else {
+ WidgetWorker.addToParamsIfInContext(params, context, "portalPageId", parameters);
+ }
+
+ if (UtilValidate.isNotEmpty(spiData.portletId)) {
+ WidgetWorker.addToParams(params, "portalPortletId", spiData.portletId);
+ }
+
+ if (UtilValidate.isNotEmpty(spiData.portletSeqId)) {
+ WidgetWorker.addToParams(params, "portletSeqId", spiData.portletSeqId);
+ } else {
+ WidgetWorker.addToParamsIfInContext(params, context, "portletSeqId", parameters);
+ }
+
+ WidgetWorker.addToParamsIfInContext(params, context, "areaId", parameters);
+ WidgetWorker.addToParamsIfInContext(params, context, "idDescription", parameters);
+ spiData.params = params;
+ return spiData;
+ }
+
+ /**
+ * if context.get(key) not empty or context.get(parameters.key) not empty and not already in parameters add key=keyValue in params
+ * @param params
+ * @param context
+ * @param key
+ * @param parameters
+ */
+ public static void addToParamsIfInContext(StringBuilder params, Map<String, Object> context, String key, Map<String, String> parameters) {
+ if (parameters.containsKey(key)) return;
+
+ String paramValue = (String) context.get(key);
+ if (UtilValidate.isEmpty(paramValue)) {
+ Map<String, Object> contextParameters = UtilGenerics.checkMap(context.get("parameters"));
+ paramValue = (String) contextParameters.get(key);
+ }
+ if (UtilValidate.isNotEmpty(paramValue)) {
+ if ("idDescription".equals(key)) {
+ addToParams(params, key, UtilURL.removeBadCharForUrl(paramValue));
+ }
+ else {
+ addToParams(params, key, paramValue);
+ }
+ }
+ }
+ public static void addToParams(StringBuilder params, String key, String oneParam) {
+ if (UtilValidate.isNotEmpty(params)) {
+ params.append("&");
+ }
+ params.append(key).append("=").append(oneParam);
+ }
+ //#Eam# portletWidget
}
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java Tue Aug 7 19:13:03 2012
@@ -48,6 +48,7 @@ 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.ShowPortletLink;
import org.ofbiz.widget.form.ModelFormField.SubmitField;
import org.ofbiz.widget.form.ModelFormField.TextField;
import org.ofbiz.widget.form.ModelFormField.TextFindField;
@@ -422,4 +423,7 @@ public class FoFormRenderer extends Html
public void renderContainerFindField(Appendable writer, Map<String, Object> context, ContainerField containerField) throws IOException {
}
+
+ public void renderShowPortletLink(Appendable writer, Map<String, Object> context, ShowPortletLink showPortletLink) {
+ }
}
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/FormStringRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/FormStringRenderer.java?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/FormStringRenderer.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/FormStringRenderer.java Tue Aug 7 19:13:03 2012
@@ -93,4 +93,6 @@ public interface FormStringRenderer {
public void renderContainerFindField(Appendable writer, Map<String, Object> context, ModelFormField.ContainerField containerField) throws IOException;
public void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException;
public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException;
+// public void renderShowPortletField(Appendable writer,Map<String, Object> context, ModelFormField.ShowPortletField showPortletField) throws IOException;
+ public void renderShowPortletLink(Appendable writer,Map<String, Object> context, ModelFormField.ShowPortletLink showPortletLink) throws IOException;
}
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Tue Aug 7 19:13:03 2012
@@ -38,7 +38,6 @@ import javax.servlet.http.HttpServletRes
import javolution.util.FastList;
-import org.apache.commons.lang.StringEscapeUtils;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.StringUtil;
import org.ofbiz.base.util.UtilFormatOut;
@@ -54,6 +53,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;
+import org.ofbiz.widget.ModelWidget.ShowPortletLinkData;
import org.ofbiz.widget.form.ModelFormField.CheckField;
import org.ofbiz.widget.form.ModelFormField.ContainerField;
import org.ofbiz.widget.form.ModelFormField.DateFindField;
@@ -71,6 +72,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;
+import org.ofbiz.widget.form.ModelFormField.ShowPortletLink;
import org.ofbiz.widget.form.ModelFormField.SubmitField;
import org.ofbiz.widget.form.ModelFormField.TextField;
import org.ofbiz.widget.form.ModelFormField.TextFindField;
@@ -331,6 +334,7 @@ public class MacroFormRenderer implement
public void renderTextField(Appendable writer, Map<String, Object> context, TextField textField) throws IOException {
ModelFormField modelFormField = textField.getModelFormField();
String name = modelFormField.getParameterName(context);
+ boolean validateLinkOnEnter = modelFormField.getModelForm().getValidateLinkOnEnter(); // #Eam# validate-form
String className = "";
String alert = "false";
String mask = "";
@@ -402,6 +406,18 @@ public class MacroFormRenderer implement
sr.append(" clientAutocomplete=\"");
sr.append(clientAutocomplete);
+ // #Bam# validate-form
+ if (validateLinkOnEnter) {
+ sr.append("\" validateLinkOnEnter=");
+ sr.append(Boolean.toString(validateLinkOnEnter));
+ sr.append(" validateLinkId=\"");
+ sr.append(modelFormField.getModelForm().getValidateLinkId());
+ } else{
+ sr.append("\" validateLinkOnEnter=");
+ sr.append(Boolean.toString(false));
+ sr.append(" validateLinkId=\"");
+ }
+ // #Eam# validate-form
sr.append("\" ajaxUrl=\"");
sr.append(ajaxUrl);
sr.append("\" ajaxEnabled=");
@@ -1136,8 +1152,14 @@ public class MacroFormRenderer implement
boolean ajaxEnabled = (updateAreas != null || UtilValidate.isNotEmpty(backgroundSubmitRefreshTarget)) && this.javaScriptEnabled;
String ajaxUrl = "";
+ String returnParams = ""; // #Eam# portletWidget
if (ajaxEnabled) {
+ /* #Bam# portletWidget
ajaxUrl = createAjaxParamsFromUpdateAreas(updateAreas, null, context);
+ */
+ returnParams = createReturnParamsFromUpdateAreas(updateAreas, context);
+ ajaxUrl = createAjaxParamsFromUpdateAreas(updateAreas, null, context, UtilValidate.isNotEmpty(returnParams));
+ // #Eam# portletWidget
}
StringWriter sr = new StringWriter();
sr.append("<@renderSubmitField ");
@@ -1173,6 +1195,10 @@ public class MacroFormRenderer implement
if (ajaxEnabled) {
sr.append(ajaxUrl);
}
+ //#Bam# portletWidget
+ sr.append("\" returnParams =\"");
+ sr.append(returnParams);
+ //#Eam# portletWidget
sr.append("\" />");
executeMacro(writer, sr.toString());
this.appendTooltip(writer, context, modelFormField);
@@ -1746,6 +1772,7 @@ public class MacroFormRenderer implement
public void renderTextFindField(Appendable writer, Map<String, Object> context, TextFindField textFindField) throws IOException {
ModelFormField modelFormField = textFindField.getModelFormField();
+ boolean validateLinkOnEnter = modelFormField.getModelForm().getValidateLinkOnEnter(); // #Eam# validate-form
String defaultOption = textFindField.getDefaultOption();
String className = "";
String alert = "false";
@@ -1821,6 +1848,19 @@ public class MacroFormRenderer implement
sr.append(maxlength);
sr.append("\" autocomplete=\"");
sr.append(autocomplete);
+ // #Bam# validate-form
+ if (validateLinkOnEnter) {
+ sr.append("\" validateLinkOnEnter=");
+ sr.append(Boolean.toString(validateLinkOnEnter));
+ sr.append(" validateLinkId=\"");
+ sr.append(modelFormField.getModelForm().getValidateLinkId());
+ }
+ else {
+ sr.append("\" validateLinkOnEnter=");
+ sr.append(Boolean.toString(false));
+ sr.append(" validateLinkId=\"");
+ }
+ // #Eam# validate-form
sr.append("\" titleStyle=\"");
sr.append(titleStyle);
sr.append("\" hideIgnoreCase=");
@@ -2915,6 +2955,12 @@ public class MacroFormRenderer implement
* @return Parameter string or empty string if no UpdateArea objects were found
*/
public String createAjaxParamsFromUpdateAreas(List<ModelForm.UpdateArea> updateAreas, String extraParams, Map<String, ? extends Object> context) {
+ // #Bam# portletWidget
+ return createAjaxParamsFromUpdateAreas(updateAreas, extraParams, context, false);
+ }
+
+ public String createAjaxParamsFromUpdateAreas(List<ModelForm.UpdateArea> updateAreas, String extraParams, Map<String, ? extends Object> context, boolean addReturnParams) {
+ // #Eam# portletWidget
//FIXME copy from HtmlFormRenderer.java
if (updateAreas == null) {
return "";
@@ -2951,6 +2997,18 @@ public class MacroFormRenderer implement
}
}
}
+ // #Bam# portletWidget
+ StringBuilder params = new StringBuilder();
+ params.append(ajaxParams);
+ List<String> addingParams = UtilMisc.toList("portalPageId", "portalPortletId", "portletSeqId", "areaId", "idDescription");
+ for (String addingParam : addingParams) {
+ if (UtilValidate.isNotEmpty(extraParams) && extraParams.contains(addingParam + "=")) {
+ continue;
+ }
+ WidgetWorker.addToParamsIfInContext(params, ctx, addingParam, parameters);
+ }
+ ajaxParams = params.toString();
+ // #Eam# portletWidget
//then add parameters from request. Those parameters could end with an anchor so we must set ajax parameters first
if (UtilValidate.isNotEmpty(extraParams)) {
if (ajaxParams.length() > 0 && !extraParams.startsWith("&")) {
@@ -2961,10 +3019,47 @@ public class MacroFormRenderer implement
ajaxUrl += updateArea.getAreaId() + ",";
ajaxUrl += this.rh.makeLink(this.request, this.response, UtilHttp.removeQueryStringFromTarget(targetUrl));
ajaxUrl += "," + ajaxParams;
+ // #Bam# portletWidget
+ if (addReturnParams) {
+ if(updateArea.hasRedirParamList()){
+ ajaxUrl += ",true";
+ } else {
+ ajaxUrl += ",false";
+ }
+
+ }
+ // #Eam# portletWidget
}
Locale locale = UtilMisc.ensureLocale(context.get("locale"));
return FlexibleStringExpander.expandString(ajaxUrl, context, locale);
}
+
+ // #Bam# portletWidget
+ public String createReturnParamsFromUpdateAreas(List<ModelForm.UpdateArea> updateAreas, Map<String, ? extends Object> context){
+ String returnParam = "";
+ boolean first = true;
+ for (ModelForm.UpdateArea updateArea : updateAreas) {
+ Map<String, Object> ctx = UtilGenerics.checkMap(context);
+ Map<String, String> redirectParameters = updateArea.getRedirParamList(ctx);
+ if(UtilValidate.isNotEmpty(redirectParameters)){
+ for (String key : redirectParameters.keySet()) {
+ if(first){
+ returnParam += "{'" + key + "' : '" + key + "'";
+ first = false;
+ }
+ else{
+ returnParam += ", '" + key + "' : '" + key + "'";
+ }
+ }
+ }
+ }
+ if (UtilValidate.isNotEmpty(returnParam)) {
+ returnParam += "}";
+ }
+ return returnParam;
+ }
+ // #Eam# portletWidget
+
/** 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.
@@ -3118,6 +3213,10 @@ public class MacroFormRenderer implement
sr.append(event);
sr.append("\" action=\"");
sr.append(action);
+ // #Bam# validate-form
+ sr.append("\" id=\"");
+ sr.append(modelFormField.getIdName());
+ // #Eam# validate-form
sr.append("\" imgSrc=\"");
sr.append(imgSrc);
sr.append("\" title=\"");
@@ -3137,6 +3236,221 @@ public class MacroFormRenderer implement
}
}
+ //#Bam# portletWidget
+ // same as HtmlFormRenderer except when populate StringWriter sr
+ 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(showPortletItem.getRequireConfirmation()) {
+ event = "onclick";
+ action = "return confirm('" + showPortletItem.getConfirmationMessage(context) +"')";
+ }
+ }
+ 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);
+ }
+ StringWriter sr = new StringWriter();
+ sr.append("<@rerenderRefreshPortlet ");
+ sr.append("linkStyle=\"");
+ sr.append(linkStyle);
+ sr.append("\" event=\"");
+ sr.append(event);
+ sr.append("\" action=\"");
+ sr.append(action);
+ sr.append("\" areaId=\"");
+ sr.append(showPortletLink.listToString(areasList));
+ sr.append("\" id=\"");
+ sr.append(id);
+ sr.append("\" formName=\"");
+ sr.append(formName);
+ sr.append("\" imgSrc=\"");
+ sr.append(splData.imgSrc);
+ sr.append("\" title=\"");
+ sr.append(splData.imgTitle);
+
+ sr.append("\" alternate=\"");
+ sr.append(splData.alt);
+ sr.append("\" target=\"");
+ sr.append(showPortletLink.listToString(targetList));
+ sr.append("\" appendFormParams=\"");
+ sr.append(showPortletLink.listToString(formList));
+ sr.append("\" description=\"");
+ sr.append(splData.description);
+ sr.append("\" params=\"");
+ sr.append(showPortletLink.listToString(paramsList));
+ sr.append("\" collapse=\"");
+ sr.append(Boolean.valueOf(collapseScreenlet).toString());
+ sr.append("\" markSelected=\"");
+ sr.append(Boolean.valueOf(markSelected).toString());
+ sr.append("\" />");
+ executeMacro(writer, sr.toString());
+ this.appendTooltip(writer, context, modelFormField);
+ }
+ //#Eam# portletWidget
+ // #Bam# portletWidget
+ public void makeShowPortletString(Appendable writer, String linkStyle, String targetArea, String target, String targetPortletId, Map<String, String> parameterMap,
+ String description, String collapse, ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context)
+ throws IOException {
+
+ StringBuilder linkUrl = new StringBuilder();
+
+ String event = "";
+ String action = "";
+ String parameterKey = "";
+ String parameterValue = "";
+ String parameterList = "";
+ String parameterForm = "";
+ String collapseScreenlet = "";
+ //String collapseScreenlet = collapse?"true":"";
+
+ if (UtilValidate.isNotEmpty(modelFormField.getEvent()) && UtilValidate.isNotEmpty(modelFormField.getAction(context))) {
+ event = modelFormField.getEvent();
+ action = modelFormField.getAction(context);
+ }
+
+ Integer size = Integer.valueOf("0");
+
+ if( UtilValidate.isNotEmpty(description) && size > 0 && description.length() > size) {
+ description = description.substring(0, size - 8) + "..." + description.substring(description.length() - 5);
+ }
+
+ if (UtilValidate.isNotEmpty(collapse)) {
+ collapseScreenlet = collapse;
+ }
+
+ /* manage parameters-form and parameter */
+
+ Appendable localWriter = new StringWriter();
+ boolean first = true;
+ if (UtilValidate.isNotEmpty(parameterMap)) {
+ //parameterForm = modelFormField.getModelForm().getName();
+ for (Map.Entry<String, String> parameter: parameterMap.entrySet()) {
+ if (parameter.getValue() instanceof String) {
+ parameterKey = parameter.getKey();
+ parameterValue = parameter.getValue();
+ if(first){
+ // targetPortletId is required for show-portlet
+ parameterList += "{'portalPortletId':'" + targetPortletId + "', '" + parameterKey + "':'" + parameterValue + "'";
+ first = false;
+ }
+ else{
+ parameterList += ", '" + parameterKey + "':'" + parameterValue + "'";
+ }
+ } else {
+ Object parameterObject = parameter.getValue();
+
+ // skip null values
+ if (parameterObject == null){
+ parameterForm = modelFormField.getModelForm().getName();
+ }
+ else if (parameterObject instanceof String[]) {
+ // it's probably a String[], just get the first value
+ String[] parameterArray = (String[]) parameterObject;
+ parameterValue = parameterArray[0];
+ Debug.logInfo("Found String array value for parameter [" + parameter.getKey() + "], using first value: " + parameterValue, module);
+ } else {
+ // not a String, and not a String[], just use toString
+ parameterValue = parameterObject.toString();
+ }
+ }
+ }
+ if(!first){ // this means that we reached the end and the list wasn't void since we read a first element
+ parameterList += "}";
+ }
+ } else {
+ linkUrl.append(localWriter.toString());
+ }
+
+ StringWriter sr = new StringWriter();
+ sr.append("<@makeShowPortletString ");
+ sr.append("linkStyle=\"");
+ sr.append(linkStyle==null?"":linkStyle);
+ sr.append("\" id=\"");
+ sr.append(modelFormField.getIdName());
+ sr.append("\" event=\"");
+ sr.append(event);
+ sr.append("\" action=\"");
+ sr.append(action);
+ sr.append("\" target=\"");
+ sr.append(target);
+ sr.append("\" targetArea=\"");
+ sr.append(targetArea);
+ sr.append("\" targetPortletId=\"");
+ sr.append(targetPortletId);
+ sr.append("\" description=\"");
+ sr.append(description);
+ sr.append("\" parameterForm=\"");
+ sr.append(parameterForm);
+ sr.append("\" parameterList=\"");
+ sr.append(parameterList);
+ sr.append("\" collapse=\"");
+ sr.append(collapseScreenlet);
+
+ sr.append("\" />");
+ executeMacro(writer, sr.toString());
+ }
+ // #Eam# portletWidget
+
public void makeHiddenFormLinkAnchor(Appendable writer, String linkStyle, String description, String confirmation , ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException {
if (UtilValidate.isNotEmpty(description) || UtilValidate.isNotEmpty(request.getAttribute("image"))) {
String hiddenFormName = WidgetWorker.makeLinkHiddenFormName(context, modelFormField);
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/ModelForm.java?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/ModelForm.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Tue Aug 7 19:13:03 2012
@@ -89,6 +89,7 @@ public class ModelForm extends ModelWidg
protected String tooltip;
protected String listName;
protected String listEntryName;
+ protected String validateLinkId; // #Eam# validateForm
protected FlexibleMapAccessor<Map<String, ? extends Object>> defaultMapName;
protected String defaultEntityName;
protected String defaultServiceName;
@@ -115,6 +116,7 @@ public class ModelForm extends ModelWidg
protected boolean separateColumns = false;
protected boolean groupColumns = true;
protected boolean useRowSubmit = false;
+ protected boolean validateLinkOnEnter = false; // #Eam# validateForm
protected FlexibleStringExpander targetWindowExdr;
protected String defaultRequiredFieldStyle;
protected String defaultSortFieldStyle;
@@ -273,6 +275,7 @@ public class ModelForm extends ModelWidg
this.tooltip = parent.tooltip;
this.listName = parent.listName;
this.listEntryName = parent.listEntryName;
+ this.validateLinkId = parent.validateLinkId;// #Eam# validateForm
this.tooltip = parent.tooltip;
this.defaultEntityName = parent.defaultEntityName;
this.defaultServiceName = parent.defaultServiceName;
@@ -487,6 +490,15 @@ public class ModelForm extends ModelWidg
this.rowCountExdr = FlexibleStringExpander.getInstance(formElement.getAttribute("row-count"));
}
+ //#Bam# : validateForm
+ if (this.validateLinkId == null || formElement.hasAttribute("validate-link-id")) {
+ this.validateLinkId = formElement.getAttribute("validate-link-id");
+ }
+ if ( formElement.hasAttribute("validate-link-on-enter")) {
+ this.validateLinkOnEnter = "true".equalsIgnoreCase(formElement.getAttribute("validate-link-on-enter"));
+ }
+ //#Eam# : validateForm
+
//alt-row-styles
for (Element altRowStyleElement : UtilXml.childElementList(formElement, "alt-row-style")) {
AltRowStyle altRowStyle = new AltRowStyle(altRowStyleElement);
@@ -837,7 +849,10 @@ public class ModelForm extends ModelWidg
*/
public void renderFormString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException {
// increment the paginator, only for list and multi forms
+ Boolean PAGINATOR_AND_ACTION_DONE = null; // #Eam# screenlet navigationForm
if ("list".equals(this.type) || "multi".equals(this.type)) {
+ Map<String, Object> globalCtx = UtilGenerics.checkMap(context.get("globalContext")); // #Eam# screenlet navigationForm
+ PAGINATOR_AND_ACTION_DONE = (Boolean) globalCtx.get("NO_PAGINATOR"); // #Eam# screenlet navigationForm
WidgetWorker.incrementPaginatorNumber(context);
}
@@ -850,7 +865,9 @@ public class ModelForm extends ModelWidg
context.put("viewIndex", this.getViewIndex(context));
context.put("viewSize", this.getViewSize(context));
- runFormActions(context);
+ if (UtilValidate.isEmpty(PAGINATOR_AND_ACTION_DONE)) { // #Eam# screenlet navigationForm
+ runFormActions(context);
+ } // #Eam# screenlet navigationForm
// if this is a list form, don't useRequestParameters
if ("list".equals(this.type) || "multi".equals(this.type)) {
@@ -1241,7 +1258,11 @@ public class ModelForm extends ModelWidg
continue;
}
+ /* #Bam# portletWidget
if (fieldInfo.getFieldType() != ModelFormField.FieldInfo.DISPLAY && fieldInfo.getFieldType() != ModelFormField.FieldInfo.DISPLAY_ENTITY && fieldInfo.getFieldType() != ModelFormField.FieldInfo.HYPERLINK) {
+ */
+ if (fieldInfo.getFieldType() != ModelFormField.FieldInfo.DISPLAY && fieldInfo.getFieldType() != ModelFormField.FieldInfo.DISPLAY_ENTITY && fieldInfo.getFieldType() != ModelFormField.FieldInfo.HYPERLINK && fieldInfo.getFieldType() != ModelFormField.FieldInfo.SHOW_PORTLET) {
+ // #Eam# portletWidget
inputFieldFound = true;
continue;
}
@@ -1265,7 +1286,11 @@ public class ModelForm extends ModelWidg
}
// skip all of the display/hyperlink fields
+ /* #Bam# portletWidget
if (fieldInfo.getFieldType() == ModelFormField.FieldInfo.DISPLAY || fieldInfo.getFieldType() == ModelFormField.FieldInfo.DISPLAY_ENTITY || fieldInfo.getFieldType() == ModelFormField.FieldInfo.HYPERLINK) {
+ */
+ if (fieldInfo.getFieldType() == ModelFormField.FieldInfo.DISPLAY || fieldInfo.getFieldType() == ModelFormField.FieldInfo.DISPLAY_ENTITY || fieldInfo.getFieldType() == ModelFormField.FieldInfo.HYPERLINK || fieldInfo.getFieldType() == ModelFormField.FieldInfo.SHOW_PORTLET) {
+ // #Eam# portletWidget
continue;
}
@@ -1598,7 +1623,11 @@ public class ModelForm extends ModelWidg
continue;
}
+ /* #Bam# portletWidget
if (fieldInfo.getFieldType() != ModelFormField.FieldInfo.DISPLAY && fieldInfo.getFieldType() != ModelFormField.FieldInfo.DISPLAY_ENTITY && fieldInfo.getFieldType() != ModelFormField.FieldInfo.HYPERLINK) {
+ */
+ if (fieldInfo.getFieldType() != ModelFormField.FieldInfo.DISPLAY && fieldInfo.getFieldType() != ModelFormField.FieldInfo.DISPLAY_ENTITY && fieldInfo.getFieldType() != ModelFormField.FieldInfo.HYPERLINK && fieldInfo.getFieldType() != ModelFormField.FieldInfo.SHOW_PORTLET) {
+ // #Eam# portletWidget
// okay, now do the form cell
break;
}
@@ -1622,7 +1651,11 @@ public class ModelForm extends ModelWidg
}
// skip all of the display/hyperlink fields
+ /* #Bam# portletWidget
if (fieldInfo.getFieldType() == ModelFormField.FieldInfo.DISPLAY || fieldInfo.getFieldType() == ModelFormField.FieldInfo.DISPLAY_ENTITY || fieldInfo.getFieldType() == ModelFormField.FieldInfo.HYPERLINK) {
+ */
+ if (fieldInfo.getFieldType() == ModelFormField.FieldInfo.DISPLAY || fieldInfo.getFieldType() == ModelFormField.FieldInfo.DISPLAY_ENTITY || fieldInfo.getFieldType() == ModelFormField.FieldInfo.HYPERLINK || fieldInfo.getFieldType() == ModelFormField.FieldInfo.SHOW_PORTLET) {
+ // #Bam# portletWidget
continue;
}
@@ -1644,7 +1677,11 @@ public class ModelForm extends ModelWidg
}
// skip all non-display and non-hyperlink fields
+ /* #Bam# portletWidget
if (fieldInfo.getFieldType() != ModelFormField.FieldInfo.DISPLAY && fieldInfo.getFieldType() != ModelFormField.FieldInfo.DISPLAY_ENTITY && fieldInfo.getFieldType() != ModelFormField.FieldInfo.HYPERLINK) {
+ */
+ if (fieldInfo.getFieldType() != ModelFormField.FieldInfo.DISPLAY && fieldInfo.getFieldType() != ModelFormField.FieldInfo.DISPLAY_ENTITY && fieldInfo.getFieldType() != ModelFormField.FieldInfo.HYPERLINK && fieldInfo.getFieldType() != ModelFormField.FieldInfo.SHOW_PORTLET) {
+ // #Eam# portletWidget
continue;
}
@@ -2706,6 +2743,16 @@ public class ModelForm extends ModelWidg
return this.useRowSubmit;
}
+ //#Bam# : validateForm
+ public boolean getValidateLinkOnEnter() {
+ return this.validateLinkOnEnter;
+ }
+
+ public String getValidateLinkId() {
+ return this.validateLinkId;
+ }
+ //#Eam# : validateForm
+
public List<ModelFormField> getMultiSubmitFields() {
return this.multiSubmitFields;
}
@@ -2839,6 +2886,7 @@ public class ModelForm extends ModelWidg
protected String areaId;
protected String areaTarget;
List<WidgetWorker.Parameter> parameterList =FastList.newInstance();
+ List<WidgetWorker.Parameter> redirParameterList =FastList.newInstance(); // #Eam# portletWidget
/** XML constructor.
* @param updateAreaElement The <code><on-xxx-update-area></code>
* XML element.
@@ -2851,6 +2899,12 @@ public class ModelForm extends ModelWidg
for (Element parameterElement: parameterElementList) {
this.parameterList.add(new WidgetWorker.Parameter(parameterElement));
}
+ // #Bam# portletWidget
+ parameterElementList = UtilXml.childElementList(updateAreaElement, "redirect-parameter");
+ for (Element parameterElement: parameterElementList) {
+ this.redirParameterList.add(new WidgetWorker.Parameter(parameterElement));
+ }
+ // #Eam# portletWidget
}
/** String constructor.
* @param areaId The id of the widget element to be updated
@@ -2881,6 +2935,25 @@ public class ModelForm extends ModelWidg
public Map<String, String> getParameterMap(Map<String, Object> context) {
Map<String, String> fullParameterMap = FastMap.newInstance();
for (WidgetWorker.Parameter parameter: this.parameterList) {
+ // #Bam# portletWidget : add property sendIfEmpty in parameters
+ String paramValue = parameter.getValue(context);
+ if (UtilValidate.isNotEmpty(paramValue) || parameter.sendIfEmpty(context)){
+ fullParameterMap.put(parameter.getName(), parameter.getValue(context));
+ }
+ // #Eam# portletWidget
+ }
+
+ return fullParameterMap;
+ }
+ // #Bam# portletWidget
+ public boolean hasRedirParamList() {
+ return UtilValidate.isNotEmpty(this.redirParameterList);
+ }
+
+ public Map<String, String> getRedirParamList(Map<String, Object> context) {
+ Map<String, String> fullParameterMap = FastMap.newInstance();
+ for (WidgetWorker.Parameter parameter: this.redirParameterList) {
+ // #Eam# portletWidget
fullParameterMap.put(parameter.getName(), parameter.getValue(context));
}
Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java?rev=1370439&r1=1370438&r2=1370439&view=diff
==============================================================================
--- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java (original)
+++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java Tue Aug 7 19:13:03 2012
@@ -273,31 +273,37 @@ public abstract class ModelFormAction {
}
public static class Script extends ModelFormAction {
- protected String location;
- protected String method;
+ protected FlexibleStringExpander scriptLocationExdr;
public Script(ModelForm modelForm, Element scriptElement) {
super (modelForm, 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) {
+ 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.modelForm.dispatchContext;
- 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 IllegalArgumentException("Error running simple method at location [" + location + "]", e);
}
} else {
- ScriptUtil.executeScript(this.location, this.method, context);
+ ScriptUtil.executeScript(location, method, context);
}
}
}