Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    6.1p: New velocity default variable $tableName needed

    Hi Isomorphic,

    could you add support for a new velocity variable $tableName here?

    My use case is the following:
    For i18n reasons I don't use anymore something like this:
    Code:
            <field [B]foreignKey="T_LEADTEMPERATURE.ID"[/B] name="MD_LEADTEMPERATURE_ID" type="integer" displayField="MD_LEADTEMPERATURE_NAME" />
            <field name="MD_LEADTEMPERATURE_NAME" [B]includeFrom="T_LEADTEMPERATURE.NAME" [/B]/>
    This worked perfectly, but you can't have translated names that way.

    So now I'm using a big lookup-table, accessed via PL/SQL function and cached in memory in the DB with a customSelectExpression:
    Code:
            <field name="MD_LEADTEMPERATURE_ID" type="integer" displayField="MD_LEADTEMPERATURE_NAME" />
            <field name="MD_LEADTEMPERATURE_NAME" length="60" type="text" escapeHTML="true" hidden="true" [B]customSelectExpression="translation.gettranslation(V_LEAD_MATCHED_UNDISMISSED.TENANT_ID, 'T_LEADTEMPERATURE', MD_LEADTEMPERATURE_ID, 'NAME', $userLanguage)[/B]" />
    This is working fine.
    But if I now have a DataSource that inheritsFrom it's fields from this DataSource, I need to redefine the field and just change the bold part above with the name of the inheriting DataSource (because otherwise I'd get an SQL error).
    This would be solved if I had $tableName available as velocity variable, as this would translate to the correct table name in both cases without the need to redefine. I also can't leave the "TABLENAME." away, as the column name itself is not unique because of joins and this would lead to SQL ambiguity problems.

    Another valuable addition (I don't need it now, but I'm pretty sure that I can use it eventually) is to have the fieldName / nativeName available here, like you already do for viewRequires:
    In addition to the normal context variables available to Velocity expressions in Smart GWT, expressions you write for field-level requires clauses - viewRequires, editRequires, initRequires and updateRequires - can reference two additional variables: $fieldName and $dsName.
    For the tablename I already tried working with the DataSource from $dsRequest, but unfortunately DataSource does not have a getTableName().

    Does this enhancement make sense to you?

    Thank you & Best regards
    Blama

    #2
    We've added two new server-side APIs: DataSource.getTableName() and DSField.getNativeName() in both the 12.1 and 12.0 branches, but we don't plan to make these top-level Velocity variables as their usage is relatively obscure and there are already a lot of variables available.

    Regards
    Isomorphic Software

    Comment


      #3
      Hi Isomorphic,

      thanks a lot. DataSource.getTableName() works for me. I'll test it after switching to 12.0.

      Best regards
      Blama

      Comment

      Working...
      X