日系框架之seasar2(S2Struts)---(中)
j2ee.dicon
<?xmlversion="1.0"encoding="Shift_JIS"?>
<!DOCTYPEcomponentsPUBLIC"-//SEASAR//DTDS2Container//EN"
"http://www.seasar.org/dtd/components.dtd">
<componentsnamespace="j2ee">
<componentname="transactionManager"
class="org.seasar.extension.jta.TransactionManagerImpl"/>
<componentname="requiredTx"
class="org.seasar.extension.tx.RequiredInterceptor"/>
<componentname="requiresNewTx"
class="org.seasar.extension.tx.RequiresNewInterceptor"/>
<componentname="mandatoryTx"
class="org.seasar.extension.tx.MandatoryInterceptor"/>
<componentname="notSupportedTx"
class="org.seasar.extension.tx.NotSupportedInterceptor"/>
<componentclass="org.seasar.extension.jdbc.impl.BasicResultSetFactory"/>
<componentclass="org.seasar.extension.jdbc.impl.BasicStatementFactory"/>
<!--
<componentclass="org.seasar.extension.jdbc.impl.OracleResultSetFactory"/>
<componentclass="org.seasar.extension.jdbc.impl.BooleanToIntStatementFactory"/>
-->
<!--
<componentname="xaDataSource"
class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
<propertyname="driverClassName">
"oracle.jdbc.driver.OracleDriver"
</property>
<propertyname="URL">
"jdbc:oracle:thin:@xxx:xxx:xxx"
</property>
<propertyname="user">"xxx"</property>
<propertyname="password">"xxx"</property>
</component>
<componentname="xaDataSource"
class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
<propertyname="driverClassName">
"org.postgresql.Driver"
</property>
<propertyname="URL">
"jdbc:postgresql://localhost/TEST"
</property>
<propertyname="user">"xxxx"</property>
<propertyname="password">"xxxx"</property>
</component>
<componentname="xaDataSource"
class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
<propertyname="driverClassName">
"net.sourceforge.jtds.jdbc.Driver"
</property>
<propertyname="URL">
"jdbc:jtds:sqlserver://localhost/TEST;instance=SQLEXPRESS"
</property>
<propertyname="user">"xxxx"</property>
<propertyname="password">"xxxx"</property>
</component>
-->
<componentname="xaDataSource"
class="org.seasar.extension.dbcp.impl.XADataSourceImpl">
<propertyname="driverClassName">
"org.hsqldb.jdbcDriver"
</property>
<propertyname="URL">
"jdbc:hsqldb:hsql://localhost:9001"
</property>
<propertyname="user">"sa"</property>
<propertyname="password">""</property>
</component>
<componentname="connectionPool"
class="org.seasar.extension.dbcp.impl.ConnectionPoolImpl">
<propertyname="timeout">600</property>
<propertyname="maxPoolSize">10</property>
<!--JTAトランザクションが開始されていない場合にコネクションを
取得できないようにするには次のプロパティをfalseにしてください.-->
<propertyname="allowLocalTx">true</property>
<destroyMethodname="close"/>
</component>
<componentname="dataSource"
class="org.seasar.extension.dbcp.impl.DataSourceImpl"/>
<!--WebLogic
<componentname="initialContext"class="javax.naming.InitialContext"/>
<componentname="transactionManager"
class="org.seasar.extension.j2ee.JndiTransactionManager">
<arg>initialContext</arg>
<arg>"javax.transaction.TransactionManager"</arg>
</component>
<component
class="org.seasar.extension.j2ee.JndiDataSource">
<arg>initialContext</arg>
<arg>"jndiName"</arg>
</component>
-->
<!--WebSphere4
<componentname="initialContext"class="javax.naming.InitialContext"/>
<componentname="transactionManager"
class="org.seasar.extension.j2ee.SingletonTransactionManager">
<arg>"com.ibm.ejs.jts.jta.JTSXA"</arg>
<arg>"getTransactionManager"</arg>
</component>
<component
class="org.seasar.extension.j2ee.JndiDataSource">
<arg>initialContext</arg>
<arg>"jndiName"</arg>
</component>
-->
<!--WebSphere5
<componentname="initialContext"class="javax.naming.InitialContext"/>
<componentname="transactionManager"
class="org.seasar.extension.j2ee.SingletonTransactionManager">
<arg>"com.ibm.ejs.jts.jta.TransactionManagerFactory"</arg>
<arg>"getTransactionManager"</arg>
</component>
<component
class="org.seasar.extension.j2ee.JndiDataSource">
<arg>initialContext</arg>
<arg>"jndiName"</arg>
</component>
-->
<!--JBoss
<componentname="initialContext"class="javax.naming.InitialContext"/>
<componentname="transactionManager"
class="org.seasar.extension.j2ee.JndiTransactionManager">
<arg>initialContext</arg>
<arg>"java:/TransactionManager"</arg>
</component>
<component
class="org.seasar.extension.j2ee.JndiDataSource">
<arg>initialContext</arg>
<arg>"jndiName"</arg>
</component>
-->
<!--Oracle10gAS
<componentname="initialContext"class="javax.naming.InitialContext"/>
<componentname="transactionManager"
class="org.seasar.extension.j2ee.JndiTransactionManager">
<arg>initialContext</arg>
<arg>"java:comp/UserTransaction"</arg>
</component>
<component
class="org.seasar.extension.j2ee.JndiDataSource">
<arg>initialContext</arg>
<arg>"jndiName"</arg>
</component>
-->
</components>
?
?
log4j.properties
#log4j.category.org.apache.struts=DEBUG,C
log4j.category.org.apache.commons.validator=ERROR
log4j.category.org.seasar=DEBUG,C
log4j.additivity.org.seasar=false
log4j.appender.C=org.apache.log4j.ConsoleAppender
log4j.appender.C.Target=System.out
log4j.appender.C.ImmediateFlush=true
log4j.appender.C.layout=org.apache.log4j.PatternLayout
log4j.appender.C.layout.ConversionPattern=%-5p%d[%t]%m%n
log4j.rootLogger=INFO,A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d[%t]%-5p%c-%m%n
global.css
body{
padding:0;
background:#FFFFFF;
}
td,th{
font-size:small;
}
.title{
font-size:large;
font-weight:bold;
color:#5671A0;
}
.small{
font-size:70%;
color:white;
}
.smalla,smalla:visited{
color:white;
}
.smalltitle{
font-size:small;
font-weight:bold;
color:#5671A0;
}
.toolbar{
padding:4px;
background-color:#7694C8;
}
.tablebg{
background-color:#EEF3FB;
}
.oddRow,.row-1{
background-color:#FFFFFF;
}
.evenRow,.row-0{
background-color:#EEF3FB;
}
.left{
text-align:left;
}
.right{
text-align:right;
}
.box{
border:thinsolid#7694C8;
}
.label{
background-color:#ffffcc;
}
.display{
display:inline;
}
.notdisplay{
display:none;
}
.level0{
}
.level1{
}
.body{
margin-left:188px;
}
.header{
padding:4px;
}
.menu{
background:#FC0;
padding:0;
position:absolute;
width:120px;
top:145px;
}
.text{
text-align:left;
}
.number{
text-align:right;
}
.date{
text-align:left;
}
.error{
background-color:red;
}
.text-error{
background-color:red;
text-align:left;
}
.number-error{
background-color:red;
text-align:right;
}
.date-error{
background-color:red;
text-align:left;
}
?
execute.js
//
//
//
functiongo(inputTag,action){
if(action!=null){
inputTag.form.action=inputTag.form.action.replace(//[^/]*$/,action);
}
inputTag.form.method.value=inputTag.name;
}
layout.html
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN">
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=Windows-31j">
<linkhref="../../css/global.css"rel="stylesheet"type="text/css"id="globalStyle"></link>
<scripttype="text/javascript"src="../../js/execute.js"id="executeJs"></script>
<titleid="pageTitle">
S2StrutsSample
</title>
</head>
<body>
<tableborder="0"cellspacing="5"width="97%">
<tr>
<tdcolspan="2">
<divid="header">
<imgsrc="../../images/seasar.gif">
</div>
</td>
</tr>
<tr>
<tdwidth="200"valign="top">
<divid="navigation">
<ul>
<li><ahref="http://j5c.ddvip.com/index.php#">MENU1</a></li>
<li><ahref="http://j5c.ddvip.com/index.php#">MENU2</a></li>
<li><ahref="http://j5c.ddvip.com/index.php#">MENU3</a></li>
</ul>
</div>
</td>
<tdvalign="top"align="left">
<divid="layoutBody">
DUMMY
</div>
</td>
</tr>
<tr>
<tdcolspan="2">
<hr/>
</td>
</tr>
<tr>
<tdcolspan="2">
<divid="footer">
TheSeasarProject
</div>
</td>
</tr>
</table>
</body>
</html>
?
?
layout.mayaa
<?xmlversion="1.0"encoding="Shift_JIS"?>
<m:mayaaxmlns:m="http://mayaa.seasar.org"
xmlns:html="http://struts.apache.org/tags-html">
<m:echoid="globalStyle">
<m:attributename="href"value="${contextPath}/css/global.css"/>
</m:echo>
<m:echoid="executeJs">
<m:attributename="src"value="${contextPath}/js/execute.js"/>
</m:echo>
<m:insertid="pageTitle"name="title"replace="false"/>
<m:insertid="layoutBody"name="content"replace="false"/>
<m:insertid="navigation"replace="false"
path="/pages/layout/menu.html"name="menu"/>
<html:imgm:id="header"page="/images/seasar.gif"m:replace="false"/>
<!--ignoredids-->
<m:ignoreid="footer"/>
</m:mayaa>
menu.html
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN">
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=Windows-31j">
<linkhref="../../css/global.css"rel="stylesheet"type="text/css"></link>
<scripttype="text/javascript"src="../../js/execute.js"></script>
<title>
S2StrutsSampleMenu
</title>
</head>
<body>
<divid="menuBody">
<ul>
<li><ahref="http://j5c.ddvip.com/index.php#"id="addPage">S2StrutsAddApplication</a></li>
</ul>
</div>
</body>
</html>
?
?
menu.mayaa
<?xmlversion="1.0"encoding="Shift_JIS"?>
<m:mayaaxmlns:m="http://mayaa.seasar.org"
xmlns:html="http://struts.apache.org/tags-html"
xmlns:bean="http://struts.apache.org/tags-bean"
m:noCache="true">
<m:doRenderid="menuBody"name="menu"/>
<html:linkm:id="addPage"page="/pages/addInput.html"><bean:messagekey="add.title"/></html:link>
</m:mayaa>
addInput.html
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN">
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=Windows-31j">
<linkhref="../../css/global.css"rel="stylesheet"type="text/css"></link>
<scripttype="text/javascript"src="../../js/execute.js"></script>
<titleid="pageTitle">
S2StrutsAddApplicationDemo
</title>
</head>
<body>
<divid="appBody">
<divid="errorMessage"></div>
<formmethod="GET"action="result.html"id="appForm">
<inputname="arg1"type="text">+
<inputname="arg2"type="text">
<inputtype="submit"value="calculate"id="goCalc">
</form>
</div>
</body>
</html>
?
?
addInput.mayaa
<?xmlversion="1.0"encoding="Shift_JIS"?>
<m:mayaaxmlns:m="http://mayaa.seasar.org"
xmlns:html="http://struts.apache.org/tags-html"
xmlns:bean="http://struts.apache.org/tags-bean"
m:noCache="true"
m:extends="/pages/layout/layout.html">
<m:doRenderid="pageTitle"name="title">
<bean:messagekey="add.title"/>
</m:doRender>
<m:doRenderid="appBody"name="content"/>
<html:errorsm:id="errorMessage"/>
<html:formm:id="appForm"action="/add"focus="arg1"/>
<html:submitm:id="goCalc"><bean:messagekey="calc"/></html:submit>
</m:mayaa>
result.html
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN">
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=Windows-31j">
<linkhref="../../css/global.css"rel="stylesheet"type="text/css"></link>
<scripttype="text/javascript"src="../../js/execute.js"></script>
<titleid="pageTitle">
S2StrutsApplicationResultDemo
</title>
</head>
<body>
<divid="appBody">
<divid="resultMessage">
result:100
</div>
</div>
</body>
</html>
?
?
result.mayaa
<?xmlversion="1.0"encoding="Shift_JIS"?>
<m:mayaaxmlns:m="http://mayaa.seasar.org"
xmlns:html="http://struts.apache.org/tags-html"
xmlns:bean="http://struts.apache.org/tags-bean"
m:noCache="true"
m:extends="/pages/layout/layout.html">
<m:doRenderid="pageTitle"name="title">
<bean:messagekey="result.title"/>
</m:doRender>
<m:doRenderid="appBody"name="content"/>
<divm:id="resultMessage">
<bean:messagekey="result"/>:<bean:writename="calcForm"property="result"/>
</div>
</m:mayaa>
struts-config.xml
<?xmlversion="1.0"encoding="ISO-8859-1"?>
<!DOCTYPEstruts-configPUBLIC
"-//ApacheSoftwareFoundation//DTDStrutsConfiguration1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-beanname="calcForm"type="org.seasar.struts.examples.form.CalculationForm"/>
</form-beans>
<action-mappings>
<action
path="/add"
type="org.seasar.struts.examples.add.AddAction"
name="calcForm"
scope="request"
validate="false"
input="/pages/addInput.html">
<forwardname="success"path="/pages/result.html"/>
</action>
</action-mappings>
<controllerprocessorClass="org.seasar.struts.processor.S2RequestProcessor"/>
<message-resourcesparameter="application"/>
<plug-inclassName="org.apache.struts.validator.ValidatorPlugIn">
<set-propertyproperty="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
<plug-inclassName="org.seasar.struts.plugin.AutoStrutsConfigRegisterPlugIn">
<set-propertyproperty="enableJar"value="false"/>
<set-propertyproperty="docRoot"value="/pages"/>
</plug-in>
</struts-config>
?
?
tiles-defs.xml
<?xmlversion="1.0"encoding="ISO-8859-1"?>
<!DOCTYPEtiles-definitionsPUBLIC
"-//ApacheSoftwareFoundation//DTDTilesConfiguration1.1//EN"
"http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
<!--
ThisisablankTilesdefinitionfilewithacommentedexample.
-->
<tiles-definitions>
<!--sampletilesdefinitions
<definitionname=".mainLayout"path="/common/layouts/classicLayout.jsp">
<putname="title" value="SamplePageTitle"/>
<putname="header"value="/common/header.jsp"/>
<putname="menu" value=".mainMenu"/>
<putname="footer"value="/common/footer.jsp"/>
<putname="body" value=".portal.body"/>
</definition>
<definitionname=".mainMenu"path="/common/layouts/vboxLayout.jsp">
<putListname="list">
<addvalue=".menu.links"/>
<addvalue=".menu.taglib.references"/>
<addvalue=".menu.printer.friendly"/>
<addvalue=".menu.old.documents"/>
</putList>
</definition>
<definitionname="aPage"extends=".mainLayout">
<putname="title" value="AnotherTitle"/>
<putname="body" value=".aPage.body"/>
</definition>
endsamples-->
<definitionname="${YOUR_DEFINITION_HERE}"></definition>
</tiles-definitions>
?
validation.xml
<?xmlversion="1.0"encoding="ISO-8859-1"?>
<!DOCTYPEform-validationPUBLIC
"-//ApacheSoftwareFoundation//DTDCommonsValidatorRulesConfiguration1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
<form-validation>
<!--
<formset>
<formname="logonForm">
<field
property="username"
depends="required">
<argkey="logonForm.username"/>
</field>
<field
property="password"
depends="required,mask">
<argkey="logonForm.password"/>
<var>
<var-name>mask</var-name>
<var-value>^[0-9a-zA-Z]*$</var-value>
</var>
</field>
</form>
</formset>
-->
</form-validation>