Skip to content

Commit

Permalink
Improved: add auto-parameters-portlet as children of (OFBIZ-11771) ev…
Browse files Browse the repository at this point in the history
…ent-update-area (field and form).

auto-parameters-portlet add for parameters in parameters-map:
- portalPageId
- portalPortletId
- portletSeqId
- currentAreaId
auto-parameters-portlet is used by showPortlet to be able to renderer
only one portlet, because often, it's necessary to have the 4 parameters
for a future other update (ex: button back)
  • Loading branch information
holivier committed Jun 1, 2020
1 parent 56f9dc8 commit 358370e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
8 changes: 8 additions & 0 deletions framework/widget/dtd/widget-common.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,13 @@ under the License.
<xs:attribute name="send-if-empty" type="xs:boolean" default="true"/>
</xs:complexType>
</xs:element>
<xs:element name="auto-parameters-portlet">
<xs:annotation>
<xs:documentation>Generate 4 parameters : portalPageId, portalPortletId, portletSeqId and currentAreaId update from-field parameters.xxx</xs:documentation>
</xs:annotation>
<xs:complexType>
</xs:complexType>
</xs:element>
<xs:element name="exclude">
<xs:complexType>
<xs:attribute name="field-name" type="xs:string" use="required" />
Expand All @@ -525,6 +532,7 @@ under the License.
<xs:element minOccurs="0" ref="auto-parameters-service"/>
<xs:element minOccurs="0" ref="auto-parameters-entity"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="parameter" />
<xs:element minOccurs="0" ref="auto-parameters-portlet"/>
<xs:element minOccurs="0" name="image" type="image" />
</xs:sequence>
<xs:attribute type="xs:string" name="text" />
Expand Down
2 changes: 2 additions & 0 deletions framework/widget/dtd/widget-form.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ under the License.
<xs:element minOccurs="0" ref="auto-parameters-service"/>
<xs:element minOccurs="0" ref="auto-parameters-entity"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="parameter" />
<xs:element minOccurs="0" ref="auto-parameters-portlet"/>
</xs:sequence>
<xs:attribute name="event-type" use="required">
<xs:annotation>
Expand Down Expand Up @@ -1553,6 +1554,7 @@ under the License.
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="parameter" />
<xs:element minOccurs="0" ref="auto-parameters-portlet"/>
</xs:sequence>
<xs:attribute name="event-type" use="required">
<xs:annotation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,22 @@ public Link(Element linkElement) {
this.linkType = linkElement.getAttribute("link-type");
}
List<? extends Element> parameterElementList = UtilXml.childElementList(linkElement, "parameter");
if (parameterElementList.isEmpty()) {
boolean autoPortletParamsElement = UtilXml.firstChildElement(linkElement, "auto-parameters-portlet") == null ? false : true;
if (parameterElementList.isEmpty() && ! autoPortletParamsElement) {
this.parameterList = Collections.emptyList();
} else {
int paramListSize = parameterElementList.size() + (autoPortletParamsElement ? 4 : 0);
List<Parameter> parameterList = new ArrayList<>(
parameterElementList.size());
paramListSize);
for (Element parameterElement : parameterElementList) {
parameterList.add(new Parameter(parameterElement));
}
if (autoPortletParamsElement) {
parameterList.add(new CommonWidgetModels.Parameter("portalPageId", "parameters.portalPageId", true));
parameterList.add(new CommonWidgetModels.Parameter("portalPortletId", "parameters.portalPortletId", true));
parameterList.add(new CommonWidgetModels.Parameter("portletSeqId", "parameters.portletSeqId", true));
parameterList.add(new CommonWidgetModels.Parameter("currentAreaId", "parameters.currentAreaId", true));
}
this.parameterList = Collections.unmodifiableList(parameterList);
}
Element autoServiceParamsElement = UtilXml.firstChildElement(linkElement, "auto-parameters-service");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1750,13 +1750,21 @@ public UpdateArea(Element updateAreaElement, String defaultServiceName, String d
this.defaultServiceName = defaultServiceName;
this.defaultEntityName = defaultEntityName;
List<? extends Element> parameterElementList = UtilXml.childElementList(updateAreaElement, "parameter");
if (parameterElementList.isEmpty()) {
boolean autoPortletParamsElement = UtilXml.firstChildElement(updateAreaElement, "auto-parameters-portlet") == null ? false : true;
if (parameterElementList.isEmpty() && ! autoPortletParamsElement) {
this.parameterList = Collections.emptyList();
} else {
List<CommonWidgetModels.Parameter> parameterList = new ArrayList<>(parameterElementList.size());
int paramListSize = parameterElementList.size() + (autoPortletParamsElement ? 4 : 0);
List<CommonWidgetModels.Parameter> parameterList = new ArrayList<>(paramListSize);
for (Element parameterElement : parameterElementList) {
parameterList.add(new CommonWidgetModels.Parameter(parameterElement));
}
if (autoPortletParamsElement) {
parameterList.add(new CommonWidgetModels.Parameter("portalPageId", "parameters.portalPageId", true));
parameterList.add(new CommonWidgetModels.Parameter("portalPortletId", "parameters.portalPortletId", true));
parameterList.add(new CommonWidgetModels.Parameter("portletSeqId", "parameters.portletSeqId", true));
parameterList.add(new CommonWidgetModels.Parameter("currentAreaId", "parameters.currentAreaId", true));
}
this.parameterList = Collections.unmodifiableList(parameterList);
}
Element autoServiceParamsElement = UtilXml.firstChildElement(updateAreaElement, "auto-parameters-service");
Expand Down

0 comments on commit 358370e

Please sign in to comment.