2008年10月30日木曜日

Seam の UrlRewriteFilter

Seam 2.1 では標準でUrlRewriteFilterがサポートされているみたいなので、2.0で早速実験。
UrlRewrite.xml自身は特に理解が難しい物でもないので、日本語対応の物にしてみました。 ところが、UrlRewriteすると、そのままではcssが適用されなくなってしまいます。 これに付いては、「Seam In Action」(120ページ)に;
Quote

Friendly URLs can cause relative paths to bread since the servlet path is no longer representive of the rendered view. A reference to a stylesheet may stop working because the browser thinks that the friendly URL is the base URL of the resource. To solve this problem, you should use absolute reference to such resource, such as
#{facesContext.externalContext.request.contextPath}/stylesheet/theme.css

Unquote
とあります。  最初、これってどこに適用すれば良いのか分からなくて四苦八苦したのですが、 layout/template.xhtml への追加で解決。

これで、 「http://xxxx/会社別登録農薬一覧/日本農薬」などというURLの指定が可能となりました。 これ以外にも、下のような物を入れてみました(これって、xhtml書かなくても、使いまわしが出来てしまうので、癖になりそう。 楽!!)

実際の物は http://www.agriculture.jp/にありますが、この「登録農薬適用表」等の使われている用語はcrawlerはどうやって見つけ出すんですかね? (URLどうするか、決めかねている部分が有るんで、http://www.agriculture.jp/agr/登録農薬適用表/xxxxxx (登録番号) とagrをつけないと駄目です)


^/登録農薬適用表/([0-9]+)$
/ApplicationsListByRegistration.seam?registrationsRegistrationNumber=$1


^/会社別登録農薬一覧/(.*)$
/RegistrationsList1.seam?productName=&companyName=$1


^/製品名別登録農薬一覧/(.*)$
/RegistrationsList1.seam?productName=$1&companyName=


^/作物別登録殺菌剤一覧/(.*)$
/ApplicationsListByCrop2.seam?applicationMethod=&pestsRank=2&cropForSearch=$1


^/作物別登録殺虫剤一覧/(.*)$
/ApplicationsListByCrop2.seam?applicationMethod=&pestsRank=1&cropForSearch=$1


^/作物別登録除草剤一覧/(.*)$
/ApplicationsListByCrop2.seam?applicationMethod=&pestsRank=3&cropForSearch=$1

0 件のコメント:

RM Noise

最近Galaxyの携帯のCMで風のノイズ除去をしているシーンが気になっていて、「AIで処理すれば、ノイズ除去性能は上がるのでは?」なんて思いながら、 AIのopen source?の Hagging face をブラブラしていましたら、何故かFacebookで RM noize ...