2012年11月21日水曜日

アドオンマネージャを使用して日本語化 / Adding japanese resource etc using addon manager

Prepare


Install
  1. Download addon from here http://sourceforge.jp/projects/ofbiz-jp/downloads/57320/languagePack-0.1.1-v11.04.01.zip/
  2. Use follow command in command prompt
  3. cd <ofbiz.home>
    adm install languagePack-0.1.1-v11.04.01.zip
etc


準備

導入
  1. ここから言語パックをダウンロードしてください。 http://sourceforge.jp/projects/ofbiz-jp/downloads/57320/languagePack-0.1.1-v11.04.01.zip/
  2. 次のコマンドで言語パックをインストールします。
  3. cd <OFBizをインストールしたパス>
    adm install <ダウンロードしたパス>\languagePack-0.1.1-v11.04.01.zip

その他




2012年11月15日木曜日

Apache OFBiz 10.04.04

今日Apache OFBiz 10.04.04がリリースされていました。10.04.03から日にちが経っていませんが、Bugfixということです。languagePack-0.1.0-v10.04.03がそのまま使えました。

Today, Apache OFBiz 10.04.04 released. languagePack-0.1.0-v10.04.03 can install for 10.04.04.

2012年11月7日水曜日

Add-on on Windows platform

Addon Managerを使うと簡単にOFBizに機能やパッチの追加/削除ができます。Neogia Add-onをWindows上で使用します。もともとUnix系での使用を想定しているため、Windowsでは別途GNU patch、diffが必要になります。

