2012年12月9日日曜日

Using JRuby / JRubyを使用する

You can use JRuby on Apache OFBiz Serrvice like Jython, Javascript etc.

Prepare
  1. Install patchJython addon. see http://ofbizj.blogspot.jp/2012/12/jython-script.html
  2. Download and install JRuby. see http://www.jruby.org/download
  3. Copy jruby.jar file from <jruby_home>/lib directory to <ofbiz_home>/framework/base/lib/scripting directory.
  4. Edit <ofbiz_home>/framework/service/config/serviceengine.xml file and add next line.

    <engine name="ruby" class="org.ofbiz.service.engine.BSFEngine"/>

JythonやJavascript同様にApache OFBizのサービスでJRubyを使用することができます。

準備
  1. あらかじめpatchJython アドオンをインストールしておきます。 http://ofbizj.blogspot.jp/2012/12/jython-script.html
  2. JRubyをダウンロードしてインストールします。.  http://www.jruby.org/download
  3. jruby.jar ファイルを <jruby_home>/lib ディレクトリから <ofbiz_home>/framework/base/lib/scripting ディレクトリにコピーします。
  4. <ofbiz_home>/framework/service/config/serviceengine.xml ファイルに次の行を追加します。

    <engine name="ruby" class="org.ofbiz.service.engine.BSFEngine"/>



Using Javascript / Javascriptを使用する

Prepare
  1. Download patchJavascript addon from http://sourceforge.jp/projects/ofbiz-jp/downloads/57320/patchJavascript-0.1.0-v11.04.01.zip and install.
  2. Rebuild java source by using ant command (no options).

Example
  1. In this example, modify Jython sample. see http://ofbizj.blogspot.jp/2012/12/jython-script.html
  2. In directory hot-deploy/helloworld/script/org/ofbiz/test, create file JavaScriptTest.js and edit like bellow.

    importPackage(java.lang);
    importPackage(java.util);

    response = new HashMap();
    response.put("result", "OK");
    bsf.registerBean("response", response)
    System.out.println("Hello !");

  3. Edit file hot-deploy/helloworld/servicedef/service.xml like bellow.

    <services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nonamespaceschemalocation="http://ofbiz.apache.org/dtds/services.xsd">
        <description>OFBIZ Test Services</description>
        <vendor>OFBiz</vendor>
        <version>1.0</version>

        <service auth="false" engine="jython" invoke="" location="component://helloworld/script/org/ofbiz/test/JythonScriptTest.py" name="testJythonScript">
            <description>Test JythonScript Service</description>
            <attribute mode="OUT" name="result" type="String">
        </attribute></service>
        <service auth="false" engine="javascript" invoke="" location="component://helloworld/script/org/ofbiz/test/JavaScriptTest.js" name="testJavaScript">
            <description>Test JavaScript Service</description>
            <attribute mode="OUT" name="result" type="String">
        </attribute></service>
    </services>

  4. Edit hot-deploy/helloworld/webapp/helloworld/WEB-INF/controller.xml like bellow.

        <request-map uri="main">
           <security https="false" auth="false"/>
           <event type="service" invoke="testJavaScript"/> <= edit this line
           <response name="success" type="view" value="main"/>
        </request-map>

  5. see http://localhost:8080/helloworld/control/main page using browser and see logs. Browser displays "helloworld" and in logs shows "Hello !".


準備
  1. patchJavascript アドオンを次の場所からダウンロードします http://sourceforge.jp/projects/ofbiz-jp/downloads/57320/patchJavascript-0.1.0-v11.04.01.zip 。その後、adm install patchJavascript-0.1.0-v11.04.01コマンドでインストールします。
  2. Javaソースがパッチで変更されるのでantコマンドで再ビルドします。antコマンドのオプションは不要です。OFBIZ_HOMEディレクトリに移動してから実行してください。

