2008年6月4日水曜日

ブログパーツのようにしてみた。(更新ping受信サーバ作成その7)

特に需要があるわけじゃありませんがブログパーツにしてみました。
左側の更新情報というのがそれです。
ブログパーツというとFlashかJavaScriptですかね?
とりあえずJavaScriptで出力してみることにしました。


と、いってもそんなに難しいことはやってません。
http://lab.ukauka.net/updateNews/list/parts
でアクセスするようにします。ですので貼り付ける時は
<script type="text/javascript" src="http://lab.ukauka.net/updateNews/list/parts"></script>
こんな感じです。
その6で作成したActionクラスに少し手を加えます。


public ActionResult parts() {
updateEntryList = updateEntryService.getUpdateEntryList(10);
return new Forward("parts.jsp");
}


partsというメソッドを追加します。
一覧を読み込む件数を10件に指定しています。
件数は外部から指定出来るようにしたほうが自由度があがっていいですが今回はめんどくさかったので固定です。
list/parts.jsp


document.open();
document.write('<dl style="width:180px; border-top:1px solid #aaa;">');
document.write('<c:forEach var="updateEntry" items="${action.updateEntryList}" varStatus="status">');
document.write(' <dt style="padding-bottom: 2px; font-size:x-small;">${f:dateFormat(updateEntry.date, 'HH:mm')}');
document.write(' <a style="text-decoration: none;" href="${updateEntry.link}">${updateEntry.title}</a>');
document.write(' </dt>');
document.write(' <dd style="padding-bottom: 2px; font-size:x-small; margin-left:0; text-align:right; border-bottom:1px solid #aaa;">');
document.write(' <a style="color:#999; text-decoration: none;" href="${updateEntry.weblogurl}">${updateEntry.weblogname}</a>');
document.write(' </dd>');
document.write('</c:forEach>');
document.write('</dl>');
document.close();


で、document.writeでHTMLを出力します。
これだけです。
しかし、作っては見たもののあんまり意味ないですねーw

0 件のコメント:

コメントを投稿