Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Win XP, Tomcat 5.5.15 Liferay 3.6.1,
    • Similar Issues:
      Show 5 results 

      Description

      Any application or portlet dealing with currencies should really use the java BigDecimal class. It would be nice and fairly trivial for the ServiceBuilder to support this.

      I've just done a quick and dirty test and all I needed to do was use type="java.math.BigDecimal" in my service.xml and then modify the ext-hbm.xml to have type="big_decimal" in the appropriate place
      (This was with postgresql).

      Surely there are other people out there working with currencies within the liferay system that could
      benefit as well.

      Background: I'm writing a very specialised shopping basket system which is very loosely based on the
      Liferay's shopping basket and I've just realised that I shouldn't be using double values and that
      it might not be very appropriate for Liferay's shopping basket portlet either (I haven't analysed in detail
      how it does its rounding).

      1. service_builder_ftl_overrides.tar.gz
        21 kB
        Reinaldo Silva
      2. ServiceBuilder.java.patch
        2 kB
        Reinaldo Silva

        Activity

        Hide
        Brian Chan added a comment -

        Interesting. Will look into it.

        Show
        Brian Chan added a comment - Interesting. Will look into it.
        Hide
        Marcel Jansen added a comment -

        FYI

        It definitely works (combination of "java.math.BigDecimal" and "big_decimal"). Use of
        org.apache.commons.validator.routines.CurrencyValidator has also been very useful.

        Show
        Marcel Jansen added a comment - FYI It definitely works (combination of "java.math.BigDecimal" and "big_decimal"). Use of org.apache.commons.validator.routines.CurrencyValidator has also been very useful.
        Hide
        Reinaldo Silva added a comment -

        Patch and FTL service builder templates overrides to make it work on:

        • Liferay 6.1.X (rev. 65274)
        • PostgreSQL 8.4 (should work on Mysql too, but not tested)

        Also the following args must be added to "build-common-plugin.xml" SDK:

        <target name="build-service">
        <java
        classname="com.liferay.portal.tools.servicebuilder.ServiceBuilder"
        classpathref="service.classpath"
        >
        <arg value="-Dexternal-properties=com/liferay/portal/tools/dependencies/portal-tools.properties" />
        ...
        <!-- HERE YOUR OVERRIDES -->
        <arg value="-Dservice.tpl.hbm_xml=<your_plugin_package_path>/hbm_xml.ftl" />
        <arg value="-Dservice.tpl.persistence_impl=<your_plugin_package_path>/persistence_impl.ftl" />
        <arg value="-Dservice.tpl.model=<your_plugin_package_path>/model.ftl" />
        <arg value="-Dservice.tpl.model_impl=<your_plugin_package_path>/model_impl.ftl" />
        <arg value="-Dservice.tpl.model_clp=<your_plugin_package_path>/model_clp.ftl" />
        <arg value="-Dservice.tpl.service_clp_serializer=<your_plugin_package_path>/service_clp_serializer.ftl" />
        </java>
        ...
        </target>

        The database used is NUMERIC and it can be NULL, circunventing the NULL to ZERO default behavior of Liferay numeric fields.

        Only issue is that you must explicitly declare the "type='text'" attribute on "<aui:input />" elements to show properly when the field has no value, besides that all work properly.

        Also, not tested on special columns (PKs, FKs).

        Show
        Reinaldo Silva added a comment - Patch and FTL service builder templates overrides to make it work on: Liferay 6.1.X (rev. 65274) PostgreSQL 8.4 (should work on Mysql too, but not tested) Also the following args must be added to "build-common-plugin.xml" SDK: <target name="build-service"> <java classname="com.liferay.portal.tools.servicebuilder.ServiceBuilder" classpathref="service.classpath" > <arg value="-Dexternal-properties=com/liferay/portal/tools/dependencies/portal-tools.properties" /> ... <!-- HERE YOUR OVERRIDES --> <arg value="-Dservice.tpl.hbm_xml=<your_plugin_package_path>/hbm_xml.ftl" /> <arg value="-Dservice.tpl.persistence_impl=<your_plugin_package_path>/persistence_impl.ftl" /> <arg value="-Dservice.tpl.model=<your_plugin_package_path>/model.ftl" /> <arg value="-Dservice.tpl.model_impl=<your_plugin_package_path>/model_impl.ftl" /> <arg value="-Dservice.tpl.model_clp=<your_plugin_package_path>/model_clp.ftl" /> <arg value="-Dservice.tpl.service_clp_serializer=<your_plugin_package_path>/service_clp_serializer.ftl" /> </java> ... </target> The database used is NUMERIC and it can be NULL, circunventing the NULL to ZERO default behavior of Liferay numeric fields. Only issue is that you must explicitly declare the "type='text'" attribute on "<aui:input />" elements to show properly when the field has no value, besides that all work properly. Also, not tested on special columns (PKs, FKs).
        Hide
        Jonas Yuan added a comment -

        A proposal was addressed at LPS-15233

        Show
        Jonas Yuan added a comment - A proposal was addressed at LPS-15233
        Hide
        Robert Seedorff added a comment -

        Would be realy great to have this feature for dealing with currency values.

        Show
        Robert Seedorff added a comment - Would be realy great to have this feature for dealing with currency values.

          People

          • Assignee:
            Brian Chan
            Reporter:
            Marcel Jansen
          • Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:

              Development

                Structure Helper Panel