実行
  1. patchJythonのサンプルを使用しますのであらかじめ準備してください http://ofbizj.blogspot.jp/2012/12/jython-script.html
  2. hot-deploy/helloworld/script/org/ofbiz/test ディレクトリに JavaScriptTest.js ファイルを次の内容で作成します。

    from java.util import HashMap
    response = HashMap()
    response.put("result", "OK")
    bsf.registerBean("response", response)
    print "Hello !"

  3. hot-deploy/helloworld/servicedef/service.xml ファイルを次の内容に編集します。

    <services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nonamespaceschemalocation="http://ofbiz.apache.org/dtds/services.xsd">
        <description>OFBIZ Test Services</description>
        <vendor>OFBiz</vendor>
        <version>1.0</version>

        <service auth="false" engine="jython" invoke="" location="component://helloworld/script/org/ofbiz/test/JythonScriptTest.py" name="testJythonScript">
            <description>Test JythonScript Service</description>
            <attribute mode="OUT" name="result" type="String">
        </attribute></service>
        <service auth="false" engine="javascript" invoke="" location="component://helloworld/script/org/ofbiz/test/JavaScriptTest.js" name="testJavaScript">
            <description>Test JavaScript Service</description>
            <attribute mode="OUT" name="result" type="String">
        </attribute></service>
    </services>

  4. hot-deploy/helloworld/webapp/helloworld/WEB-INF/controller.xml ファイルを変更します。

        <request-map uri="main">
           <security https="false" auth="false"/>
           <event type="service" invoke="testJavaScript"/> <= edit this line
           <response name="success" type="view" value="main"/>
        </request-map>

  5. 次のURLをブラウザで表示します http://localhost:8080/helloworld/control/main 。画面には "helloworld" が表示されて、ログには "Hello !" が表示されて、サービスが呼び出されたことが確認できます。




2012年12月8日土曜日

Using Jython script / Jythonを使用する

For long years, OFBiz have impremented Jython script. But it not work well now. You can use jython script by using patchJython addon.

Prepare
  1. Download patchJython addon from http://sourceforge.jp/projects/ofbiz-jp/downloads/57320/patchJython-0.1.0-v11.04.01.zip and install.
  2. Rebuild java source by using ant command (no options).

Example
  1. In this example, use helloworld sample. see http://ofbizj.blogspot.jp/2012/11/hello-world.html
  2. Create directory hot-deploy/helloworld/script/org/ofbiz/test. In this directory, create file JythonScriptTest.py and edit like bellow.

    from java.util import HashMap
    response = HashMap()
    response.put("result", "OK")
    bsf.registerBean("response", response)
    print "Hello !"

  3. Create directory hot-deploy/helloworld/servicedef. In this directory, create file service.xml and edit like bellow.

    <services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nonamespaceschemalocation="http://ofbiz.apache.org/dtds/services.xsd">
        <description>OFBIZ Test Services</description>
        <vendor>OFBiz</vendor>
        <version>1.0</version>

        <service auth="false" engine="jython" invoke="" location="component://helloworld/script/org/ofbiz/test/JythonScriptTest.py" name="testJythonScript">
            <description>Test JythonScript Service</description>
            <attribute mode="OUT" name="result" type="String">
        </attribute></service>

    </services>

  4. Edit hot-deploy/helloworld/webapp/helloworld/WEB-INF/controller.xml like bellow. Service invoked before view screen.

        <request-map uri="main">
           <security https="false" auth="false"/>
           <event type="service" invoke="testJythonScript"/> <= add this line
           <response name="success" type="view" value="main"/>
        </request-map>

  5. see http://localhost:8080/helloworld/control/main page using browser and see logs. Browser displays "helloworld" and in logs shows "Hello !".


昔からOFBizではJythonスクリプト言語が実装されていましたが、現在はそのままではうまく動作しない状態です。きっと今では誰も使っていないのでしょう。次の方法で使用することができます。

