ラベル prudence の投稿を表示しています。 すべての投稿を表示
ラベル prudence の投稿を表示しています。 すべての投稿を表示

2010年11月23日火曜日

Prudence groovy editionでquery parameterを取得する

Prudence groovy editionでquery parameterを取得するには、以下のコードを実行します。

PRUDENCE_HOME/applications/test4/web/dynamicディレクトリに
query.htmlを以下の内容で作成
<html>
<head><title>query test</title></head>
<body>
<%
print "param1=${conversation.query['param1']}<br/>"
print "param2=${conversation.query['param2']}<br/>"
%>
</body>
</html>


ブラウザでhttp://localhost:8080/test4/query/?param1=123¶m2=abcにアクセスする。

動作環境
Prudence "Luscious Groovy" Edition R571, JDK6 Update22

関連情報
prudenceのウェブサイト
http://threecrickets.com/prudence/

2010年11月22日月曜日

Prudence groovy editionでルーティングを変更する

Prudence groovy editionでルーティングを変更するには、以下のコードを実行します。

PRUDENCE_HOME/applications/test3/web/dynamicディレクトリに
display_entry.htmlを以下の内容で作成
<html>
<head><title>capture test</title></head>
<body>
<%
entryID = conversation.locals.get('entryid')
println "entry id:${entryID}"
%>
</body>
</html>

PRUDENCE_HOME/applications/test3/ディレクトリに
routing.gvを以下の内容で作成
document.execute('defaults/application/routing/')
router.capture('display_entry/{entryid}/', 'display_entry/')

ブラウザでhttp://localhost:8080/test3/display_entry/123/にアクセスする。
123がentryIDとして処理されてdisplay_entryにルーティングされる。

動作環境
Prudence "Luscious Groovy" Edition R571, JDK6 Update22

関連情報
prudenceのウェブサイト
http://threecrickets.com/prudence/

2010年11月21日日曜日

Prudence groovy editionでライブラリをインクルードする

Prudence groovy editionでライブラリをインクルードするには、以下のコードを実行します。

PRUDENCE_HOME/applications/test2/web/dynamicディレクトリに
index.htmlを以下の内容で作成
<html>
<head><title>libraries test</title></head>
<body>
<%
document.execute('libtest/')
println getMessage()
%>
</body>
</html>

PRUDENCE_HOME/applications/test2/librariesディレクトリに
libtest.groovyを以下の内容で作成

getMessage = {
return "hello."
}

※ライブラリ内でクロージャはOKだけど、クラスは定義できない?

ブラウザでhttp://localhost:8080/test2/にアクセスする

動作環境
Prudence "Luscious Groovy" Edition R571, JDK6 Update22

関連情報
prudenceのウェブサイト
http://threecrickets.com/prudence/

2010年11月20日土曜日

Prudence groovy editionでフラグメントをインクルードする

Prudence groovy editionでフラグメントをインクルードするには、以下のコードを実行します。

PRUDENCE_HOME/applications/test1/web/dynamicディレクトリに
index.htmlを以下の内容で作成
<html>
<head><title>fragment test</title></head>
<body>
<%& 'fragment1/' %>
</body>
</html>


PRUDENCE_HOME/applications/test1/web/fragmentsディレクトリに
fragment1.htmlを以下の内容で作成
<p>included fragment.</p>


ブラウザでhttp://localhost:8080/test1/にアクセスする

動作環境
Prudence "Luscious Groovy" Edition R571, JDK6 Update22

関連情報
prudenceのウェブサイト
http://threecrickets.com/prudence/

2010年10月31日日曜日

Prudence groovy editionでHello Worldを作成する

Prudence groovy editionでHello Worldを作成するには、以下のコードを実行します。

PRUDENCE_HOME/applications/test/web/dynamicディレクトリに
index.htmlを以下の内容で作成。

<html>
<head><title>prudenceとgroovy</title></head>
<body>
<%
print("prudence groovy editionでhello world" + new Date())
%>
</body>
</html>

※Windowsの場合はUNIX形式ファイルで保存する(改行がLF)。

ブラウザでhttp://localhost:8080/test/にアクセスする。

動作環境
Prudence "Luscious Groovy" Edition R571, JDK6 Update22

関連情報
prudenceのウェブサイト
http://threecrickets.com/prudence/

CentOS5.5にPrudence "Luscious Groovy" Editionをインストールする

CentOS5.5にPrudence "Luscious Groovy" Editionをインストールするには、以下の手順を実行します。

1.以下のサイトからPrudence "Luscious Groovy" Editionをダウンロード
http://threecrickets.com/prudence/download/

2.解凍とパーミッション変更
mkdir /opt/prudence-groovy-R751
mv prudence-groovy-R751.zip /opt/prudence-groovy-R751
unzip prudence-groovy-R751.zip
cd /opt/prudence-groovy-R751/bin
chmod +x run.sh

3.prudence実行
以下のコマンドを実行
cd /opt/prudence-groovy-R751/bin
./run.sh console

ブラウザから以下のアドレスを入力して動作確認
http://yourhost:8080/

※JDKはあらかじめ導入しておくこと。

動作環境
Prudence "Luscious Groovy" Edition R571, JDK6 Update22

関連情報
prudenceのウェブサイト
http://threecrickets.com/prudence/