Posts

Generating JAXB classes from an XML using RAD

Java Architecture for XML Binding (JAXB) is a framework that allows Java developers to map Java classes to XML representations. JAXB provides two main features: the ability to marshal Java objects into XML and the inverse, i.e. to unmarshal XML back into Java objects. Below are the steps for generating JAXB classes: Create a new folder under ServerExtensionsLogic project and copy the XML to it. Right click on XML > Generate > XML Schema. Step 2 will create a schema definition file in the specified folder. Right click the newly created xsd file > Generate > Java. From the XSD to Java dialog, select Generator 'Schema to JAXB Java Classes' and click Next. Select Target Java Container (java project inside which the newly created classes to be placed) and specify value for Target Package (package for the newly created classes). Click Finish. Refresh the Target Java Container project you mentioned in the previous step and navigate to the package you specifi...

Enabling the shipment notification e-mail - IBM WebSphere Commerce

In WebSphere Commerce you need to make following configuration change for enabling shipment notification e-mail. The default command registry entry is mapped to ReleaseShipNotifyDummyImpl which does nothing. If you change the mapping to ReleaseShipNotifyCmdImpl it will enable the application to send notification message when the order release is shipped. Procedure Update the CMDREG mapping for ReleaseShipNotifyCmd: update cmdreg set classname='com.ibm.commerce.messaging.commands.ReleaseShipNotifyCmdImpl' where interfacename='com.ibm.commerce.messaging.commands.ReleaseShipNotifyCmd' By default, the Release_WCS_ShipmentNotify message is disabled by using ReleaseShipNotifyDummyImpl as the CLASSNAME in the CMDREG database table. The ReleaseShipNotifyDummyImpl is a dummy implementation which does nothing. The default JSP, ReleaseShipNotify.jsp, for the XML message is located in the following directory: WC_eardir/Stores.war Deploy updates to this file using...

Creating and adding elements to a list in JSTL

There are plenty of places in WebSphere Commerce out-of-the-box code where we can see code to iterate over a list in JSTL. But I feel that code to create and add items to list in JSTL are rare and hence lot of developers (atleast beginners) do not know how to do that. I recently came across and used this code to create and add items to an arraylist in JSP using JSTL. And I thought I need to note it down somewhere so I can refer in future. Sample code below: <wcf:useBean var="sampleList" classname="java.util.ArrayList"/> ... <c:set var="sampleVar" value="val"/> <wcf:set target="${sampleList}" value="${sampleVar}"/> Once you created the list, you can iterate through and process it as required. <c:forEach items="${sampleList}" var="eachVal"> <c:out value="${eachVal}" /> </c:forEach> Hope this help someone. Feel free to share t...

Fetching PIs (Payment Instructions) for an order - IBM WebSphere Commerce

Payment instructions of an order is stored in PPCPAYINST database table. This post is about the usage of QueryPIsCmd task command which can be used to fetch all the payment instructions for an order. The default implementation of this command is QueryPIsCmdImpl. Below is a sample code snippet to fetch already added PIs for an order. QueryPIsCmd queryPICmd = (QueryPIsCmd) CommandFactory.createCommand("com.ibm.commerce.edp.commands.QueryPIsCmd", storeId); queryPICmd.setCommandContext(commandContext); queryPICmd.setOrderId(new Long(orderId)); queryPICmd.execute(); ArrayList pis = queryPICmd.getPIs(); Hope this help someone. Feel free to share this page with your friends and colleagues. Thanks..!

Applied promotions of an order - IBM WebSphere Commerce

In this post we will see how we can get the name and other details of promotions already applied to an order from a controller command. These details are stored in the PX_PROMOARG table in XML format. So for this task we need to fetch the PromotionArgument object for the order from the PX_PROMOARG table. This is achieved using PromotionArgumentSessionBeanPersistenceManager, this class provides a load() method which accepts OrderKey using which we can load the PromotionArgument for the order. From the PromotionArgument we can get the list of PromotionExecutionRecords. Below is sample code to get all the promotions applied to an order and print the name and description of the promotions. OrderKey ordKey = new OrderKey(new Long(orderId)); PromotionArgumentSessionBeanPersistenceManager promoManager = new PromotionArgumentSessionBeanPersistenceManager(); PromotionArgument promArg = promoManager.load(ordKey); Iterator prmoExeRecds = promArg.getPromotionExecutionRecords(); ...

Fetching cookie value in controller command - IBM WebSphere Commerce

As WebSphere Commerce developers we may sometimes work on scenarios where we need to read a particular cookie value in controller command. Usually lot of developers use cookies as a simple technique to store some value only for a session and when not required to be saved in the database for future use. Recently, I have came across a business requirement where I have to add a cookie from the front-end (using Javascript) and write some logic in the back-end using the cookie value. Below is the code I have used to iterate over the list of cookies and fetch the value of the required one in a controller command. String cookieName = "MyCookieName"; HttpServletRequest httpServletReq = ((HttpControllerRequestObject) (((ViewCommandContext) getCommandContext()).getRequest())) .getHttpRequest(); Cookie[] cookies = httpServletReq.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { if (cookieName.equals(cookie.ge...