レイアウト
SAStrutsのサイトのチュートリアルにTilesがない・・・
補記20080613 チュートリアルプロジェクトにはあります。
が・・・変数表示しているだけなので、
いまいちわかりにくいということで残しておきます。
(わからないの私だけかもしれませんが)
というわけで、
Google先生に教えていただき、
ひがさんブログから抜粋した方法を解釈して試してみた。
ベースは、Doltengで作成されたプロジェクトとします。
そうすると、webapp/commonがあるので。
本来であれば、
<html>〜</html>
を作るところを、以下のようにする。
<tiles:insert template="/common/layout.jsp" flush="true"> <tiles:put name="title" value="検索"/> <tiles:put name="content" type="string"> <html:errors/> <s:form action="/game/search"> <table class="search"> <tr> <td class="left">名前</td> <td class="right"><html:text property="name"/></td> </tr> </table> <input type="submit" name="search" value="検索"/> <table> <thead> <tr> <th>名前</th> </tr> </thead> <tbody> <c:forEach items="${searchResults}" var="game"> <tr> <td>${f:u(game.name)}</td> </tr> </c:forEach> </tbody> </table> </s:form> </tiles:put> </tiles:insert>
<body> </body>
の「中身」をごっそり、
<tiles:put name="content" type="string">
の中身にする。
※調べている最中に、チュートリアルのレイアウトを〜〜
って記述があって、今ないのは、方法模索中なのかもしれません。
ちなみに
cssの取り込みがうまくいかないので
絶対パスで取り込むことにした。
<link rel="stylesheet" type="text/css" href="<%= request.getContextPath() %>/css/style.css")}">
以下でもいけるようだが、現在Doltengで作成できるプロジェクトだと、
SAStruts1.0.0のようで、
以下は
1.0.2rc4
で取り込まれたようなので、現状はf:urlを解決できないと怒られます。
<link rel="stylesheet" type="text/css" href="${f:url("/css/style.css")}">