とりあえずでけた?

id:matobat:20070609で紹介されてるarchetypeを使ってみたけれど

TypeError: Cannot read property "instance" from undefined in script=
indexDto.instance.message

と出てしまいダメ。
おそらくつまらないところでひっかかっているんだろうけど、しばらく追ってみてやっぱダメなので諦め。しょうがないので、頭を冷やしてs2struts-exampleを改造するという初心に帰ってみる。

とりあえずHelloWorldしてみる。まず試したのは以下の構成

org.seasar.struts.examples.employee.action.IndexAction
org.seasar.struts.examples.employee.action.IndexActionImpl
org.seasar.struts.examples.employee.dto.IndexDto
org.seasar.struts.examples.employee.service.IndexService
org.seasar.struts.examples.employee.service.impl.IndexServiceImpl

ところがソース云々どうこうよりも、そもそもコンポーネントが登録されない。理由は謎だけどとりあえず動いてるEmployeeパッケージに突っ込んでみた。が、命名規約の違反かと思うけれども同じ名前だとどうもだめ。なので名前を変更してトライ。結果一応成功した。ソースは以下。

package org.seasar.struts.examples.employee.action;

import org.seasar.struts.annotation.tiger.StrutsAction;

@StrutsAction
public interface EmployeeTestAction {

	void initialize();
}
package org.seasar.struts.examples.employee.action.impl;

import org.seasar.struts.examples.employee.action.EmployeeTestAction;
import org.seasar.struts.examples.employee.dto.EmployeeTestDto;
import org.seasar.struts.examples.employee.service.EmployeeTestService;

public class EmployeeTestActionImpl implements EmployeeTestAction {

	private EmployeeTestDto employeeTestDto;
	
	private EmployeeTestService employeeTestService;
	
	public void initialize() {
		String message = employeeTestService.getMessage();
		employeeTestDto.setMessage(message);
	}

	public EmployeeTestDto getEmployeeTestDto() {
		return employeeTestDto;
	}

	public void setEmployeeTestDto(EmployeeTestDto employeeTestDto) {
		this.employeeTestDto = employeeTestDto;
	}

	public EmployeeTestService getEmployeeTestService() {
		return employeeTestService;
	}

	public void setEmployeeTestService(EmployeeTestService employeeTestService) {
		this.employeeTestService = employeeTestService;
	}

}
package org.seasar.struts.examples.employee.dto;

import org.seasar.struts.annotation.tiger.StrutsActionForm;

@StrutsActionForm
public class EmployeeTestDto {
	private String message;

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
}
package org.seasar.struts.examples.employee.service;

public interface EmployeeTestService {
	String getMessage();
}
package org.seasar.struts.examples.employee.service.impl;

import org.seasar.struts.examples.employee.service.EmployeeTestService;

public class EmployeeTestServiceImpl implements EmployeeTestService {

	public String getMessage() {
		return "success man!";
	}

}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <link href="../../css/global.css" rel="stylesheet" type="text/css"></link>
  <script type="text/javascript" src="../../js/execute.js"></script>
  <title id="pageTitle">
    S2Struts Sample Calculate Application Demo
  </title> 
</head>
<body>

<div id="appBody">
	<span id="message">test message</span>
</div>

</body>
</html>
<?xml version="1.0" encoding="Shift_JIS"?>
<m:mayaa xmlns:m="http://mayaa.seasar.org" 
        xmlns:bean="http://struts.apache.org/tags-bean"
		xmlns:s2struts="http://www.seasar.org/tags-s2struts"
        m:noCache="true"
        m:extends="/pages/layout/layout.html">

    <m:doRender id="pageTitle" name="title">
        <bean:message key="sample.title"/>
		<s2struts:init action="#{employeeTestAction.initialize}" />
    </m:doRender>
    
    <m:doRender id="appBody" name="content"/>
	<bean:write m:id="message" name="employeeTestDto" property="message" scope="request" />
</m:mayaa>

初めから焦ることなく基本から押さえていけばもっと早く色々出来ていたのに、焦ってまとめてやろうとしたのが敗因だなぁ・・・もっとはやく背伸びせずにやっていればよかったorz
とりあえず謎な部分はまず置いておいて、次はTiger対応をやってみよう。