小编Rom*_*nin的帖子

CMS 组件渲染器与控制器之间的区别

我们正在使用 Hybris v5.7,我已经向项目添加了一个插件。我想渲染一些 CMS 组件,我发现有两种方法可以填充渲染组件的模型对象:创建 DefaultAddOnCMSComponentRenderer 或 AbstractCMSAddOnComponentController 的子类并将其注册为 bean。哪种方法更好?也许这些方法之一已经过时了?

@Controller
@RequestMapping("/view/MarketingNotificationFormComponentController")
public class MarketingNotificationFormComponentController extends AbstractCMSAddOnComponentController<MarketingNotificationFormComponentModel> {
    @Override
    protected void fillModel(HttpServletRequest request, Model model, MarketingNotificationFormComponentModel component) {
        //populate model here
    }
}
Run Code Online (Sandbox Code Playgroud)

或者

public class MarketingNotificationFormComponentRenderer extends DefaultAddOnCMSComponentRenderer<MarketingNotificationFormComponentModel> {
    @Override
    protected Map<String, Object> getVariablesToExpose(PageContext pageContext, MarketingNotificationFormComponentModel component) {
        Map<String, Object> variables = new HashMap<String, Object>();
        // populate model here
        return variables;
    }
}
Run Code Online (Sandbox Code Playgroud)

sap-commerce-cloud

6
推荐指数
1
解决办法
2304
查看次数

标签 统计

sap-commerce-cloud ×1