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

2012年12月9日日曜日

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月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.