Saturday, November 16, 2013

Websphere Commerce: Setting the view in a ControllerCommand

In the performExecute() method of the controller command, set the view in the response properties like:

     TypedProperty responseProperties = getResponseProperties();
     responseProperties.put(ECConstants.EC_VIEWTASKNAME, "MyNewView"); 
     setResponseProperties(responseProperties);


     OR

     TypedProperty responseProperties = getResponseProperties();
     responseProperties.put(“viewTaskName”, "MyNewView"); 
     setResponseProperties(responseProperties);



 When redirecting the view to the same jsp page do:

         responseProperties.put("redirecturl", "CustomerAccountForm");
         responseProperties.put("viewTaskName", "RedirectView");
         setResponseProperties(responseProperties);


where: CustomerAccountForm is the URL mapped to the same jsp page, i.e. CustomerAccount.jsp


For Commerce built- in commands (blackbox):

See IBM infocenter’s documentation for the command’s implementation class (cmdimpl).

Example -  RequisitionListDisplayCmdImpl:

IBM Documentation states that  for the View:
  • If requisitionListId is specified, it sets RequisitionListDetailView.
  • If requisitionListId is not specified, it sets RequisitionListView.

So, in order to return a view for this command, you need to map either the RequisitionListView or RequisitionListDetailView url to a jsp file in your configuration file (such as struts-config.xml file).

No comments:

Post a Comment