准备工作
仍然使用我们在学习RPCCommand命令控件时所用的到示例,打开sample项目的src下的commandRegist,在【Controls】下新建Button控件。
图15-21
设置新建的Button的id属性值为btnForword,value属性值为"登陆跳转"。
图15-22
新建RequestCommand控件
在【Controls】下新建RequestCommand请求命令控件。步骤:【Controls】—>【Insert】—>【Commands】—>【RequestCommand】。
图15-23
设置新建RequestCommand控件绑定datasetRegist,并且属性id的值为cmdRequest。
图15-24
设置按钮控件btnForword的command属性值为cmdRequest,绑定RequestCommand控件。
图15-25
在formRegist中的【FormGroup】下新建【Custom Element】。步骤:【formRegist】—>【From Group】—>【Insert】—>【Custom Element】。
图15-26
设置新建【element1】的controlId属性值为btnForword。
图15-27
保存全部修改,刷新cmmand_regist.jsp页面查看效果。
图15-28
新建视图模型
在sample项目的src下新建ViewModel,命名commandExecute。新建AutoSqlDataset关联表EMPLOYEE,命名datasetEmployee,设置其中的label属性。
图15-29
在【Controls】下新建DataTable和DataPilot控件,二者都绑定datasetEmployee。
图15-30
配置接收查询匹配条件
在新建的commandExecute视图模型中,配置datasetEmployee的MatchRules查询匹配条件。步骤:【datasetEmployee】—>【Insert】—>【Modify...】。
图15-31
完成配置后,设置【MatchRules】下EMPLOYEE_ID的escapeEnable属性值为true。
图15-32
新建commandExecute的相关JSP页面command_execute.jsp。通过【Browse】查看。
图15-33
配置path属性
在commandRegist中,配置cmdRequest控件的path属性值为command_execute.jsp。
图15-34
保存修改,刷新command_regist.jsp页面。在"登陆用户"文本框中输入ANLIN后点击【登陆跳转】。
图15-35
从页面展现上看,并没有特别之处,但是地址栏中的URL信息告诉我们,这个页面是被跳转过来的。
在URL中,我们可以清楚地看到其中的"username=ANLIN&"是从command_regist.jsp页面中输入的值传递过来的。
parameterFields和method属性
从被传递的参数值中可以了解到它们都是由于RequestCommand绑定了Dataset的缘故。并非每次我们都需要传递绑定的Dataset中所有Field的值。例如在本例中,我们只需要传递userName的值即可。
设置cmdRegist的parameterFields属性值为userName。
图15-36
保存修改后刷新command_regist.jsp页面,在"登陆用户"中输入ANLIN,点击【登陆跳转】查看被跳转的command_execute.jsp页面的URL信息。
和我们预期的一样,URL信息中只含有"username=ANLIN&"。因此parameterFields属性可以设置需要传递的参数值对的数量。
很多情况下,我们传递的信息值并不需要在URL中显示。RequestCommand执行的页面跳转类似标准DHTML中的<form></form>元素中的input type=submit。可以选择是get或post方法提交。
设置cmdRegist的method属性值为post(默认值为get)。
图15-37
保存修改后刷新command_regist.jsp页面,在"登陆用户"中输入ANLIN,点击【登陆跳转】查看被跳转的command_execute.jsp页面的URL信息。
接收传递的参数值
本例中从command_regist.jsp页面传递的参数值,需要被command_execute.jsp页面接收并用于datasetEmployee数据集对象的过滤查询。
在datasetEmployee的Parameters节点下新建Parameter对象。步骤:【datasetEmployee】—>【Parameters】—>【Parameter】。
图15-38
设置新建Parameter对象的name属性值为EMPLOYEE_ID,dataType属性值为string,value值为${Request.userName}。
图15-39
保存修改后刷新command_regist.jsp页面,在"登陆用户"中输入ANLIN,点击【登陆跳转】查看被跳转页面信息。
图15-40
开发步骤
RequestCommand命令控件通过配置path属性可以实现默认的get方式请求跳转页面,可将绑定的Dataset中指定Field的值作为参数传递至被请求页面。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Attachments:



























