<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>ueblog &#187; Java</title>
	<atom:link href="http://ueblog.natural-wave.com/category/webtechnology/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://ueblog.natural-wave.com</link>
	<description>Web関連のネタを中心に役立つ情報を配信しています。</description>
	<lastBuildDate>Wed, 11 Jan 2012 00:51:56 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ueblog.natural-wave.com/category/webtechnology/java/feed/" />
		<item>
		<title>TeedaのカスタムValidator</title>
		<link>http://ueblog.natural-wave.com/2008/01/06/teeda%e3%81%ae%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0validator/</link>
		<comments>http://ueblog.natural-wave.com/2008/01/06/teeda%e3%81%ae%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0validator/#comments</comments>
		<pubDate>Sun, 06 Jan 2008 13:35:59 +0000</pubDate>
		<dc:creator>ueblog</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[Teeda]]></category>

		<guid isPermaLink="false">http://ueblog.natural-wave.com/2008/01/06/teeda%e3%81%ae%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0validator/</guid>
		<description><![CDATA[前回に引き続き、Validator。今回は、自前のカスタムValidatorを作るときどうするかっていう、備忘録です。 もし、あるDBの項目で重複を許したくない場合（ユニークチェックですね）を例として取り上げます。 環境はTeeda + DBFluteを想定し、EMPテーブルのidとい]]></description>
			<content:encoded><![CDATA[<p>前回に引き続き、Validator。今回は、自前のカスタムValidatorを作るときどうするかっていう、備忘録です。</p>
<p>もし、あるDBの項目で重複を許したくない場合（ユニークチェックですね）を例として取り上げます。</p>
<p>環境はTeeda + DBFluteを想定し、EMPテーブルのidという項目の重複がある場合にエラーとなる場合です。</p>
<p>まずは、javax.faces.validator.Validatorインターフェースを継承したMyEmpDuplicateValidatorクラスを作成します。場所はDoltengであらかじめ作成されているvalidatorというディレクトリに置きました。</p>
<p>MyEmpDuplicateValidator.java</p>
<div class="igBar"><span id="ljava-5"><a href="#" onclick="javascript:showPlainTxt('java-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-5">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package examples.<span style="color: #006600;">teeda</span>.<span style="color: #006600;">validator</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.faces.FacesException;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.faces.application.FacesMessage;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.faces.component.EditableValueHolder;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.faces.component.UIComponent;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.faces.context.FacesContext;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.faces.internal.FacesMessageUtil;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.faces.internal.UIComponentUtil;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.faces.internal.UIInputUtil;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.faces.validator.Validator;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import javax.faces.validator.ValidatorException;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.seasar.framework.container.annotation.tiger.Binding;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.seasar.framework.container.annotation.tiger.BindingType;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.seasar.framework.util.AssertionUtil;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import examples.teeda.dbflute.cbean.EmpCB;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import examples.teeda.dbflute.exbhv.EmpBhv;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyEmpDuplicateValidator <span style="color: #000000; font-weight: bold;">implements</span> Validator <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> MESSAGE_ID = <span style="color: #ff0000;">"examples.teeda.validator.EmpDuplicateValidator.INVALID"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @<a href="http://www.google.com/search?q=allinurl%3ABinding+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Binding</span></a><span style="color: #66cc66;">&#40;</span>bindingType = <a href="http://www.google.com/search?q=allinurl%3ABindingType+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">BindingType</span></a>.<span style="color: #006600;">MUST</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> EmpBhv empBhv;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> validate<span style="color: #66cc66;">&#40;</span>FacesContext context, UIComponent component,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3AObject+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> value<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> FacesException <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// nullな場合無視します。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; AssertionUtil.<span style="color: #006600;">assertNotNull</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"context"</span>, context<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; AssertionUtil.<span style="color: #006600;">assertNotNull</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"component"</span>, component<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>UIInputUtil.<span style="color: #006600;">isEmpty</span><span style="color: #66cc66;">&#40;</span>value<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> s = value.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// EMPテーブルのid項目に対して件数を取得しています。</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; FeedCB cb = <span style="color: #000000; font-weight: bold;">new</span> FeedCB<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; cb.<span style="color: #006600;">query</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">setId_Equal</span><span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333;">int</span> count = empBhv.<span style="color: #006600;">selectCount</span><span style="color: #66cc66;">&#40;</span>cb<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>count&gt; <span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?q=allinurl%3AObject+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> submittedValue = EditableValueHolder.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006600;">cast</span><span style="color: #66cc66;">&#40;</span>component<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getSubmittedValue</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?q=allinurl%3AObject+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Object</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> args = <span style="color: #66cc66;">&#123;</span> UIComponentUtil.<span style="color: #006600;">getLabel</span><span style="color: #66cc66;">&#40;</span>component<span style="color: #66cc66;">&#41;</span>,submittedValue<span style="color: #66cc66;">&#125;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">final</span> FacesMessage message = FacesMessageUtil.<span style="color: #006600;">getMessage</span><span style="color: #66cc66;">&#40;</span>context, MESSAGE_ID, args<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> ValidatorException<span style="color: #66cc66;">&#40;</span>message, MESSAGE_ID, args<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
validateメソッドを実装します。その中で、DBにアクセスする必要があるので、DBFluteのBehaviorをInjectさせて、件数を取得し、件数がある場合に、JSFの作法にのっとり、ValidatorExceptionをthrowしてます。</p>
<p>また、MESSAGE_IDで指定した、文言がエラーとして出力されるので、resourcesのpropertyファイルに追記しておきます。</p>
<p>appMessages_ja.properties</p>
<div class="igBar"><span id="lcode-6"><a href="#" onclick="javascript:showPlainTxt('code-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-6">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">examples.<span style="">teeda</span>.<span style="">validator</span>.<span style="">EmpDuplicateValidator</span>.<span style="">INVALID</span> = IDが重複しています。 </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>そして、アノテーションを使えるようにするためにインターフェースを作成します。場所は上記と同じ場所に配置しました。</p>
<p>EmpDuplicateValidator.java</p>
<div class="igBar"><span id="ljava-7"><a href="#" onclick="javascript:showPlainTxt('java-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-7">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package examples.<span style="color: #006600;">teeda</span>.<span style="color: #006600;">validator</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.lang.annotation.ElementType;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.lang.annotation.Retention;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.lang.annotation.RetentionPolicy;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.lang.annotation.Target;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.seasar.teeda.extension.annotation.validator.Validator;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@Retention<span style="color: #66cc66;">&#40;</span>RetentionPolicy.<span style="color: #006600;">RUNTIME</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@Target<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span> ElementType.<span style="color: #006600;">FIELD</span>, ElementType.<span style="color: #006600;">METHOD</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@Validator<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"myEmpDuplicateValidator"</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> @<span style="color: #000000; font-weight: bold;">interface</span> EmpDuplicateValidator <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>これで、Pageクラスなどで</p>
<div class="igBar"><span id="ljava-8"><a href="#" onclick="javascript:showPlainTxt('java-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-8">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@EmpDuplicateValidator</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> id; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
と書くだけで、重複チェックが行われるわけです。</p>
<p>少しややこしいように見えますが、一度やってしまうと簡単にカスタムValidatorが作れます。便利ですね。</p>
]]></content:encoded>
			<wfw:commentRss>http://ueblog.natural-wave.com/2008/01/06/teeda%e3%81%ae%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0validator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ueblog.natural-wave.com/2008/01/06/teeda%e3%81%ae%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%a0validator/" />
	</item>
		<item>
		<title>Teedaで正規表現のValidate</title>
		<link>http://ueblog.natural-wave.com/2008/01/06/teeda%e3%81%a7%e6%ad%a3%e8%a6%8f%e8%a1%a8%e7%8f%be%e3%81%aevalidate/</link>
		<comments>http://ueblog.natural-wave.com/2008/01/06/teeda%e3%81%a7%e6%ad%a3%e8%a6%8f%e8%a1%a8%e7%8f%be%e3%81%aevalidate/#comments</comments>
		<pubDate>Sat, 05 Jan 2008 15:18:04 +0000</pubDate>
		<dc:creator>ueblog</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[Teeda]]></category>

		<guid isPermaLink="false">http://ueblog.natural-wave.com/2008/01/06/teeda%e3%81%a7%e6%ad%a3%e8%a6%8f%e8%a1%a8%e7%8f%be%e3%81%aevalidate/</guid>
		<description><![CDATA[Teedaを利用していて、フォームの入力チェックで正規表現を使いたい場合、 Pageクラスで PLAIN TEXT JAVA: public class TestPage &#123; &#160; &#160; @RegularExpression&#40;pattern = "[0-9a-zA-Z]+"&#41; &#160; &#160; public String title; ～ &#125; アノテーションを利用する場合はこのように書く。 （例は英数字のみのチェック） そして、HTMLは PLAIN TEXT HTML: &#60;span id="allMessages"&#62;&#60;/span&#62; &#60;input type="text" id="title" title="タイトル" /&#62; と書いておけば、そこにエラー文言が表]]></description>
			<content:encoded><![CDATA[<p>Teedaを利用していて、フォームの入力チェックで正規表現を使いたい場合、</p>
<p>Pageクラスで</p>
<div class="igBar"><span id="ljava-11"><a href="#" onclick="javascript:showPlainTxt('java-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-11">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TestPage <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @RegularExpression<span style="color: #66cc66;">&#40;</span>pattern = <span style="color: #ff0000;">"[0-9a-zA-Z]+"</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> title;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">～</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
アノテーションを利用する場合はこのように書く。<br />
（例は英数字のみのチェック）</p>
<p>そして、HTMLは</p>
<div class="igBar"><span id="lhtml-12"><a href="#" onclick="javascript:showPlainTxt('html-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-12">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/span.html"><span style="color: #000000; font-weight: bold;">&lt;span</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"allMessages"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"title"</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">"タイトル"</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
と書いておけば、そこにエラー文言が表示される。すごく直感的、簡単でわかりやすい！</p>
<p>でも、エラー文言は</p>
<blockquote><p>値(タイトル)は正規表現([0-9a-zA-Z]+)にマッチしません。</p></blockquote>
<p>これがデフォルト。<br />
気持ちはわかるが、これデフォルトで使う人いないっしょ！</p>
<p>あと、話はそれるが、DynamicPropertyの話。<br />
htmlの属性値を変更できる機能だが、id属性の値を変更できない。。これなんとかしてほしいなあ。</p>
<p>そもそもTeeda Extensionは、xercesを利用してHTMLをパースする仕様なんで、ちゃんとしたxhtml書かないとだめ。テンプレートでもちゃんとしたHTMLを書かねばならんので、結構融通が利かない場合が多い。</p>
<p>テンプレートエンジンの差し替えが簡単なら、他のテンプレートエンジンの組み合わせも考えていきたい。</p>
]]></content:encoded>
			<wfw:commentRss>http://ueblog.natural-wave.com/2008/01/06/teeda%e3%81%a7%e6%ad%a3%e8%a6%8f%e8%a1%a8%e7%8f%be%e3%81%aevalidate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ueblog.natural-wave.com/2008/01/06/teeda%e3%81%a7%e6%ad%a3%e8%a6%8f%e8%a1%a8%e7%8f%be%e3%81%aevalidate/" />
	</item>
		<item>
		<title>Teeda HTMLでリンクURLを書き換えるには？</title>
		<link>http://ueblog.natural-wave.com/2007/12/17/teeda-html%e3%81%a7%e3%83%aa%e3%83%b3%e3%82%afurl%e3%82%92%e6%9b%b8%e3%81%8d%e6%8f%9b%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/</link>
		<comments>http://ueblog.natural-wave.com/2007/12/17/teeda-html%e3%81%a7%e3%83%aa%e3%83%b3%e3%82%afurl%e3%82%92%e6%9b%b8%e3%81%8d%e6%8f%9b%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/#comments</comments>
		<pubDate>Sun, 16 Dec 2007 15:25:38 +0000</pubDate>
		<dc:creator>ueblog</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[Teeda]]></category>

		<guid isPermaLink="false">http://ueblog.natural-wave.com/2007/12/17/teeda-html%e3%81%a7%e3%83%aa%e3%83%b3%e3%82%afurl%e3%82%92%e6%9b%b8%e3%81%8d%e6%8f%9b%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/</guid>
		<description><![CDATA[TeedaのHTML上でリンク（aタグのhref属性）を書き換えるにはどうする？ 答えは、Dynamic Propertyを利用する。 view PLAIN TEXT HTML: &#60;a id="url" href="" target="_blank"&#62;外部リンク&#60;/a&#62; Pageクラス PLAIN TEXT JAVA: private String url; //Dynamic Propertyを使って、urlを書き換え public String getUrlHref&#40;&#41;&#123; &#160; &#160; return this.url; &#125; Dynamic Propertyは、先頭にget + (id) + (属性名)という、getterを用意すれば、その属性の値を変換してくれる。 それでは、画面遷移などでgoを]]></description>
			<content:encoded><![CDATA[<p>TeedaのHTML上でリンク（aタグのhref属性）を書き換えるにはどうする？</p>
<p>答えは、Dynamic Propertyを利用する。</p>
<p>view</p>
<div class="igBar"><span id="lhtml-19"><a href="#" onclick="javascript:showPlainTxt('html-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-19">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">&lt;a</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"url"</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">""</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">"_blank"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>外部リンク<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Pageクラス</p>
<div class="igBar"><span id="ljava-20"><a href="#" onclick="javascript:showPlainTxt('java-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-20">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> url;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//Dynamic Propertyを使って、urlを書き換え</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> getUrlHref<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">url</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
Dynamic Propertyは、先頭にget + (id) + (属性名)という、getterを用意すれば、その属性の値を変換してくれる。</p>
<p>それでは、画面遷移などでgoをくっつける場合はどうなるか。<br />
view</p>
<div class="igBar"><span id="lhtml-21"><a href="#" onclick="javascript:showPlainTxt('html-21'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-21">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/a.html"><span style="color: #000000; font-weight: bold;">&lt;a</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"goUrl"</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">""</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span>リンク<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Pageクラス</p>
<div class="igBar"><span id="ljava-22"><a href="#" onclick="javascript:showPlainTxt('java-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-22">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> url;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">//Dynamic Propertyを使って、urlを書き換え+goを利用</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> getGoUrlHref<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">url</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
get + Go + (id) + (属性名)なgetterを用意すればよい。</p>
<p>さて、javascript内などに、HTMLを表示する段階で動的に値を渡してあげるには？<br />
view</p>
<div class="igBar"><span id="lhtml-23"><a href="#" onclick="javascript:showPlainTxt('html-23'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">HTML:</span>
<div id="html-23">
<div class="html">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/span.html"><span style="color: #000000; font-weight: bold;">&lt;span</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"hoge"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span><span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">alert(document.getElementById(&quot;mapx&quot;).innerHTML);</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Pageクラス</p>
<div class="igBar"><span id="ljava-24"><a href="#" onclick="javascript:showPlainTxt('java-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-24">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> hoge;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setHoge<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> hoge<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">hoge</span> = hoge;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">Class</span> prerender<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; setHoge<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"javascriptに値を渡す。"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">null</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
という感じで、span経由で渡すことで可能。でもspanタグを隠さないとHTMLとして見えてしまうので微妙。</p>
<p>もっといい方法はないものか。</p>
<hr />
明日から、台湾出張です。台湾のインターネット事情がわかればレポートします。<br />
しかし、昨日テレビで見た、日航機墜落と大韓航空爆破のドキュメンタリーを見てしまい、飛行機が若干怖くなった。。。</p>
]]></content:encoded>
			<wfw:commentRss>http://ueblog.natural-wave.com/2007/12/17/teeda-html%e3%81%a7%e3%83%aa%e3%83%b3%e3%82%afurl%e3%82%92%e6%9b%b8%e3%81%8d%e6%8f%9b%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ueblog.natural-wave.com/2007/12/17/teeda-html%e3%81%a7%e3%83%aa%e3%83%b3%e3%82%afurl%e3%82%92%e6%9b%b8%e3%81%8d%e6%8f%9b%e3%81%88%e3%82%8b%e3%81%ab%e3%81%af%ef%bc%9f/" />
	</item>
		<item>
		<title>Teeda + DBFlute環境でバッチ作成</title>
		<link>http://ueblog.natural-wave.com/2007/12/15/teeda-dbflute-batch/</link>
		<comments>http://ueblog.natural-wave.com/2007/12/15/teeda-dbflute-batch/#comments</comments>
		<pubDate>Sat, 15 Dec 2007 14:35:48 +0000</pubDate>
		<dc:creator>ueblog</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[DBFlute]]></category>
		<category><![CDATA[Teeda]]></category>

		<guid isPermaLink="false">http://ueblog.natural-wave.com/2007/12/15/teeda-dbflute-batch/</guid>
		<description><![CDATA[現在、Teeda + DBFluteな環境で、Webアプリを製作中なわけですが、DBを更新する処理とかのバッチ作成する時って、どこにソースを配置すべきなんでしょう。 考えた末、、Webアプリと混在する環境に置く事に。 javaのソースディレクトリにbatchっていうのを]]></description>
			<content:encoded><![CDATA[<p>現在、Teeda + DBFluteな環境で、Webアプリを製作中なわけですが、DBを更新する処理とかのバッチ作成する時って、どこにソースを配置すべきなんでしょう。</p>
<p>考えた末、、Webアプリと混在する環境に置く事に。</p>
<p><a href='http://ueblog.natural-wave.com/wp-content/uploads/2007/12/home.jpg' title='teeda-batch' rel="lightbox"><img src='http://ueblog.natural-wave.com/wp-content/uploads/2007/12/home.thumbnail.jpg' alt='teeda-batch' /></a></p>
<p>javaのソースディレクトリにbatchっていうのを作って、そこにmain関数を書いてしまう。<br />
そして、ソースはこんな感じで。<br />
<br clear="all"/></p>
<div class="igBar"><span id="ljava-26"><a href="#" onclick="javascript:showPlainTxt('java-26'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-26">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.seasar.framework.container.S2Container;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.seasar.framework.container.factory.S2ContainerFactory;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import sample.dbflute.exbhv.MemberBhv;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import sample.dbflute.exentity.Member;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> S2PATH = <span style="color: #ff0000;">"dbflute.dicon"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> args<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; S2Container container = S2ContainerFactory.<span style="color: #006600;">create</span><span style="color: #66cc66;">&#40;</span>S2PATH<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; container.<span style="color: #006600;">init</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MemberBhv memberBhv</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = <span style="color: #66cc66;">&#40;</span>memberBhv<span style="color: #66cc66;">&#41;</span>container.<span style="color: #006600;">getComponent</span><span style="color: #66cc66;">&#40;</span>MemberBhv.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?q=allinurl%3AMember+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Member</span></a> member = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AMember+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Member</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; member.<span style="color: #006600;">setId</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; member.<span style="color: #006600;">setName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"name"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; memberBhv.<span style="color: #006600;">insert</span><span style="color: #66cc66;">&#40;</span>member<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #006600;">printStackTrace</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; container.<span style="color: #006600;">destroy</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
S2Containerを呼び出し、Behaviorを作成。Behaviorを通して簡単なinsert処理を。<br />
これで完了。</p>
<p>いちおう、Container経由でWebで作ったロジックもちゃんと呼べたりもしますし、DBFluteの便利なBehaviorやConditionBeanも呼び出せるので、これでええかなと。</p>
<p>しかし、調べてみるといろいろ意見があったりしてます。<br />
<a href="https://ml.seasar.org/archives/seasar-user/2007-August/011996.html" target="_blank">https://ml.seasar.org/archives/seasar-user/2007-August/011996.html<br />
</a></p>
<p>最適な解は何なんでしょう。</p>
]]></content:encoded>
			<wfw:commentRss>http://ueblog.natural-wave.com/2007/12/15/teeda-dbflute-batch/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ueblog.natural-wave.com/2007/12/15/teeda-dbflute-batch/" />
	</item>
		<item>
		<title>JavaでRESTするには(RestletによるAPI利用)</title>
		<link>http://ueblog.natural-wave.com/2007/12/10/java-rest/</link>
		<comments>http://ueblog.natural-wave.com/2007/12/10/java-rest/#comments</comments>
		<pubDate>Sun, 09 Dec 2007 15:28:58 +0000</pubDate>
		<dc:creator>ueblog</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[API]]></category>

		<guid isPermaLink="false">http://ueblog.natural-wave.com/2007/12/10/java-rest/</guid>
		<description><![CDATA[Javaで各種WebのAPIにRESTするのに一番簡単な方法は？ いろんな手段がありえるが、今回は「Restlet」を取り上げてみる。 Restlet自体はAPIを提供する側のサーバ機能を利用することが多いようですが、今回はあえてクライアントとして利用します。 まずは、Restlet]]></description>
			<content:encoded><![CDATA[<p>Javaで各種WebのAPIにRESTするのに一番簡単な方法は？</p>
<p>いろんな手段がありえるが、今回は「<strong>Restlet</strong>」を取り上げてみる。<br />
Restlet自体はAPIを提供する側のサーバ機能を利用することが多いようですが、今回はあえてクライアントとして利用します。</p>
<p>まずは、Restletのライブラリをダウンロードする。<br />
<a href="http://www.restlet.org/downloads/" target="_blank">Restlet - Downloads</a></p>
<p>Zip archive版の中から、</p>
<blockquote><p>com.noelios.restlet.jar<br />
org.restlet.jar<br />
com.noelios.restlet.ext.httpclient_3.1.jar</p></blockquote>
<p>を取り出し、CLASSPATHに通す。</p>
<p>そして、commonsプロジェクトにも依存しているようなので、<br />
<a href="http://commons.apache.org/downloads/download_logging.cgi" target="_blank">Apache Commons - Logging Downloads</a></p>
<p><a href="http://commons.apache.org/downloads/download_codec.cgi" target="_blank">Apache Commons - Codec Downloads<br />
</a><br />
<a href="http://jakarta.apache.org/httpcomponents/httpclient-3.x/downloads.html" target="_blank">HttpClient - HttpClient Downloads</a></p>
<p>から、それぞれ</p>
<blockquote><p>commons-logging-1.1.jar<br />
commons-codec-1.3.jar<br />
commons-httpclient-3.1.jar</p></blockquote>
<p>を取り出し、CLASSPATHに通す。</p>
<p>さて、今日はどのAPIを標的とするかというと、、東京大学空間情報科学研究センターが提供する、住所から位置情報を割り出せるという<a href="http://pc035.tkl.iis.u-tokyo.ac.jp/~sagara/geocode/index.php" target="_blank">CSISシンプルジオコーディング</a>を利用してみようと思う。</p>
<p>さっそくコードはこんな感じに。東京都渋谷区道玄坂をターゲットにしてみました。</p>
<div class="igBar"><span id="ljava-28"><a href="#" onclick="javascript:showPlainTxt('java-28'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-28">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.restlet.Client;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.restlet.data.Protocol;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.restlet.data.Reference;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.restlet.resource.DomRepresentation;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import org.w3c.dom.Node;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> args<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Client client = <span style="color: #000000; font-weight: bold;">new</span> Client<span style="color: #66cc66;">&#40;</span>Protocol.<span style="color: #006600;">HTTP</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> url = <span style="color: #ff0000;">"http://geocode.csis.u-tokyo.ac.jp/cgi-bin/simple_geocode.cgi"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + <span style="color: #ff0000;">"?addr="</span> + <a href="http://www.google.com/search?q=allinurl%3AReference+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Reference</span></a>.<span style="color: #006600;">encode</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"東京都渋谷区道玄坂"</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + <span style="color: #ff0000;">"&amp;charset=UTF8"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DomRepresentation xml = client.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>url<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getEntityAsDom</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Node n1 = xml.<span style="color: #006600;">getNode</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"//results/candidate/address"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"address : "</span> + n1.<span style="color: #006600;">getTextContent</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Node n2 = xml.<span style="color: #006600;">getNode</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"//results/candidate/longitude"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"longitude : "</span> + n2.<span style="color: #006600;">getTextContent</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Node n3 = xml.<span style="color: #006600;">getNode</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"//results/candidate/latitude"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"latitude : "</span> + n3.<span style="color: #006600;">getTextContent</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #006600;">printStackTrace</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
実行結果はこちら</p>
<blockquote><p>address : 東京都/渋谷区/道玄坂<br />
longitude : 139.698166<br />
latitude : 35.657429</p></blockquote>
<p>Clientのインスタンスを作って、URLを書き、そして簡単にxmlの解析ができます。超簡単！<br />
なんといっても、ソースが直感的。<br />
ライブラリの依存関係がうざいけど、シンプルなAPIにはかなり使えそうだ。</p>
<p>そして、このシンプルジオコーディング、かなりつかえるぞ！<br />
住所の文字列から住所の区分けまでやってくれます。さすが。</p>
]]></content:encoded>
			<wfw:commentRss>http://ueblog.natural-wave.com/2007/12/10/java-rest/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ueblog.natural-wave.com/2007/12/10/java-rest/" />
	</item>
		<item>
		<title>JavaでRSSフィードを取得（ROME）</title>
		<link>http://ueblog.natural-wave.com/2007/12/02/java%e3%81%a7rss%e3%83%95%e3%82%a3%e3%83%bc%e3%83%89%e3%82%92%e5%8f%96%e5%be%97%ef%bc%88rome%ef%bc%89/</link>
		<comments>http://ueblog.natural-wave.com/2007/12/02/java%e3%81%a7rss%e3%83%95%e3%82%a3%e3%83%bc%e3%83%89%e3%82%92%e5%8f%96%e5%be%97%ef%bc%88rome%ef%bc%89/#comments</comments>
		<pubDate>Sun, 02 Dec 2007 12:35:22 +0000</pubDate>
		<dc:creator>ueblog</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programing]]></category>

		<guid isPermaLink="false">http://ueblog.natural-wave.com/2007/12/02/java%e3%81%a7rss%e3%83%95%e3%82%a3%e3%83%bc%e3%83%89%e3%82%92%e5%8f%96%e5%be%97%ef%bc%88rome%ef%bc%89/</guid>
		<description><![CDATA[JavaでRSSフィードを取得する手段は？ commonsのHttpClientライブラリで取得してDom操作とか、、そんなめんどくさそうな感じがいやだったので、いろいろと探してみると、ありました！その名も「ROME」 このROMEは、RSSやAtomフィードなどのいろんなバージョンのRSSを統]]></description>
			<content:encoded><![CDATA[<p>JavaでRSSフィードを取得する手段は？<br />
commonsのHttpClientライブラリで取得してDom操作とか、、そんなめんどくさそうな感じがいやだったので、いろいろと探してみると、ありました！その名も「<strong>ROME</strong>」</p>
<p>このROMEは、RSSやAtomフィードなどのいろんなバージョンのRSSを統一なインターフェースで取得できるライブラリである、ということでさっそく使ってみました。</p>
<p>まずは、公式サイトから「<a href="https://rome.dev.java.net/" target="_blank">ROME</a>」、「<a href="http://wiki.java.net/bin/view/Javawsxml/RomeFetcherRelease09">ROME Fether</a>」、そして「<a href="http://www.jdom.org/downloads/index.html">JDOM</a>」のバイナリをダウンロードし、</p>
<blockquote><p>rome-0.9.jar<br />
rome-fetcher-0.9.jar<br />
jdom.jar</p></blockquote>
<p>を抽出し、CLASSPATHを通します。</p>
<p>そしてサンプルがこちら。</p>
<div class="igBar"><span id="ljava-31"><a href="#" onclick="javascript:showPlainTxt('java-31'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVA:</span>
<div id="java-31">
<div class="java">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.net.URL;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import java.util.List;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.sun.syndication.feed.synd.SyndEntry;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.sun.syndication.feed.synd.SyndFeed;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.sun.syndication.fetcher.FeedFetcher;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #a1a100;">import com.sun.syndication.fetcher.impl.HttpURLFeedFetcher;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> FEED_URL = <span style="color: #ff0000;">"http://ueblog.natural-wave.com/feed/"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">static</span> <span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> args<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; FeedFetcher fetcher = <span style="color: #000000; font-weight: bold;">new</span> HttpURLFeedFetcher<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SyndFeed feed = fetcher.<span style="color: #006600;">retrieveFeed</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=allinurl%3AURL+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">URL</span></a><span style="color: #66cc66;">&#40;</span>FEED_URL<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Blog Title:"</span> + feed.<span style="color: #006600;">getTitle</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span>SyndEntry entry : <span style="color: #66cc66;">&#40;</span>List&lt;SyndEntry&gt;<span style="color: #66cc66;">&#41;</span>feed.<span style="color: #006600;">getEntries</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"==================================================="</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Title:"</span> + entry.<span style="color: #006600;">getTitle</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Date:"</span> + entry.<span style="color: #006600;">getPublishedDate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Uri:"</span> + entry.<span style="color: #006600;">getUri</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3ASystem+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Description:"</span> + entry.<span style="color: #006600;">getDescription</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getValue</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #006600;">printStackTrace</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
URLをいれてFeedの繰り返しをまわしながら、getメソッドで取得していく。すごく直感的でわかりやすい！</p>
<p>実行した結果はこちら</p>
<div class="igBar"><span id="lcode-32"><a href="#" onclick="javascript:showPlainTxt('code-32'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-32">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Blog Title:ueblog</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">===================================================</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Title:英語SNS、「iKnow」がすごい件</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Date:Thu Nov <span style="color:#800000;color:#800000;">29</span> <span style="color:#800000;color:#800000;">00</span>:<span style="color:#800000;color:#800000;">15</span>:<span style="color:#800000;color:#800000;">46</span> JST <span style="color:#800000;color:#800000;">2007</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Uri:http:<span style="color:#FF9933; font-style:italic;">//ueblog.natural-wave.com/2007/11/29/%e8%8b%b1%e8%aa%9esns%e3%80%81%e3%80%8ciknow%e3%80%8d%e3%81%8c%e3%81%99%e3%81%94%e3%81%84%e4%bb%b6/</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Description:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">英語やらなきゃって勉強していても、なかなか続かないのが悩みの種。まさにそんな自分なんですが、このはてぶで見つけた「iKnow!」っていうサービスがすごい！</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">見た目とか、フォームとかインターフェー...</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">=================================================== </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>JavaでRSS取得するのにいろいろと調べていて思ったのですが、さまざまな手法があり、またどれが標準的なものなのか、一番使われていてメンテナンスされているライブラリはどれか、ということがすごくわかりにくいなあと感じます。</p>
<p>特にJavaの場合、Webのフレームワークが顕著ですが、どれが自分に最適なのか？また、組み合わせもいろいろ考えられるところが逆に新しい開発者が参入しにくい一因になっているようなそんな気がする。</p>
<p>今回のRomeにしても、JDOMというライブラリが必要であったり面倒な部分があるので、All IN Oneで手軽に導入できないものかと、そう感じました。</p>
]]></content:encoded>
			<wfw:commentRss>http://ueblog.natural-wave.com/2007/12/02/java%e3%81%a7rss%e3%83%95%e3%82%a3%e3%83%bc%e3%83%89%e3%82%92%e5%8f%96%e5%be%97%ef%bc%88rome%ef%bc%89/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ueblog.natural-wave.com/2007/12/02/java%e3%81%a7rss%e3%83%95%e3%82%a3%e3%83%bc%e3%83%89%e3%82%92%e5%8f%96%e5%be%97%ef%bc%88rome%ef%bc%89/" />
	</item>
		<item>
		<title>Teedaの使いにくい点</title>
		<link>http://ueblog.natural-wave.com/2007/09/17/s2-teeda/</link>
		<comments>http://ueblog.natural-wave.com/2007/09/17/s2-teeda/#comments</comments>
		<pubDate>Mon, 17 Sep 2007 14:50:03 +0000</pubDate>
		<dc:creator>ueblog</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[Teeda]]></category>

		<guid isPermaLink="false">http://ueblog.natural-wave.com/2007/09/17/s2-teeda/</guid>
		<description><![CDATA[最近家でもりもりとプログラムを作成していて、サーバー側の実装はお気に入りのSeasar2 Teedaを利用しているのですが、どうも納得のいかん部分があるので書いておきます。 １．URLを操作しにくい。 Webアプリケーションを作成する上でURLのつけ]]></description>
			<content:encoded><![CDATA[<p>最近家でもりもりとプログラムを作成していて、サーバー側の実装はお気に入りのSeasar2 Teedaを利用しているのですが、どうも納得のいかん部分があるので書いておきます。</p>
<p><strong>１．URLを操作しにくい。</strong><br />
Webアプリケーションを作成する上でURLのつけ方にはこだわりを持ちたいものですが、URLの操作がしにくい。/view/サブアプリケーション名/○○.htmlみたいな形にしかできない。diconの書き換えをすればできるかもですが、この辺は作成する側に任せてほしい。ApacheのRewriteなどで対応できそうではあるが。</p>
<p><strong>２．GETメソッドって使える？</strong><br />
基本はPRGパターン（POST-REDIRECT-GET）になっていて、スコープの状態を保存して画面遷移するみたいですが、たとえば、検索などでURLにパラメーターを残したい場合に対応できない。これももう少し調べるとできるのかもだが、まだよくわかってません。</p>
<p><strong>３．HTMLのチェックが厳格すぎる。</strong><br />
これを言ってしまえば、フレームワーク使うなって話だけど、結局HTMLってプログラマー以外の人も触るものだし、なんとかならんかなとも思ったりする。</p>
<p>業務系のWebアプリとか、フォーム系の処理なんかは、すごくマッチするフレームワークだと思うけど、例えば簡単な携帯サイトや検索アプリなんかは作りにくいなあと感じます。</p>
<p>まだ不勉強でこんなことを言ってますが、初心者が陥りやすいミスとか気づいたこととかあれば、またこのブログに載せていきます。</p>
]]></content:encoded>
			<wfw:commentRss>http://ueblog.natural-wave.com/2007/09/17/s2-teeda/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ueblog.natural-wave.com/2007/09/17/s2-teeda/" />
	</item>
		<item>
		<title>Seasar2 mini eventに行ってきました</title>
		<link>http://ueblog.natural-wave.com/2007/06/30/seasar2-mini-event/</link>
		<comments>http://ueblog.natural-wave.com/2007/06/30/seasar2-mini-event/#comments</comments>
		<pubDate>Fri, 29 Jun 2007 17:44:30 +0000</pubDate>
		<dc:creator>ueblog</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[Seasar]]></category>

		<guid isPermaLink="false">http://ueblog.natural-wave.com/2007/06/30/seasar2-mini-event/</guid>
		<description><![CDATA[Seasar2のmini eventに行ってきました。 場所は萌えの町アキバ！ しばらくぶりに行ったけど、だいぶ変わったな～ コスプレのおねえちゃんはともかくとして、、 中央通りのビルが軒並み建設中でいままでのような活気がなく感じた。 まさに再開]]></description>
			<content:encoded><![CDATA[<p>Seasar2のmini eventに行ってきました。<br />
場所は萌えの町アキバ！<br />
しばらくぶりに行ったけど、だいぶ変わったな～<br />
コスプレのおねえちゃんはともかくとして、、<br />
中央通りのビルが軒並み建設中でいままでのような活気がなく感じた。<br />
まさに再開発の途中って感じ。</p>
<p>まあアキバの話は置いておいて、<br />
自分も実践してるGTDのツール（<a href="http://tugboat-gtd.sandbox.seasar.org/index.html" target="_blank">tugboat.GTD</a>）の話と<br />
まさに勉強中のSeasar2の話が聞けるということで行ってみました。</p>
<p>Seasar関連のイベントは初めてで、生ひがさんを見たのも初めて！<br />
自分にとっては、かなり参考になったので、<br />
ひがさんの話を思い出しながら（メモ帳を忘れてしまったのでうろ覚えですが）<br />
簡単に感想＆まとめを書いてみます。</p>
<blockquote><p>まずWebアプリケーションにおけるレイヤモデルの問題点。<br />
プレゼンテーション層、サービス層、ドメイン層、データアクセス層、リソース…<br />
各々の層をインターフェースを用いて疎結合するという方法は、<br />
各層の役割が明確化して、修正による影響が低いというところがあげられるが、<br />
どの層にクラスを持っていくべきか迷う場合がある。<br />
またインターフェースやクラスが大量に作成されることになり<br />
クラスの管理、テストの面においても煩雑になってしまう。</p></blockquote>
<p>自分も以前のJ2JSFを利用したときに体験したので確かに、<br />
何もロジックのないクラスを作ったりすることの無駄はあるなーと感じていたので<br />
かなり同感できました。</p>
<blockquote><p>teedaの1ページ1クラス、1ユースケースに1サービスクラスという構造。<br />
共通機能はサービスクラスに置き、継承を利用する。</p></blockquote>
<p>これならどこにロジックをおくべきなのかは明らか。</p>
<blockquote><p>ユースケースの粒度については、メニューの1機能が1ユースケースと考える。<br />
異なるユースケース間の共通機能は委譲モデルを利用して<br />
共通ユースケースを作成して実現する。</p></blockquote>
<p>なるほど。またこのような考え方は、複数人開発をイメージしていて、<br />
1ユースケースが一人で作成して、重複しないように考えられているそうです。</p>
<p>私の周りでjava関連のフレームワークを利用していない人は、<br />
クラスの管理や考え方が煩雑で複雑なイメージを持っている方が多いですが、<br />
teedaならシンプルに考えられそうな気がしてきました。<br />
これはぜひteeda試さないと！</p>
<p><a href="http://tugboat-gtd.sandbox.seasar.org/index.html" target="_blank">tugboat.GTD</a>の資料は<a href="http://d.hatena.ne.jp/yousukehara/20070629" target="_blank">haraさんのブログ</a>にありました。</p>
<p><a href="http://d.hatena.ne.jp/higayasuo/20070628" target="_blank">ひがさんのブログ</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ueblog.natural-wave.com/2007/06/30/seasar2-mini-event/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ueblog.natural-wave.com/2007/06/30/seasar2-mini-event/" />
	</item>
		<item>
		<title>JavaでAjax</title>
		<link>http://ueblog.natural-wave.com/2007/04/20/java-ajax/</link>
		<comments>http://ueblog.natural-wave.com/2007/04/20/java-ajax/#comments</comments>
		<pubDate>Thu, 19 Apr 2007 16:47:56 +0000</pubDate>
		<dc:creator>ueblog</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programing]]></category>

		<guid isPermaLink="false">http://ueblog.natural-wave.com/2007/04/20/java-ajax/</guid>
		<description><![CDATA[WebインターフェースをAjaxを利用し、サーバサイドのプログラムは Javaで実装したい場合、さまざまなスキルセットが必要となる。 思いついた部分だけであげてみると JavaScript DHTMLとCSS JSONもしくはXML アプリケーションサーバ （Tomcatなど） JavaServlet/JSP、Webフレームワークの知識 Eclipse]]></description>
			<content:encoded><![CDATA[<p align="left">WebインターフェースをAjaxを利用し、サーバサイドのプログラムは</p>
<p align="left">Javaで実装したい場合、さまざまなスキルセットが必要となる。</p>
<p align="left">思いついた部分だけであげてみると</p>
<blockquote>
<ul>
<li>JavaScript</li>
<li>DHTMLとCSS</li>
<li>JSONもしくはXML</li>
<li>アプリケーションサーバ （Tomcatなど）</li>
<li>JavaServlet/JSP、Webフレームワークの知識</li>
<li>Eclipseなどの開発ツール（複雑なフレームワークを利用する場合は必須であろう）</li>
<li>XMLパーサやXSLTなどのXML解析技術</li>
</ul>
</blockquote>
<p align="left">と盛りだくさんだ。また、非同期通信する際のWebインターフェース設計は</p>
<p align="left">いままでのページ単位の設計とは違う視点が必要になる。</p>
<p align="left">&nbsp;</p>
<p align="left"> このようにたくさんの技術が必要となると、</p>
<p align="left">Ajaxを利用したリッチなコンテンツを作りたくても足踏みしてしまいがちだが</p>
<p align="left">調べてみると、Ajax製作をサポートするフレームワークはJavaの世界でも</p>
<p align="left">いくつかある。</p>
<blockquote>
<p align="left"> Direct Web Remoting（DWR）<br />
Google Web Toolkit<br />
JSON-RPC-Java<br />
Restlet<br />
S2Ajax<br />
Ajax Baron</p></blockquote>
<p align="left">フレームワークによりさまざまだが、JavaScriptの実装をJavaプログラム</p>
<p align="left">で書けるようにしていたり、簡単に非同期通信、オブジェクトのやりとりを実現できる。</p>
<p align="left">&nbsp;</p>
<p align="left">現在、JSON-RPC-JAVAとSeasar2、DBはS2Daoを利用</p>
<p>あと、Ajax BaronのライブラリがXMLを取得するのに直感的でわかりやすいので</p>
<p>さまざまなWebAPIからデータを取得し、マッシュアップを試みていている。</p>
<p>のちほどまた詳細な実装例をレポートしようと思う。</p>
]]></content:encoded>
			<wfw:commentRss>http://ueblog.natural-wave.com/2007/04/20/java-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://ueblog.natural-wave.com/2007/04/20/java-ajax/" />
	</item>
	</channel>
</rss>