準備
  1. patchJython アドオンを次の場所からダウンロードします http://sourceforge.jp/projects/ofbiz-jp/downloads/57320/patchJython-0.1.0-v11.04.01.zip 。その後、adm install patchJython-0.1.0-v11.04.01コマンドでインストールします。
  2. Javaソースがパッチで変更されるのでantコマンドで再ビルドします。antコマンドのオプションは不要です。OFBIZ_HOMEディレクトリに移動してから実行してください。

実行
  1. helloworldのサンプルを使用しますのであらかじめ準備してください http://ofbizj.blogspot.jp/2012/11/hello-world.html
  2. hot-deploy/helloworld/script/org/ofbiz/test ディレクトリを作成し、その中に JythonScriptTest.py ファイルを次の内容で作成します。

    from java.util import HashMap
    response = HashMap()
    response.put("result", "OK")
    bsf.registerBean("response", response)
    print "Hello !"

  3. hot-deploy/helloworld/servicedef ディレクトリを作成し、その中に service.xml ファイルを次の内容で作成します。

    <services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nonamespaceschemalocation="http://ofbiz.apache.org/dtds/services.xsd">
        <description>OFBIZ Test Services</description>
        <vendor>OFBiz</vendor>
        <version>1.0</version>

        <service auth="false" engine="jython" invoke="" location="component://helloworld/script/org/ofbiz/test/JythonScriptTest.py" name="testJythonScript">
            <description>Test JythonScript Service</description>
            <attribute mode="OUT" name="result" type="String">
        </attribute></service>

    </services>

  4. helloworldサンプルで作成済の hot-deploy/helloworld/webapp/helloworld/WEB-INF/controller.xml ファイルに次の1行を追加します。画面を表示する前にサービスが呼び出されます。

        <request-map uri="main">
           <security https="false" auth="false"/>
           <event type="service" invoke="testJythonScript"/> <= add this line
           <response name="success" type="view" value="main"/>
        </request-map>

  5. 次のURLをブラウザで表示します http://localhost:8080/helloworld/control/main 。画面には "helloworld" が表示されて、ログには "Hello !" が表示されて、サービスが呼び出されたことが確認できます。




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に、レスポンスをリダイレクトします。






2012年10月28日日曜日

Eclipseでデバッグ / Debugging on Eclipse

Eclipse上でApache OFBizをデバッグ/実行します。

 1. 実行>構成情報で、Javaアプリケーションを選択して、新規ボタンを押します。以下の設定を行います。

 2. メイン・タブ
  • 名前 OFBiz
  • プロジェクト ofbiz
  • メイン・クラス org.ofbiz.base.start.Start
 3. (x)= 引数タブ
  •  VM引数 -Xms128M -Xmx512M (これは例です適当に増やしてください、PermGenも不足気味です -XX:MaxPermSize=128m など指定してください)
 4. クラス・パス
  • ブーストラップ・エントリー JRE システム・ライブラリー (デフォルトのまま)
  • ユーザー・エントリー デフォルトのofbiz (デフォルト・クラスパス)を削除して、Jar追加ボタンで、OFBizプロジェクトのofbiz.jarを追加します
 5. ソース・タブ
  • 追加>Javaプロジェクトで、ofbizプロジェクトを追加します
適用ボタン、開始ボタンで開始します。

この方法でデバッグする場合、Javaソースを変更した時はantの再ビルドが必要です。スクリプトや設定ファイルの変更は反映されます。


Eclipseの準備 / Preparing Eclipse

Apache OFBIz のテスト、開発にはEclipseを使うのが便利です。
Eclipseは http://www.eclipse.org/http://mergedoc.sourceforge.jp/ からダウンロードしてください。
まずEclipseにプロジェクトをインポートします。ダウンロードしたApache OFBizをant run-installビルドした状態から開始します。インストール方法はこちらを参照してください http://ofbizj.blogspot.jp/2012/10/apache-ofbiz_24.html

 1. ファイル>インポートで、 既存プロジェクトをワークスペースへを選びます。

 2. ルートディレクトリの選択で、インストールしたC:\ofbizを選択します。

 3. 完了ボタンを押すとインポートされます。

