开发者

Struts logic- want to prevent duplicate message in email confirmation

I'm new to struts so bear with me please. I want to display a promotional message in the order confirmation email jsp. 开发者_StackOverflow中文版I'm pulling this promo code from a field on a shopping cart form. It works fine except it duplicates the message for every orderline. How do I get it to print only once for a given promo code?

<logic:iterate id="orderLineItem name="order" property="orderLines" type"=com.corporation.ecom.OrderLine">
<logic:notEmpty name="orderLineItem" property="promotionCodes">
    <logic:iterate id="promo" name="ordeLineItem" property="promotionCodes">
       <logic:equal name="promo" value="ABC">
        <p>Message goes here...............
        </p>
       </logicEqual>
       <logic:equal name="promo" value="XYZ">
        <p>Message goes here...............
        </p>
       </logicEqual>
    </logic:iterate>
</logic:notEmpty>
</logic:iterate>


It depends, I don't know what you're actually trying to do.

If, for example, the user enters a promo code, and it's a promo-code-per-order, but must match the promo code of a line item, then you're doing it wrong--you need to check the entered promo code against each item's promo code, and see if there's a match anywhere. If there is, then print the appropriate message.

Doing this in the JSP is a PITA: I'd do it as a JSP fragment or as a JSP-based custom tag. Ideally it'd be done on the server side, where it's far less bulky, and way easier to test. Where/how the promo message is stored also makes a difference.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