*趣旨 [#ucb191c0] PLAY! FRAMEWORKについて調べたことをメモしておく 一般の単語であるPLAYをつかっているため、検索に引っかかりにくいようだ。 *目次 [#qde659da] #contents *Play!の概要 [#a98bb4bb] Play framework は、Railsのような生産性の高い、JavaでもつかえるしScalaでもつかえるフレームワークといったところ。 *リンク [#w18fc933] **日本語の分かりやすいサイト [#m272e530] http://playdocja.appspot.com/documentation/1.2.4/home 本家は、version2.0.1が出ているが、まずはこれを読もう。とても丁寧にかいてあるからだ。 **チートシート(よくつかうコマンド一覧) [#f131ac2b] http://playdocja.appspot.com/documentation/1.2.4/cheatsheet/model 英語 http://playcheatsheet.appspot.com/show/ArtemMedeu/armed/play-cheatsheets **2.0のドキュメント(英語) [#v922396b] http://www.playframework.org/documentation/2.0.1/Home **ダウンロード [#oc3c912b] ダウンロードは下記のアドレスからダウンロードできる。90MBある。ちょっとしたボリュームだ。 http://download.playframework.org/releases/ *playのインストールをしてみる実況 [#o24a456d] cd c:\play-2.0.1 play new helloworld なにやらたりないライブラリをとってきているようだ。 What is the application name? と聞いてくる。 すでにhelloworldがはいっている したがってそのままEnterキー -1 ... Scala -2 ... Java -3 ... empty 2 を選ぶ、あとでScalaでも同様のことをまなんでみよう。 **動作確認 [#yb42f698] play run helloworld this is not play application とでる。 cd helloworld ..\play run とやるとうごく。playのパスを環境変数に登録しておいたほうがよさそうだ。 SET PATH=%PATH%;c:\play-2.0.1 localhost:9000 にアクセスする。 裏でコンパイルが走っている模様 もう、ページが出てきた。マニュアルページだ。 コンソールに戻りたくなったので、CTRL+Dで戻る こんどは ../play コンソールがでてきた。 run ってやってみた うごいた 再びCTRL+D プロジェクトをエクリプスのプロジェクトにする **エクリプスで開発 [#h0aec330] こんどは、 eclipsify おおっエクリプスのプロジェクトできた エクリプスたちあげて、 [ファイル]-[インポート]-[既存のプロジェクト] jarファイルがたくさんみえるので、 [ウィンドウ]-[ビューの表示]-[ナビゲータ] でみるとすっきりとした感じにみえる *チェックボックスの書き方 [#bc37d927] http://stackoverflow.com/questions/8204708/how-do-i-bind-a-checkbox-to-a-boolean-in-play-framework *Play Framework で OpenID に接続して、認証後のユーザ情報をセッションに格納するサンプルコード [#xdbec0d3] https://gist.github.com/1523390 *複数行の取り扱いについて [#b8bb101e] http://stackoverflow.com/questions/7417321/how-to-submit-a-list-of-objects-in-play-framework *モジュール [#h9d64531] http://www.playframework.org/modules scaffoldとか、javascript最小化モジュールとかいろいろある **ページ処理モジュール? [#k8caa31d] http://www.playframework.org/modules/paginate-head/home *play frameworkのバッチあてた版のダウンロード先 [#y06811dc] https://github.com/mbknor/play/tree/1.2.4-mbknor-custom-release *テスト [#t92f06bf] http://www.playframework.org/documentation/1.2.1/test *scaffold [#j978d9dc] http://yono05.wordpress.com/2011/11/03/play-scaffold%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%81%BF%E3%81%9F/ *フォームからのデータの受け取り方法 [#i62ad3c7] **配列 [#a9eab9ea] <INPUT TYPE="hidden" name="formList[0]" id="formList0" value="bar" /> Java側は変数名を上記のname属性と同一名とし、List型で受け取るようにする。 List formList *高速なテンプレートエンジン [#c05520f5] http://www.playframework.org/modules/fastergt http://kjetland.com/blog/2011/11/playframework-new-faster-groovy-template-engine/ http://yosuke-furukawa.hatenablog.com/entry/20111219/1324306476 https://groups.google.com/forum/?fromgroups#!topic/play-framework/fz_iakmj_uc *レンダリング結果の取得 [#c3872dde] これをつかえば、レンダリングの仕組みを、コード生成など、いろいろ別用途につかえますね。 **情報源 [#qff27dac] http://garbagetown.github.com/blog/2012/07/10/08-57/ **コード [#xc1bdd6b] private static String getHtml(String version, String id) { String html = null; if (Play.mode == Play.Mode.PROD && !isTextile(version)) { (snip) } else { (snip) Template template = TemplateLoader.load("Documentation/page.html"); Map<String, Object> args = new HashMap<String, Object>(); args.put("request", request); args.put("versions", versions); args.put("version", version); args.put("id", id); args.put("article", article); args.put("navigation", navigation); html = template.render(args); } return html; }