エラーがある場合は、JDK1.6を使用していないことが考えられます。

 1. ウインドウ>設定>Java>インストール済みのJREで、jdk1.6を追加してください。

 2. プロジェクト>Java>Javaコンパイラーで、コンパイラー準拠レベルを1.6に設定してください。

OFBizの規約ではタブにスペース4個を使用します。Eclipseのコードスタイルを設定します。

 1. ウインドウ>設定>Java>コードスタイル>フォーマッター

 2. 新規ボタンを押します。プロファイル名はOFBizなど適当につけます。

 3. タブ・ポリシーでスペースのみを選択してください。


2012年10月26日金曜日

サンプルデータの日本語化 / Japanese sample data

1.ここから日本語リソースをダウンロードします。

  http://sourceforge.jp/projects/ofbiz-jp/downloads/57177/ofbiz_ja_demodata_v0_1.zip/

  ここには、勘定科目(CoA)、部署名、都道府県の日本語サンプルデータが含まれています。

2.ダウンロードしたzipファイルを展開するとofbiz_demodataフォルダが作成されます。

3.展開されたフォルダの中身を、OFBizホームに上書きします。

  例えばOFBizをC:\ofbizにインストールしていたとしたら、ofbiz_demodataフォルダの中身をC:\ofbizに上書きでコピーします。

4.すでにOFBizがビルド済であれば、次のコマンドでデータベースをクリアします。

  ant clean-data

5.次のコマンドでデータベースを更新します。

  ant run-install

6.OFBizを開始します。

2012年10月25日木曜日

Apache OFBiz について / About



Apache OFBizOpen for Business Project:ビジネス向けオープンプロジェクト)は、ApacheライセンスVer2でライセンスされるのエンタープライズ向けコンピューティングソフトウェアです。OFBizWebアプリケーションやWebサービスを効率的に開発できるフレームワークであると同時に、そのフレームワーク上でERPCRMeコマース、SCMMRPなどの多くの業務アプリケーションがすでに実装されています。少しのカスタマイズでeコマースサイトを立ち上げたりすることができます。建築に例えると、テナントビルを建てたいオーナー向けに、ビルが建っていて、サンプルの店舗があり、その上内装工事の材料が揃っているようなものです。ソフトウェア開発の分野で課題であったプレビルドのフレームワークです。

SpringSeasar 2などのフレームワークによってアプリケーションの開発効率が向上してきましたが、OFBizはさらに上位のアプリケーションレイヤーを含めて開発効率を向上させることが可能です。業務アプリケーションを開発する場合に、ユーザーや顧客の管理、会計システムとの連携など、本来業務以外の部分にも多くの労力、時間を使ってきましたが、OFBizでは本来業務部分の開発に専念することができます。

また、英語、中国語などの多言語、円、ドルなどの多通貨を扱うことができるので、海外向けの通販サイトなども容易に構築することができます。海外向けのシステムを構築の労力を大幅に削減することができます。

要件定義のできないユーザー、開発者のスキルの低下、時間やリソースの制限などシステム開発の分野の環境は厳しくなる一方です。Apache OFBizを試してみませんか。


レポート日本語化 / Using japanese font on report

Apache OFBizは画面や帳票の出力にFOP、FreeMarkerなどいくつかの方法が使われています。現在OFBizで使用されているFOP、FreeMarkerは画面と異なり各国語を切り替えて使用することができません。まず日本語で帳票が作成できる環境を構築します。

1.コマンドラインから下記のコマンドで、FOP用のフォントメトリックスを作成します。

