Creating the summary for the price rule element
About this task
Typically, summary text can be either static text or a combination of static and dynamic text. In the previous example, all the text is static except for the actual date. This date changes dynamically depending on the date the business user specifies in the properties of the condition. You can review additional examples of summaries by looking at other price rule conditions and actions in Management Center.
Consider using the summary of an existing file, similar price rule element as a starting point for your new price rule element. The existing summary files are stored here:
LOBTools/WebContent/WEB-INF/src/xml/commerce/price/restricted/propertiesViews/priceRuleBuilder/
Procedure
- Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
- Create a directory to store your new summary file.
Use a directory structure similar to the following example:
LOBTools/WebContent/WEB-INF/src/xml/your_company_name/price/propertiesViews/priceRuleBuilder/
-
Create an XML file with this syntax:
pricerule_element_nameSummary.xml
, for example, RegistrationTimeConditionSummary.xml. -
Define the new summary.
Here is the code that produces the summary class in the previous example, based on the default DateConditionFlowElementSummary.xml file:
<Definitions> <FlowElementSummary classDefinition="true" definitionName="cmc/price/RegistrationTimeConditionElementSummary"> <dependency localName="priceResources" moduleName="cmc/price/PriceResources"/> <dependency localName="DateUtil" moduleName="cmc/foundation/DateUtil"/> <dependency localName="PreferenceManager" moduleName="cmc/shell/PreferenceManager"/> <FlowSummaryParam name="startDate" propertyName="startDate"/> <FlowSummaryParam name="endDate" propertyName="endDate"/> <!--- @keywords private --> <handler name="oninit"> <![CDATA[ this.updateSummaryDel.connect(priceResources.Singleton.startDate, "onstring"); this.updateSummaryDel.connect(priceResources.Singleton.endDate, "onstring"); this.updateSummaryDel.connect(PreferenceManager.Singleton, "preferenceChanged"); ]]> </handler> <method args="e" name="updateSummary"> <![CDATA[ if (typeof(e) == "undefined") e = null; var summaryText = ""; var tooltipText = ""; var startDate = this.resolvedParams.startDate; var endDate = this.resolvedParams.endDate; var sDate = DateUtil.Singleton.parse(startDate, DateUtil.Singleton.DATE_TIME_FORMAT); startDate = DateUtil.Singleton.formatUI(sDate, DateUtil.Singleton.UI_DATE_TIME_FORMAT); var eDate = DateUtil.Singleton.parse(endDate, DateUtil.Singleton.DATE_TIME_FORMAT); endDate = DateUtil.Singleton.formatUI(eDate, DateUtil.Singleton.UI_DATE_TIME_FORMAT); if (startDate != "") { summaryText = priceResources.Singleton.replaceValues("summary_startDate", [startDate]); tooltipText = priceResources.Singleton.replaceValues("summary_startDate", [startDate]); } if (endDate != "") { summaryText += ", " + priceResources.Singleton.replaceValues("summary_endDate", [endDate]); tooltipText += ", " + priceResources.Singleton.replaceValues("summary_endDate", [endDate]); } this.setSummaryText(summaryText); this.setTooltipText(tooltipText); ]]> </method> </FlowElementSummary> </Definitions>
Where:- The updateSummary method sets the summary text for the price rule element.
- The updateSummary method must call the setSummaryText method with the summary text.
-
Register this new summary as an object definition.
Create a RegistrationTimeFlowElementObjectDefinition.xml file similar to the object definition files in LOBTools/WebContent/WEB-INF/src/xml/commerce/price/objectDefinitions/priceRuleBuilder/