必要なものは
  1. Add-on Manager (http://code.google.com/a/apache-extras.org/p/ofbiz-adm/downloads/list)
  2. patch.exe, diff.exe (http://gnuwin32.sourceforge.net/)
  3. todos.exe (http://www.thefreecountry.com/tofrodos/index.shtml)

準備
  1. C:\gnuwin32\binフォルダを作成して、ダウンロードしたファイルを格納します。zipは展開します。
  2. フォルダにpatch.batファイルを次の内容で作成します。
  3. @ECHO OFF
    todos %3
    todos %4
    C:\gnuwin32\bin\patch.exe %1 %2 %3 %4

  4. フォルダにdiff.batファイルを次の内容で作成します。
  5. @ECHO OFF
    todos %2
    todos %3
    C:\gnuwin32\bin\diff.exe %1 %2 %3

  6. フォルダにadm.batファイルを次の内容で作成します。
  7. @ECHO OFF
    java C:\gnuwin32\bin\addonmanager.jar %*

  8. システムのプロパティでシステム環境変数PATHに上記のパスを追加します。

実行
たとえばlanguagePackアドオンをインストールする場合、コマンドプロンプトから次のコマンドでインストールします。
    C:\gnuwin32\bin> adm install languagePack-0.1.1-v11.04.01.zip
インストール済アドオンのアンインストール
    C:\gnuwin32\bin> adm uninstall languagePack
インストール済アドオンの一覧表示
    C:\gnuwin32\bin> adm list


Using Add-on Manager on Windows
  1. Download and Add-on Manager (http://code.google.com/a/apache-extras.org/p/ofbiz-adm/downloads/list)
  2. Download patch.exe, diff.exe (http://gnuwin32.sourceforge.net/)
  3. Make a directory, for example C:\gnuwin32\bin, and extract downloaded zip files in it. And copy jar file also in it.
  4. Create patch.bat file into the directory and edit like this.
  5. @ECHO OFF
    todos %3
    todos %4
    C:\gnuwin32\bin\patch.exe %1 %2 %3 %4

  6. Create diff.bat file into the directory and edit like this.
  7. @ECHO OFF
    todos %2
    todos %3
    C:\gnuwin32\bin\diff.exe %1 %2 %3

  8. Create adm.bat file into the directory and edit like this.
  9. @ECHO OFF
    java C:\gnuwin32\bin\addonmanager.jar %*

  10. Set environment variable PATH.
  11. For example. To install languagePack Addon, exec command line, adm install languagePack-0.1.1-v11.04.01.zip

Links
Neogia Add-on Manager: http://neogia.org/wiki/index.php/Add-on_Manager
Neogia Add-on: http://neogia.org/wiki/index.php/OFBiz_add-on
Add-ons: http://addons.neogia.org/
Apache-extra: http://code.google.com/a/apache-extras.org/p/ofbiz-adm/
Apache-extra wiki (about how to install etc.) http://code.google.com/a/apache-extras.org/p/ofbiz-adm/w/list


2012.11.07 created.
2012.11.24 modified.

2012年11月2日金曜日

Hello World

Apache OFBizでHello Worldを作ってみましょう。

コンポーネントの作成



  1. hot-deploy(C:\ofbiz\hot-deploy)にディレクトリ(フォルダ)を作成します。"helloworld"(hotdeploy/helloworld)という名前で作成します。ディレクトリ名は、新しく作成するコンポーネント名と一致させます。OFBizではカスタマイズの開発をhot-deployに作成することが推奨されています。
  2. 作成したhot-deploy/helloworldディレクトリにofbiz-component.xmlファイルを作成します。内容は次の とおりです。(framework/exampleなど他のコンポーネントに含まれているファイルを参考にしてください)。
  3. <?xml version="1.0" encoding="UTF-8"?>
    <ofbiz-component name="helloworld"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd">
          <resource-loader     name="main" type="component"/>
        <webapp name="helloworld"
           title="Hello World"
           server="default-server"
           base-permission="OFBTOOLS"
           location="webapp/helloworld"
           mount-point="/helloworld"
           app-bar-display="false"/>
    </ofbiz-component>

    ofbiz-component.xmlの説明


    1. ofbiz-component.xmlファイルは、リソースがどこに格納されているかをOFBizに通知し、リソースをクラスパスに追加することができるようにします。
    2. "resource-loader"の名前には任意の文字列を指定することができます。ここでは、"main"として設定されています。 "type"はコンポーネントをロードすることをOFBizに指示します。
    3. <webapp>タグにはいくつかの属性がありますが、目的は次のとおりです。
    • name: Webアプリケーションの名前を定義します。
    • title:ナビゲーションの上部に表示されるアプリケーションのタイトルになります。
    • server: 使用するサーバーをOFBizに通知します。
    • base-permission: ユーザーがアプリケーションを使用する時にOFBTOOLS権限が必要なことを示します。"admin"ユーザーがこの権限を持っているので、新しいユーザーを作成する必要はありません。
    • location: サーバーのデフォルト・ベース・ディレクトリの場所になります。
    • mount-point: このリソースにアクセスするために使用されるURLです。 この場合、localhost:8080/helloworldとなります。
    • app-bar-display: このコンポーネントが共通ofbizデコレータの一部としてメイン・アプリケーション・タブに表示したい場合に、OFBizに通知します。

    Webアプリケーションの作成

    1. helloworldコンポーネントに"webapp"ディレクトリを作成します(hot-deploy/helloworld/webapp)。作成するコンポーネントのWebアプリケーションに関連するファイルがこのディレクトリにすべて含まれます。
    2. 作成するWebアプリケーションの名前"helloworld"で、webappディレクトリ内にサブディレクトリを作成します(hot-deploy/helloworld/webapp/helloworld)。コンポーネントには、関連した複数のWebアプリケーションを含めることができます。例えば"marketing"のコンポーネントには、"marketing"と"sfa"の2つのWebアプリケーションが含まれています。作成するWebアプリケーションは、J2EE Webアプリケーション標準に準拠しています。
    3. Webアプリケーションに、WEB-INFディレクトリを作成します(hot-deploy/helloworld/webapp/helloworld/WEB-INF)。OFBiz Webアプリケーションは、controller.xmlおよびweb.xmlの2つの構成ファイルが必要です。controller.xmlは訪問者のさまざまな要求をOFBizがどのように処理するか、どのようなアクションを実行するか、どのようなページをレンダリングするかを指示します。web.xmlは(データベースやビジネス•ロジックにアクセスする)どのようなリソースがこのWebアプリケーションで利用可能か、ウェルカムページ、リダイレクト、およびエラーページのようなWeb関連の問題を処理する方法をOFBizに指示します。
    4. "web.xml"という名前でファイルを作成します(web.xmlは2EE Webアプリケーション仕様に準拠します)。このファイルの内容は、既存のコンポーネントからコピーすることができます。例えば、/framework/exampleコンポーネントからコピーします。変更する重要な値は<display-name>、localDispatcherName、mainDecoratorLocationおよびwebSiteIdです。

    5. <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
      <!--
      Licensed to the Apache Software Foundation (ASF) under one
      or more contributor license agreements.  See the NOTICE file
      distributed with this work for additional information
      regarding copyright ownership.  The ASF licenses this file
      to you under the Apache License, Version 2.0 (the
      "License"); you may not use this file except in compliance
      with the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

      Unless required by applicable law or agreed to in writing,
      software distributed under the License is distributed on an
      "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
      KIND, either express or implied.  See the License for the
      specific language governing permissions and limitations
      under the License.
      -->

      <web-app>
          <display-name>Hello World</display-name>
          <description>Hello World for the Open For Business Project</description>

          <context-param>
              <param-name>webSiteId</param-name>
              <param-value>HELLOWORLD</param-value>
              <description>A unique ID used to look up the WebSite entity</description>
          </context-param>
          <context-param>
              <param-name>localDispatcherName</param-name>
              <param-value>helloworld</param-value>
              <description>A unique name used to identify/recognize the local dispatcher for the Service Engine</description>
          </context-param>
          <context-param>
              <param-name>entityDelegatorName</param-name>
              <param-value>default</param-value>
              <description>The Name of the Entity Delegator to use, defined in entityengine.xml</description>
          </context-param>
          <context-param>
              <param-name>mainDecoratorLocation</param-name>
              <param-value>component://helloworld/widget/CommonScreens.xml</param-value>
              <description>The location of the main-decorator screen to use for this webapp; referred to as a context variable in screen def XML files.</description>
          </context-param>
          <context-param>
              <param-name>widgetVerbose</param-name>
              <param-value>false</param-value>
              <description>Enable widget boundary comments. See org.ofbiz.widget.ModelWidget.widgetBoundaryCommentsEnabled().</description>
          </context-param>
          <context-param>
              <param-name>compressHTML</param-name>
              <param-value>false</param-value>
              <description>Remove unnecessary whitespace from HTML output.</description>
          </context-param>

          <filter>
              <filter-name>ContextFilter</filter-name>
              <display-name>ContextFilter</display-name>
              <filter-class>org.ofbiz.webapp.control.ContextFilter</filter-class>
              <init-param><param-name>disableContextSecurity</param-name><param-value>N</param-value></init-param>
              <init-param>
                  <param-name>allowedPaths</param-name>
                  <param-value>/error:/control:/select:/index.html:/index.jsp:/default.html:/default.jsp:/images:/includes/maincss.css</param-value>
              </init-param>
              <init-param><param-name>errorCode</param-name><param-value>403</param-value></init-param>
              <init-param><param-name>redirectPath</param-name><param-value>/control/main</param-value></init-param>
          </filter>
          <filter-mapping><filter-name>ContextFilter</filter-name><url-pattern>/*</url-pattern></filter-mapping>

          <listener><listener-class>org.ofbiz.webapp.control.ControlEventListener</listener-class></listener>
          <listener><listener-class>org.ofbiz.webapp.control.LoginEventListener</listener-class></listener>
          <!-- NOTE: not all app servers support mounting implementations of the HttpSessionActivationListener interface -->
          <!-- <listener><listener-class>org.ofbiz.webapp.control.ControlActivationEventListener</listener-class></listener> -->

          <servlet>
              <servlet-name>ControlServlet</servlet-name>
              <display-name>ControlServlet</display-name>
              <description>Main Control Servlet</description>
              <servlet-class>org.ofbiz.webapp.control.ControlServlet</servlet-class>
              <load-on-startup>1</load-on-startup>
          </servlet>
          <servlet-mapping><servlet-name>ControlServlet</servlet-name><url-pattern>/control/*</url-pattern></servlet-mapping>

          <session-config><session-timeout>60</session-timeout><!-- in minutes --></session-config>

          <welcome-file-list>
              <welcome-file>index.jsp</welcome-file>
              <welcome-file>index.html</welcome-file>
              <welcome-file>index.htm</welcome-file>
          </welcome-file-list>
      </web-app>

      • 練習用としてwebsiteIdに"HELLOWORLD"を設定しています。
      • mainDecoratorLocationに"component://helloworld/widget/CommonScreens.xml"の値を設定しています。使用する場合次のように指定します:${parameters.mainDecoratorLocation} 

    6. "controller.xml"という名前のファイルを作成します(ofbiz webappのコントローラとして使用されます)。このファイルは最初は小さく、シンプルですが、後で機能を追加すると大きくなっていきます。最初に次のコードを挿入します。
    7. <?xml version="1.0" encoding="UTF-8"?>
      <site-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/site-conf.xsd">
             <include location="component://common/webcommon/WEB-INF/common-controller.xml"/>
             <description>Hello World Component Site Configuration File</description>
             <owner>Copyright 2001-2009 The Apache Software Foundation</owner>
             <handler name="screen" type="view" class="org.ofbiz.widget.screen.ScreenWidgetViewHandler"/>
             <!-- Request Mappings -->
             <request-map uri="main">
                 <security https="false" auth="false"/>
                 <response name="success" type="view" value="main"/>
             </request-map>
             <!-- end of request mappings -->
             <!-- View Mappings -->
             <view-map name="main" type="screen" page="component://helloworld/widget/HelloWorldScreens.xml#main"/>
             <!-- end of view mappings -->
      </site-conf>

    8. 1つ上のレベルに移動して"error"(hot-deploy/helloworld/webapp/helloworld/error)という名前の新しいディレクトリを作成します。
      •   "error"ディレクトリ内にファイルerror.jspを作成します。このファイルは、exampleコンポーネントなど既存のコンポーネントからコピーすることができます。エラーページの場所は<errorpage>/error/error.jsp</errorpage>のようにcontroller.xmlファイルの先頭に指定します。表示するエラーメッセージはhot-deploy/helloworld/webapp/helloworld/error/error.jspを作るか、あるいはコピーしてくる必要があります。
    9. コンポーネント•ディレクトリ"helloworld"内に"widget"(hot-deploy/helloworld/widget)という名前のサブディレクトリを作成します。このディレクトリには、フォーム、メニュー、およびUI用に作成される画面が含まれます。
    10. ディレクトリ"widget"内に"HelloWoldScreens.xml"という名前のファイルを作成します。このファイルの内容は、既存のコンポーネントなどからコピーすることができます。たとえばexampleコンポーネントから。
    11. <?xml version="1.0" encoding="UTF-8"?>
      <screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd">
          <screen name="main">
              <section>
                  <widgets>
                      <label text="Hello World"/>
                  </widgets>
              </section>
          </screen>
      </screens>

    12. これまで作成したファイルと、流れを確認します。基本的な流れは規模の大小に関係なく同じです。まず、特定のリソースを表示するため、リクエストがブラウザによって行われます。例えば"http://localhost:8080/helloworld/control/main"のようなリクエストがあります。
      • OFBizがこのリクエストを受け取った時に、まず/helloworldセクションを探します。ofbiz-component.xmlファイルのwebアプリケーションのマウントポイントが/helloworldを指しています。これでOFBizは、helloworldコンポーネントの処理を行うことがわかります。
      • OFBizはその後、controller.xmlファイルを見ます。controller.xmlファイルでは、リクエストマップおよびビューマップがあります。'main'という名前のリクエストマップを見つけると、ビューマップに関連付けられて使用されます。リクエストマップはいずれかのビュー、あるいはイベントやサービスを指定することができます。
      • 今回のシンプルな例では、タイプ=screen(画面)のビューに移動すると仮定します。この場合、ページ•タグは、画面定義ファイルへのパスと同時に"#"記号の後に表示する画面名を指定します。
    13. さあ初めてのHelloWorldアプリケーションを実行してみましょう!コマンドラインで次のコマンドを入力して、サーバーを起動します:java -Xmx256m -jar ofbiz.jar (-Xmx256mはプログラムに十分なメモリを与えるためです)。その後ブラウザでhttp://localhost:8080/practice/control/mainを指定すると、次のように表示されるはずです。
    14. 出力画面:


    15. webappディレクトリ"helloworld"にindex.jspという名前でファイルを作成します(このファイルの内容は、"example"コンポーネントからコピーすることができます)。このファイルは、http://localhost:8080/helloworld/としてURLを与えた場合に、control/mainに、レスポンスをリダイレクトします。