cd c:\ofbiz\framework\base
java -cp ./lib/fop-0.95.jar;./lib/commons/commons-logging-1.1.jar;./lib/commons/commons-io-1.3.1.jar org.apache.fop.fonts.apps.TTFReader /windows/fonts/msmincho.ttc -ttcname "MS Mincho" msmincho.xml
java -cp ./lib/fop-0.95.jar;./lib/commons/commons-logging-1.1.jar;./lib/commons/commons-io-1.3.1.jar org.apache.fop.fonts.apps.TTFReader /windows/fonts/msmincho.ttc -ttcname "MS PMincho" mspmincho.xml
java -cp ./lib/fop-0.95.jar;./lib/commons/commons-logging-1.1.jar;./lib/commons/commons-io-1.3.1.jar org.apache.fop.fonts.apps.TTFReader /windows/fonts/msgothic.ttc -ttcname "MS Gothic" msgothic.xml
java -cp ./lib/fop-0.95.jar;./lib/commons/commons-logging-1.1.jar;./lib/commons/commons-io-1.3.1.jar org.apache.fop.fonts.apps.TTFReader /windows/fonts/msgothic.ttc -ttcname "MS PGothic" mspgothic.xml
java -cp ./lib/fop-0.95.jar;./lib/commons/commons-logging-1.1.jar;./lib/commons/commons-io-1.3.1.jar org.apache.fop.fonts.apps.TTFReader /windows/fonts/msgothic.ttc -ttcname "MS UI Gothic" msuigothic.xml

2.作成されたファイルは、ファイル内のフォント名が文字化けしていますので、任意のテキストエディタでフォント名を変更します。












3.作成したファイルをC:\ofbiz\framework\webapp\configに移動します。

4.FOPの設定ファイルに、作成したフォントメトリックスを指定します。任意のテキストエディタを使用して、C:\ofbiz\framework\webapp\config\fop.xconfファイルを編集します。次の行を追加します。

<font metrics-url="msgothic.xml" embed-url="C:\WINDOWS\Fonts\MSGOTHIC.TTC" kerning="yes">
            <font-triplet name="MS Gothic" style="normal" weight="normal"/>
            <font-triplet name="MS Gothic" style="normal" weight="bold"/>
            <font-triplet name="MS Gothic" style="italic" weight="normal"/>
            <font-triplet name="MS Gothic" style="italic" weight="bold"/>
        </font>
        <font metrics-url="mspgothic.xml" embed-url="C:\WINDOWS\Fonts\MSGOTHIC.TTC" kerning="yes">
            <font-triplet name="MS PGothic" style="normal" weight="normal"/>
            <font-triplet name="MS PGothic" style="normal" weight="bold"/>
            <font-triplet name="MS PGothic" style="italic" weight="normal"/>
            <font-triplet name="MS PGothic" style="italic" weight="bold"/>
        </font>
        <font metrics-url="msuigothic.xml" embed-url="C:\WINDOWS\Fonts\MSGOTHIC.TTC" kerning="yes">
            <font-triplet name="MS UI Gothic" style="normal" weight="normal"/>
            <font-triplet name="MS UI Gothic" style="normal" weight="bold"/>
            <font-triplet name="MS UI Gothic" style="italic" weight="normal"/>
            <font-triplet name="MS UI Gothic" style="italic" weight="bold"/>
        </font>
        <font metrics-url="msmincho.xml" embed-url="C:\WINDOWS\Fonts\MSMINCHO.TTC" kerning="yes">
            <font-triplet name="MS Mincho" style="normal" weight="normal"/>
            <font-triplet name="MS Mincho" style="normal" weight="bold"/>
            <font-triplet name="MS Mincho" style="italic" weight="normal"/>
            <font-triplet name="MS Mincho" style="italic" weight="bold"/>
        </font>
        <font metrics-url="mspmincho.xml" embed-url="C:\WINDOWS\Fonts\MSMINCHO.TTC" kerning="yes">
            <font-triplet name="MS PMincho" style="normal" weight="normal"/>
            <font-triplet name="MS PMincho" style="normal" weight="bold"/>
            <font-triplet name="MS PMincho" style="italic" weight="normal"/>
            <font-triplet name="MS PMincho" style="italic" weight="bold"/>
        </font>
      </fonts>

