如何从CalculationResultView类调用自定义方法 [英] How to call custom methods from CalculationResultView class

查看:46
本文介绍了如何从CalculationResultView类调用自定义方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用自定义方法(例如)实现了自定义计算视图类."getMonthlyDiscount","getMonthlyPrice"等,并将其在组件框架中注册到BasketBOCalculationResultViewExtensionFactory.问题是我们无法找到有关如何调用这些方法以获取计算结果的信息.

通过调用"basketbo.getExtension(BasketBOCalculationResultViewExtension.class)",我们将获得"BasketBOCalculationResultViewExtensionImpl",因此仅在"LineItemCtnrCalculationResultViewProxy"中定义的方法可用,而不是我们的自定义.

同一示例可以应用于如何从此处给出的TutorialCalculationResultView中调用方法"getDuties"的问题:解决方案

除了威廉姆斯的答案:

如果您使用的是ICM版本> = 7.10.8.0,则应该能够通过以下方式检索 TutorialCalculationResultView :

  LineItemCtnrCalculationResultViewProxy resultViewProxy = basketBO.getExtension("CalculationResultView");TutorialCalculationResultView resultView =(TutorialCalculationResultView)resultViewProxy.getDelegate(); 

如果您使用的是7.10.8.0之前的版本,并且已获得Intershop支持合同,则可以随时尝试向Intershop技术支持询问是否可以向下移植此功能.

或者,如果 TutorialCalculationResultView 中的自定义方法很简单,并且仅通过关联的 CalculationRuleSet 的值,那么您还可以使用以下方法之一: BasketBOCalculationResultViewExtension 直接获取值:

 //返回组中的单个项目ComputedItem getComputedItem(String group,String id);//返回整个组Collection< ComputedItem>getComputedItems(String group); 

We implemented custom calculation view class with custom methods e.g. "getMonthlyDiscount", "getMonthlyPrice", etc. and registered it with component framework to BasketBOCalculationResultViewExtensionFactory. The problem is we are unable to find information of how to call those methods to get calculated results.

By calling "basketbo.getExtension(BasketBOCalculationResultViewExtension.class)" we get "BasketBOCalculationResultViewExtensionImpl", so only methods defined in "LineItemCtnrCalculationResultViewProxy" are available, not our custom.

The same example can be applied to question of how to call method "getDuties" from TutorialCalculationResultView given here: https://support.intershop.com/kb/index.php/Display/23V395#Cookbook-BasketCalculation-Recipe:TheResultView

Thank you for your answers! Kind regards

解决方案

In addition to Willem's answer:

If you're using an ICM version >= 7.10.8.0 you should be able to retrieve your TutorialCalculationResultView via:

LineItemCtnrCalculationResultViewProxy resultViewProxy = basketBO.getExtension("CalculationResultView");
TutorialCalculationResultView resultView = (TutorialCalculationResultView)resultViewProxy.getDelegate();

If you're using a version before 7.10.8.0 and have an Intershop support contract, you could always try asking Intershop tech support if this feature could be downported.

Alternatively, if the custom methods in your TutorialCalculationResultView are simple and only pass through the values of the associated CalculationRuleSet, then you can also use one of the following methods from the BasketBOCalculationResultViewExtension to retrieve the value directly:

// returns a single item from the group
ComputedItem getComputedItem(String group, String id);
// returns the whole group
Collection<ComputedItem> getComputedItems(String group);

这篇关于如何从CalculationResultView类调用自定义方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