我们正在使用 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)