IBM Power Systems AS/400 iSeries ¤Ë´Ø¤¹¤ë³Ð¤¨½ñ¤­¤Ê¥Ú¡¼¥¸¤Ç¤¹¡£


MyFaces¤Ç°ìÍ÷ɽ¤«¤éÌÀºÙɽ¼¨

MyFaces¤ÇDerby¤ÎÆâÍƤò¥Æ¡¼¥Ö¥ëɽ¼¨¤ò¥Ù¡¼¥¹¤Ë¥Æ¡¼¥Ö¥ë¤ò°ìÍ÷ɽ¼¨¤·¤¿¤È¤³¤í¤«¤é£±ÌÀºÙ¤Î¤ß¤Îɽ¼¨¥Ú¡¼¥¸¤Ë°ÜÆ°¤¹¤ë¤È¸À¤¦¥¢¥×¥ê¤òºîÀ®¤·¤Þ¤¹¡£

JavaBeans

ItemListBean.java
package bean.primula.jp;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

import javax.annotation.Resource;
import javax.faces.FacesException;
import javax.sql.DataSource;

public class ItemListBean {
    @Resource(name = "TestDB")
    private DataSource ds;

    ArrayList<Item> items = new ArrayList<Item>();

    public ItemListBean() {

    }

    private void execSQL() {
        Connection con = null;
        Statement stmt = null;
        ResultSet resultSet = null;
        items.clear();
        try {
            con = this.ds.getConnection();
            stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                    ResultSet.CONCUR_READ_ONLY);
            String sql = "select * from ITEM";
            resultSet = stmt.executeQuery(sql);
            while (resultSet.next()) {
                items.add(new Item(resultSet.getInt(1), resultSet.getString(2),
                        resultSet.getBigDecimal(3)));
            }
            resultSet.close();
            stmt.close();
            con.close();
        } catch (Exception ex) {
            throw new FacesException(ex);
        }
    }

    public ArrayList<Item> getItems() {
        execSQL();
        return items;
    }

    public void setItems(ArrayList<Item> items) {
        this.items = items;
    }
}
ItemDspBean.java
package bean.primula.jp;

import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.annotation.Resource;
import javax.faces.FacesException;
import javax.sql.DataSource;

public class ItemDspBean {
    @Resource(name = "TestDB")
    private DataSource ds;

    private int id;
    private String name;
    private BigDecimal price;

    private void execSQL(String key) {
        Connection con = null;
        Statement stmt = null;
        ResultSet resultSet = null;
        try {
            con = this.ds.getConnection();
            stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                    ResultSet.CONCUR_READ_ONLY);
            String sql = "select * from ITEM where id=" + key  ;
            resultSet = stmt.executeQuery(sql);
            if (resultSet.next()) {
                this.setId(resultSet.getInt(1));
                this.setName(resultSet.getString(2));
                this.setPrice(resultSet.getBigDecimal(3));
            }
            resultSet.close();
            stmt.close();
            con.close();
        } catch (Exception ex) {
            throw new FacesException(ex);
        }
    }

    public String doDetail() {
        this.execSQL(Integer.toString(id));
        return "Dsp";
    }


    public ItemDspBean() {
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }
}

faces-config.xml

    <navigation-rule>
        <from-view-id>/DataTableSample01.jsp</from-view-id>
        <navigation-case>
            <from-outcome>Dsp</from-outcome>
            <to-view-id>/itemDsp.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <navigation-rule>
        <from-view-id>/itemDsp.jsp</from-view-id>
        <navigation-case>
            <from-outcome>DataTableSample01</from-outcome>
            <to-view-id>/DataTableSample01.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>

¥¹¥¿¥¤¥ë¥·¡¼¥È

jsf.css
@CHARSET "UTF-8";
.table-01 {
    width: 320px;
    border: 1px #E3E3E3 solid;
    border-spacing: 0;
    background: #D5F0F0;
}
.th {
    padding: 5px;
    border: #98DCDC solid;
    border-width: 0 0 1px 1px;
    background: #73CECE;
    color: #FFFFFF;
    font-weight: bold;
    line-height: 120%;
    text-align: center;

}
.td {
    padding: 1px;
    border-style: solid;
    border-width: 1px;
    border-color: #FFFFFF #8ED9D9 #8ED9D9 #FFFFFF;
    color: #1A4444;
    text-align: center;
    white-space: nowrap;
}

