WCS学习笔记(第四天) - 使用data bean从MyNewControllerCmd 向 MyNewView传递信息
2013-10-14 12:46
567 查看
1. 编写Controller接口和实现:
a.WebSphereCommerceServerExtensionsLogic
>src >com.ibm.commerce.sample.databeans
新建MyNewDataBean.java (可从IBM教程获取),方法体主要对callingCommandName和calledByControllerCmd的set、get方法
b. 修改WebSphereCommerceServerExtensionsLogic> src > com.ibm.commerce.sample.commands.MyNewControllerCmdImpl.java控制实现:
导入data bean
修改performExecute方法,分别对bean中callingCommandName和calledByControllerCmd赋值,并rspProp.put于mndbInstance,代码实现如下:
2. 修改JSP页面:
a. 在MyNewJSPTemplate.jsp的SECTION 5中增加下面代码,用于判断和显示bean传递的信息:
3. 测试:
a. 启动server
b. 访问:
c. 访问:
参考: http://pic.dhe.ibm.com/infocenter/wchelp/v7r0m0/topic/com.ibm.commerce.developer.tutorial.doc/tutorial/ttd14a.htm
a.WebSphereCommerceServerExtensionsLogic
>src >com.ibm.commerce.sample.databeans
新建MyNewDataBean.java (可从IBM教程获取),方法体主要对callingCommandName和calledByControllerCmd的set、get方法
/// Section 1 ///////////////////////////////////////////// /// create fields and accessors (setter/getter methods) private java.lang.String callingCommandName = null; private boolean calledByControllerCmd = false; public java.lang.String getCallingCommandName() { return callingCommandName; } public void setCallingCommandName(java.lang.String newCallingCommandName) { callingCommandName = newCallingCommandName; } public boolean getCalledByControllerCmd() { return calledByControllerCmd; } public void setCalledByControllerCmd(boolean newCalledByControllerCmd) { calledByControllerCmd = newCalledByControllerCmd; } /// End of Section 1 ////////////////////////////////////
b. 修改WebSphereCommerceServerExtensionsLogic> src > com.ibm.commerce.sample.commands.MyNewControllerCmdImpl.java控制实现:
导入data bean
/// Import Section 1 /////////////////////////////// import com.ibm.commerce.sample.databeans.MyNewDataBean; /// End of Import Section 1 ////////////////////////
修改performExecute方法,分别对bean中callingCommandName和calledByControllerCmd赋值,并rspProp.put于mndbInstance,代码实现如下:
/// Section 3A///////////////////////////////////////// /// instantiate the MyNewDataBean databean and set the properties, /// then add the instance to resProp for response MyNewDataBean mndb = new MyNewDataBean(); mndb.setCallingCommandName(this.getClass().getName()); mndb.setCalledByControllerCmd(true); /// end of section 3A///////////////////////////////////////// /// Section 3B///////////////////////////////////////// rspProp.put("mndbInstance", mndb); /// end of section 3B/////////////////////////////////////////
2. 修改JSP页面:
a. 在MyNewJSPTemplate.jsp的SECTION 5中增加下面代码,用于判断和显示bean传递的信息:
<!-- SECTION 5 --> <c:if test="${mndbInstance.calledByControllerCmd}"> <fmt:message key="Example" bundle="${tutorial}" /> <br /> <fmt:message key="CalledByControllerCmd" bundle="${tutorial}" /> <br /> <fmt:message key="CalledByWhichControllerCmd" bundle="${tutorial}" /> <b><c:out value="${mndbInstance.callingCommandName}" /></b> <br /> <br /> </c:if> <!-- END OF SECTION 5 -->
3. 测试:
a. 启动server
b. 访问:
http://localhost/webapp/wcs/stores/servlet/MyNewControllerCmd(注:由于缓存可在url后加如: ?StoreId=10051 )
c. 访问:
http://localhost/webapp/wcs/stores/servlet/MyNewView(注:由于缓存可在url后加如: ?StoreId=10051 )
参考: http://pic.dhe.ibm.com/infocenter/wchelp/v7r0m0/topic/com.ibm.commerce.developer.tutorial.doc/tutorial/ttd14a.htm
相关文章推荐
- WCS学习笔记(第九天) - MyNewControllerCmd整合Bonus entity bean
- mvc如何使用JavaScript在view和controller之间传递数据
- 基于MUI框架的使用HTML5+实现的二维码扫描功能并且其结果在webview中的信息的传递
- iOS彩票项目--第四天,新特性界面搭建,UICollectionViewController的初次使用
- iOS 创建用xib制作的ViewController,不可以使用new方法
- MVC架构中使用ajax实现view和controller之间值的传递
- iOS UISplitViewController 使用教学
- iOS-UI篇—UITabBarController控制View的生命周期(使用storyoard搭建
- ViewController的生命周期分析和使用
- iOS-----MFMessageCompose 和 MFMailComposeViewController的使用方法
- 使用return new ModelAndView("/sys/selectAccount");后session被清空了
- iOS 6新特性UIActivityViewController使用教程(一)
- 使用storyboard时viewcontroller中成员变量初始化
- 自定义view时使用xml传递参数-设定TextView中图片大小
- presentModalViewController和dismissModalViewControllerAnimated的使用总结
- android开发基础:Intent与Bundle的使用,实现页面跳转及信息传递
- 【框架篇】mvc、mvp、mvvm使用关系总结 原创 2016年03月27日 10:04:21 标签:android /架构 9837 MVC MVC全名是Model View Controller,
- iOS开发之ViewController的生命周期分析和使用
- 在presentModalViewController中使用UINavigationController
- 正确使用PresentModalViewController