5.共通で使用されるフォント指定部分を編集します。Arialフォントを指定している箇所が2か所あるので、それぞれMS UI Gothicに変更します。C:\ofbiz\framework\common\widget\CommonScreens.xml

                <!--<set field="defaultFontFamily" value="Arial"/>-->
                <set field="defaultFontFamily" value="MS UI Gothic"/>

6.画面、帳票、メールのテンプレートがそれぞれのアプリケーション内にありますので、フォントを指定している箇所を変更します。

7.では、PDFを表示してみましょう。Apache OFBizを起動して、業務>売掛(AR)>請求書に移動します。




2012/10/27 追記
次のファイルでHelveticaフォントが指定されています

applications\accounting\webapp\accounting\invoice\PrintInvoices.fo.ftl
applications\accounting\webapp\accounting\reports\AcctgTransEntriesSearchResult.fo.ftl
applications\accounting\webapp\accounting\reports\AcctgTransSearchResult.fo.ftl
applications\accounting\webapp\accounting\reports\ChartOfAccount.fo.ftl
applications\manufacturing\webapp\manufacturing\jobshopmgt\CuttingListReport.fo.ftl
applications\manufacturing\webapp\manufacturing\reports\ShipmentLabel.fo.ftl
applications\manufacturing\webapp\manufacturing\reports\ShipmentPlanStockReport.fo.ftl
applications\manufacturing\webapp\manufacturing\reports\ShipmentWorkEffortTasks.fo.ftl
applications\order\webapp\ordermgr\reports\OrderPurchaseReportPayment.fo.ftl
applications\order\webapp\ordermgr\reports\OrderPurchaseReportProduct.fo.ftl
applications\order\webapp\ordermgr\reports\PurchasesByOrganizationReport.fo.ftl
applications\order\webapp\ordermgr\reports\SalesByStoreReport.fo.ftl
applications\product\webapp\catalog\product\ProductBarCode.fo.ftl
applications\product\webapp\facility\facility\NotReadyToPick.fo.ftl
applications\product\webapp\facility\facility\Picklist.fo.ftl
applications\product\webapp\facility\facility\PrintPickSheets.fo.ftl
applications\product\webapp\facility\shipment\ShipmentBarCode.fo.ftl



2012年10月24日水曜日

リソース日本語化 / Japanese resources

1.ここから日本語リソースをダウンロードします。
http://sourceforge.jp/projects/ofbiz-jp/downloads/57177/ofbiz_ja_resources_v0_1.zip/

2.ダウンロードしたzipファイルを展開するとofbiz_resourcesフォルダが作成されます。

3.展開されたフォルダの中身を、OFBizホームに上書きします。
  例えばOFBizをC:\ofbizにインストールしていたとしたら、ofbiz_resourcesフォルダの中身をC:\ofbizに上書きでコピーします。

4.OFBizを起動すると、日本語で表示されるはずです。
http://localhost:8080/catalog


Apache OFBiz インストール / Install



  • Java 1.6 SDKが必要です。インストールされていない場合は、Javaのサイトからダウンロードしてインストールしてください。JREではなくSDKが必要です。インストール後、環境変数JAVA_HOMEを設定します。
  • ダウンロードサイトからApache OFBiz 11.04.01をダウンロードします。 
  • あるいはダウンロードサイトからApache OFBiz 11.04.01-J001をダウンロードします(日本語化済)。 

  • zipファイルを新しいディレクトリに解凍します。

以下はC:\ofbizに展開される前提で話を進めます。

  •  コマンドラインで下記のコマンドを実行してシステムを構築します。

cd C:\ofbiz
ant run-install run

12.04からは
ant load-demo start

  • ブラウザで、http://localhost:8080/catalogを表示し、ユーザー名”admin”、パスワード”ofbiz”でログインします。

2012/10/24 created
2013/1/1 updated
2013/5/4 updated