JSP

DataTableSample01.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>¥Æ¡¼¥Ö¥ë°ìÍ÷¤Î¥µ¥ó¥×¥ë</title>
<link rel="stylesheet" type="text/css" href="jsf.css">
</head>
<body>
<f:view>
    <h:dataTable border="1" value="#{itemList.items}" var="item" styleClass="table-01" rowClasses="td" headerClass="th">
        <h:column id="column1">
            <f:facet name="header">
                <h:outputText value="ID"></h:outputText>
            </f:facet>
            <h:form>
                <h:commandLink action="#{itemDsp.doDetail}">
                    <h:outputText value="#{item.id}"></h:outputText>
                    <t:updateActionListener property="#{itemDsp.id}" value="#{item.id}" />
                </h:commandLink>
            </h:form>
        </h:column>
        <h:column id="column2">
            <h:outputText value="#{item.name}"></h:outputText>
            <f:facet name="header">
                <h:outputText value="̾Á°"></h:outputText>
            </f:facet>
        </h:column>
        <h:column id="column3">
            <h:outputText value="#{item.price}"></h:outputText>
            <f:facet name="header">
                <h:outputText value="ÃÍÃÊ"></h:outputText>
            </f:facet>
        </h:column>
    </h:dataTable>
</f:view>
</body>
</html>
itemDsp.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ITEM¤ÎÌÀºÙɽ¼¨</title>
<link rel="stylesheet" type="text/css" href="jsf.css">
</head>
<body>
<f:view>
    <h:panelGrid border="1" columns="2" styleClass="table-01">
        <h:outputText value="ID"></h:outputText>
        <h:outputText value="#{itemDsp.id}"></h:outputText>
        <h:outputText value="̾Á°" ></h:outputText>
        <h:outputText value="#{itemDsp.name}"></h:outputText>
        <h:outputText value="²Á³Ê"></h:outputText>
        <h:outputText value="#{itemDsp.price}"></h:outputText>
    </h:panelGrid>
    <h:form>
        <h:commandButton value="°ìÍ÷¤ËÌá¤ë" action="DataTableSample01"></h:commandButton>
    </h:form><br>
</f:view>
</body>
</html>

¤³¤Î¥Ú¡¼¥¸¤Ø¤Î¥³¥á¥ó¥È

MGXTRM This is one awesome post.Really thank you! Cool.

0
Posted by awesome things! 2014ǯ01·î23Æü(ÌÚ) 00:29:29 ÊÖ¿®

jygd9x Thank you ever so for you blog post.Really thank you! Really Great.

0
Posted by tips about seo 2013ǯ12·î20Æü(¶â) 21:03:24 ÊÖ¿®

7K15xY <a href="http://kzrvjgzndatj.com/">kzrvjgzndatj</a>, [url=http://zobphxbwrurt.com/]zobphxbwrurt[/url], [link=http://ullepwlqtvtr.com/]ullepwlqtvtr[/link], http://ofakqnycnbac.com/

0
Posted by pdnvblpud 2013ǯ11·î21Æü(ÌÚ) 14:24:40 ÊÖ¿®

UhmoRH <a href="http://tvggybcecgnm.com/">tvggybcecgnm</a>, [url=http://kmygxdtznmew.com/]kmygxdtznmew[/url], [link=http://mpxnktwnydut.com/]mpxnktwnydut[/link], http://xnenbfjnrzdu.com/

0
Posted by dwsfibwm 2013ǯ11·î15Æü(¶â) 03:23:30 ÊÖ¿®

¥³¥á¥ó¥È¤ò¤«¤¯


¡Öhttp://¡×¤ò´Þ¤àÅê¹Æ¤Ï¶Ø»ß¤µ¤ì¤Æ¤¤¤Þ¤¹¡£

ÍøÍѵ¬Ìó¤ò¤´³Îǧ¤Î¤¦¤¨¤´µ­Æþ²¼¤µ¤¤

WikiÆ⸡º÷

Menu

¤³¤³¤Ï¼«Í³¤ËÊÔ½¸¤Ç¤­¤ë¥¨¥ê¥¢¤Ç¤¹¡£

¥á¥ó¥Ð¡¼¤Î¤ßÊÔ½¸¤Ç¤­¤Þ¤¹