SSH集成框架的页面数据回显

来源:互联网 发布:淘宝店音乐怎么设置 编辑:程序博客网 时间:2024/06/16 22:50

集成框架里的页面数据回显

Action层的代码

Long did;Long[] pids;public Long getDid() {return did;}public void setDid(Long did) {this.did = did;}public Long[] getPids() {return pids;}public void setPids(Long[] pids) {this.pids = pids;}

public String updateUI() {User newUser = userServiece.getUserByID(this.user.getUid());// 一般属性的回显ServletActionContext.getContext().getValueStack().push(newUser);this.did = newUser.getDepartment().getDid();Set<Post> posts = newUser.getPosts();int index = 0;this.pids = new Long[posts.size()];for (Post post : posts) {this.pids[index] = post.getPid();index++;}// 准备部门下拉选项的数据Collection<Department> departmentList = departmentService.getAllDepartment();ServletActionContext.getContext().put("departmentList", departmentList);// 准备岗位多选的数据Collection<Post> postList = postService.getAllPost();ServletActionContext.getContext().put("postList", postList);return "updateUI";}

service层和DAO层代码省略

页面内容(需回显的页面代码)


<table cellpadding="0" cellspacing="0" class="mainForm"> <tr><td width="100">所属部门</td>  <td><s:select list="#departmentList" listKey="did" listValue="dname" headerKey="" headerValue="请选择部门" name="did" cssClass="SelectStyle"></s:select>      </td> </tr> <tr><td>登录名</td>    <s:label id="message"></s:label>    </td>        </tr><tr><td>性别</td>            <td><s:radio list="{'男','女'}" name="sex"></s:radio></td>        </tr><tr><td>联系电话</td>            <td><s:textfield name="phone" cssClass="InputStyle"></s:textfield></td>        </tr>        <tr><td>E-mail</td>            <td><s:textfield name="email" cssClass="InputStyle"></s:textfield></td>        </tr></table>