Top > SAStrutsあれこれ > 「データベースを使ったサンプル」を軽く改造(4)

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 
 
-
|
|
|
|
|
|
!
import org.seasar.framework.beans.util.BeanMap;
----------------------
    public List<BeanMap> findAllByDirectSQL() {
        return this.jdbcManager
            .selectBySql(BeanMap.class, 
                "select id, name, job_type, salary, department_id, department.name as department_name " +
                "from employee " +
                "inner join department on employee.department_id = department.id")
            .getResultList();
    }

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 
 
 
 
 
 
 
 
-
|
|
!
import org.seasar.framework.beans.util.BeanMap;
----------------------
public List<BeanMap>    mapItems;
[/code]
 
以下の"index2"メソッドを追加します。
[code]
    @Execute(validator = false)
    public String index2() {
        mapItems = employeeService.findAllByDirectSQL();
        return "index2.jsp";
    }

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
<%@page pageEncoding="UTF-8" %>
<html>
<head>
<title>Employee List</title>
</head>
<body>
<table border="1">
<tr style="background-color:pink">
<th>&nbsp;</th><th>Id</th><th>Name</th><th>JobType</th><th>Salary</th><th>Department</th><th>Department Name</th><th>編集</th>
</tr>
<c:forEach var="m" varStatus="s" items="${mapItems}">
<tr style="background-color:${s.index %2 == 0 ? 'white' : 'yellow'}">
<td><input type=checkbox name="delete_checks" value="${f:h(m.id)}"></td>
<td align="right">${f:h(m.id)}</td>
<td>${f:h(m.name)}</td>
<td>${f:h(m.jobType)}</td>
<td align="right"><fmt:formatNumber value="${m.salary}" pattern="#,##0"/></td>
<td align="right">${f:h(m.departmentId)}</td>
<td align="right">${f:h(m.departmentName)}</td>
<td><a href="edit/${f:u(m.id)}">編集</a></td>
</tr>
</c:forEach>
</table>
</body>
</html>


リロード   新規 編集 凍結解除 差分 添付 複製 名前変更   ホーム 一覧 単語検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS
Last-modified: 2012-08-08 (水) 23:26:09 (2923d)