2023 Jan 12 1:56 PM
I have a created a video component in homepage and i want to show that component to the cusotmer whose order history is having order as completed. I have done few of the things but not getting the last kick.I am not able to deal with enum in the getView method.
package de.hybris.training.storefront.controllers.cms;
import de.hybris.platform.acceleratorstorefrontcommons.controllers.cms.AbstractCMSComponentController;
import de.hybris.platform.commercefacades.order.OrderFacade;
import de.hybris.platform.commercefacades.order.data.OrderHistoryData;
import de.hybris.platform.commerceservices.search.pagedata.PageableData;
import de.hybris.platform.commerceservices.search.pagedata.SearchPageData;
import de.hybris.platform.core.enums.OrderStatus;
import de.hybris.training.core.model.components.TrainingVideoComponentModel;
import de.hybris.training.storefront.controllers.ControllerConstants;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.BooleanUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Controller for CMS HomePageVideoComponent
*/
@Controller("TrainingVideoCMSComponentController")
@RequestMapping(value = ControllerConstants.Actions.Cms.TrainingVideoCmsComponent)
public class TrainingVideoCMSComponentController extends AbstractCMSComponentController<TrainingVideoComponentModel>
{
@Resource(name = "orderFacade")
private OrderFacade orderFacade;
@Override
protected void fillModel(final HttpServletRequest request, final Model model, final TrainingVideoComponentModel component)
{
// Auto-generated method stub
model.addAttribute("width", component.getWidth());
model.addAttribute("height", component.getHeight());
model.addAttribute("videoId", component.getVideoId());
model.addAttribute("autoPlay", BooleanUtils.toBoolean(component.getAutoPlay()) ? 1 : 0);
model.addAttribute("showControls", BooleanUtils.toBoolean(component.getShowControls()) ? 1 : 0);
}
@Override
protected String getView(final TrainingVideoComponentModel component)
{
// Auto-generated method stub
final PageableData pageableData = new PageableData();
pageableData.setPageSize(1);
final SearchPageData<OrderHistoryData> orderHistoryData = orderFacade.getPagedOrderHistoryForStatuses(pageableData,
OrderStatus.COMPLETED);
if (OrderStatus.COMPLETED != null)
{
return getView(component);
}
else
{
return null;
}
}
}
I have to make changes in the controller.
So, I took one method from Order Facade that is returning the order history of the current user with giving two parameters out one is Order status. I used this method but not getting how to process furthered. I am slo not sured that the return statement for my view is correct or not.
2023 Jan 12 1:56 PM
Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with: https://community.sap.com/resources/questions-and-answers, as it provides tips for preparing questions that draw responses from our members.
For example, you can:
- outline what steps you took to find answers (and why they weren't helpful)
- share screenshots of what you've seen/done
- make sure you've applied the appropriate tags
- use a more descriptive subject line
The more details you provide, the more likely it is that members will be able to respond. Feel free to also take our Q&A tutorial at: https://developers.sap.com/tutorials/community-qa.html
Should you wish, you can revise your question by selecting Actions, then Edit.
By adding a picture to your profile you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html
Questions on how to draw responses from members? Check out this discussion on how to improve questions. https://groups.community.sap.com/t5/welcome-corner-discussions/advice-from-sap-champions-questions-a...