WCS学习笔记(第十天) - 创建消息信息

1. 创建message information properties文件:

    a. 右键 Stores > Java Resources > src , 选择 New > Other

    b.  选择 General > File , 点击 Next , 在 File name 项中输入 MyNewErrorMessages.properties , 点击 Finish

    c. 打开  MyNewErrorMessages.properties ,加入下面键值: 

_ERR_TOO_MANY_ITEMS=You cannot add more items into your shopping cart. Your shopping cart can hold up to five different items.

 

2. 创建properties文件的代码引用
  a.  右键 WebSphereCommerceServerExtensionsLogic > Java Resources > src , 选择 New > Package      

  b. 在 File name 项中输入 com.ibm.commerce.sample.messages , 点击 Finish

  c.  右键 com.ibm.commerce.sample.messages  , 选择 New > Class      

  d. 在 File name 项中输入 MyNewMessages , 点击 Finish , 代码如下:

package com.ibm.commerce.sample.messages;

import com.ibm.commerce.ras.ECMessage;
import com.ibm.commerce.ras.ECMessageSeverity;
import com.ibm.commerce.ras.ECMessageType;

public class MyNewMessages {

	// Resource bundle used to extract the text for an exception
	  static final String errorBundle = "MyNewErrorMessages";

	  // An ECMessage describes an ECException and is passed
	  // into the ECException when thrown
	  public static final ECMessage _ERR_TOO_MANY_ITEMS =
	      new ECMessage(ECMessageSeverity.ERROR, ECMessageType.USER, 
	      MyNewMessageKeys._ERR_TOO_MANY_ITEMS, errorBundle);
	  
}

 

  e.  右键 com.ibm.commerce.sample.messages  , 选择 New > Class      

  f. 在 File name 项中输入 MyNewMessageKeys , 点击 Finish , 代码如下:

package com.ibm.commerce.sample.messages;

public class MyNewMessageKeys {
	// This class defines the keys used to create new exceptions that are 
	// thrown by customized code.
	  public static final String _ERR_TOO_MANY_ITEMS = "_ERR_TOO_MANY_ITEMS";
}

 

参考: http://pic.dhe.ibm.com/infocenter/wchelp/v7r0m0/topic/com.ibm.commerce.developer.tutorial.doc/tutorial/ttd23.htm  


 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值