<action path="/CartAdd" type="com.softslate.commerce.customer.order.CartAddAction" name="cartAddForm" validate="true" scope="request" input="/Product.do"> <forward name="failure" path="/Product.do"/> <forward name="success" path="cart.full"/> </action>
<form-bean name="cartAddForm" type="com.softslate.commerce.customer.order.CartAddForm"> </form-bean>
Because the action mapping's validate attribute is set to
true, Struts knows that the request must be validated. In Struts, this means that the
validate method of the action form
com.softslate.commerce.customer.order.CartAddForm
must be invoked.
![]() | Note |
|---|---|
More details about the add to cart validation is available in the
API Documentation for |
// Process the items CartProcessor cartProcessor = (CartProcessor) baseForm .getBusinessObjectFactory().createObject( "cartProcessorImplementer"); Map results = cartProcessor.processAddItems(PropertyUtils .describe(baseForm));
At this point, control of the request is passed from the Web Controller or Struts layer, to the Business layer.
![]() | Note |
|---|---|
Whenever an object in the Business layer is created, the
|
OrderGatewayDAO orderGatewayDAO = (OrderGatewayDAO) getDaoFactory() .createDAO("orderGatewayDAOImplementer"); orderGatewayDAO .processOrderItems(getUser(), newOrderItems, results);
![]() | Note |
|---|---|
Whenever an object in the Data Access layer is created, the
|
return mapping.findForward(forward);
<forward name="failure" path="/Product.do"/> <forward name="success" path="cart.full"/>
If it's a failure, control of the request is passed to the "/Product.do" URL. In other words, the user is sent back to the product page where any errors that occured are displayed.
If on the other hand everything went well and the processing succeeded, control is passed to "cart.full", which is not a URL but rather a Tiles definition. Forwards that use this sort of dot notation identify Tiles definitions.
It's at this point that control passes to the Presentation layer.
<definition name="cart.full" extends="core.baseLeftLayout"> <put name="pageTitleKey" value="page.cart"/> <put name="subMenu" value="product.breadcrumbs" /> <put name="body" value="cart.fullLayout" /> </definition>
Tiles definitions can both extend other definitions, and include other
definitions under them. As you can see, "cart.full" extends the
"core.baseLeftLayout" definition, which is defined in the
WEB-INF/conf/core/tiles-defs.xml file:
<definition name="core.baseLeftLayout" path="/WEB-INF/layouts/default/core/leftLayout.jsp" controllerUrl="/LayoutAction.do"> <put name="beforeHTML" value="/WEB-INF/layouts/default/core/empty.jsp" /> <put name="htmlHead" value="/WEB-INF/layouts/default/core/htmlHead.jsp" /> <put name="tracking" value="/WEB-INF/layouts/default/core/tracking.jsp" /> <put name="header" value="/WEB-INF/layouts/default/core/header.jsp" /> <put name="error" value="/WEB-INF/layouts/default/core/error.jsp" /> <put name="message" value="/WEB-INF/layouts/default/core/message.jsp" /> <put name="leftSide" value="core.leftSide" /> <put name="rightSide" value="core.rightSide" /> <put name="subMenu" value="/WEB-INF/layouts/default/core/empty.jsp" /> <put name="body" value="/WEB-INF/layouts/default/core/empty.jsp" /> <put name="footer" value="/WEB-INF/layouts/default/core/footer.jsp" /> <put name="afterHTML" value="/WEB-INF/layouts/default/core/empty.jsp" /> </definition>
Here you can start to understand how Tiles organizes the JSP templates used to
display the results of every request. The "cart.full" definition extends
"core.baseLeftLayout", which identifies many of the JSP templates used to display
the application's HTML. Note that "core.baseLeftLayout" indicates that a JSP file
named empty.jsp should be use for the "body" of the page.
Fortunately, "cart.full" overrides this attribute - otherwise, only an empty space
would be displayed in the page's body.
"cart.full" identifies another Tiles definition should be used for the body of the
page: "cart.fullLayout". This definition appears just below "cart.full" in the
same WEB-INF/conf/order/tiles-defs-order.xml
file:
<definition name="cart.fullLayout" path="/WEB-INF/layouts/default/order/cart.jsp"> <put name="couponFormGuts" value="/WEB-INF/layouts/default/order/couponFormGuts.jsp" /> </definition>
With this definition we've now seen nearly all of the JSP templates used to generate
the response. In particular, we can guess that cart.jsp is
going to provide the guts of the screen for us.
The JSP templates are processed, including processing of the Tiles tags.
<tiles:insert attribute="body"/>
All of leftLayout.jsp is processed in this way, including
each of the JSP templates referred to by their Tiles attributes. The result is an HTML
page displaying the contents of the user's cart, including the new item that has just
been added to it.
![]() | Note |
|---|---|
SoftSlate Commerce extends the Tiles framework to first look inside the
|
Copyright © 2009-2017 SoftSlate, LLC. All Rights Reserved.
Powered by SoftSlate Commerce