Develop > Presentation layer > WebSphere Commerce integration with WebSphere Portal > Customize WebSphere Commerce Portal integration > Use the provided WebSphere Commerce MVCPortlet class (MVC style) > Using WebSphere Commerce services in portlets


Call a WebSphere Commerce service using the MVC portlet configuration file

Use the MVC portlet configuration file, portlet-config.xml, to call a WebSphere Commerce service without writing any additional code.

To use the MVC portlet configuration file to call a WebSphere Commerce service:

  1. Open the MVCPortlet_installdir/WEB-INF/portlet.xml file.

  2. Find the <portlet> element for the portlet that to configure. In that section is an <init-param> element with a <name> of wc.config.files. The <value> for this element is the location of the portlet-config.xml file.

  3. Open the portlet-config.xml file in the Rational Application Developer.

  4. To call a WebSphere Commerce service, add an <action> element. For example, the following element calls the updatePerson() method on the Member client library:

    <action className="com.ibm.commerce.foundation.client.portal.handlers.MVCPortletActionHandler"
     name="ChangePersonalInformation">  
    <set-property name="clientLibrary" value="com.ibm.commerce.member.facade.client.MemberFacadeClient" />  
    <set-property name="clientMethod" value="updatePerson" />  
    <set-property name="renderName" value="ChangePersonalInformationDisplay" />  
    <set-property name="session" value="true" />
    </action>
    <render className="com.ibm.commerce.foundation.client.portal.handlers.MVCPortletRenderHandler"
     name="ChangePersonalInformationDisplay">  
    <forward mode="view" path="/member/ChangePersonalInformationDisplay.jsp" />  
    <set-property name="session" value="true" />
    </render>
    

  5. Add a link to call the <action> from a JSP file. For example, the actionURL below calls the ChangePersonalInformation action we defined in step 2:

    <portlet:actionURL var="ChangePersonalInformationActionURL"> 
    <portlet:param name="actionName" value="ChangePersonalInformation" /> 
    <portlet:param name="renderName" value="AccountDisplay" /> 
    <portlet:param name="faultRenderName" value="ChangePersonalInformationDisplay" />
    </portlet:actionURL> 
    <form name="ChangePersonalInformation" method="post"
     action="<c:out value='${ChangePersonalInformationActionURL}' />"> 
    ......
    
    </form>
    

    The action is called and then forwards to the AccountDisplay render. If there is an error, it forwards to the ChangePersonalInformationDisplay render, which returns to the original JSP file. An error message will be added to the request parameter. It can be retrieved from the request parameter map by using the name "errorMessage".


Related concepts

WebSphere Commerce portlet action handler

Business context plug-in

WebSphere Commerce portlet render handler

WebSphere Commerce integration with WebSphere Portal

Use WebSphere Commerce services in portlets

WebSphere Commerce Portal integration event handlers

Related reference

MVC portlet configuration file syntax


+

Search Tips   |   Advanced Search