Showing posts with label Sorting. Show all posts
Showing posts with label Sorting. Show all posts

DisplayNames, sorting and Grouping- InterMediate II

Display Names using the Resource Bundle (Localising the Labels).

Define resource bundle using following attribute.
    <attribute name="resourceBundle" value="resourceBundleName"/>

ex: <attribute name="resourceBundle" value="my.Resource"/>

Localising the values can be applied at
  • Item-descriptor
  • Property
Labels that can be localised using resource bundle are
  • display-name ( to display-name-resource)
  • description ( to description-resource)
  • category ( to category-resource)
Item-descriptor <item-descriptor name="author" display-name-resource="author" >
<attribute name="resourceBundle" value="my.Resource"/>
.
.
.
</item-descriptor> 


Property
<property name="firstName" column-name="first_name" display-name-resource="firstName" data-type="string"/>
 <attribute name="resourceBundle" value="my.Resource"/>
</property> 

And Resource file would contain following content.
author=Author
firstName=First Name


Grouping Properties and Sorting them in groups.

Properties under each Item-descriptor can be grouped together using "category" attribute at property level.Category attribute can be localised using resource bundle.

<table name="BOOK_MASTER" type="primary" id-column-name="book_id">
        <property name="id" column-name="book_id"/>
        <property name="name" column-name="name" display-name="name" data-type="string" category="basics"/>
        <property name="description" column-name="description" display-name="description" data-type="big string"
category="basics"/>
        <property name="price" column-name="price" display-name="price" data-type="double"
category="additionalInfo"/>
        <property name="pages" column-name="pages" display-name="pages" data-type="int" category="additionalInfo"/>
       <property name="available" column-name="available" display-name="available" data-type="boolean" category="additionalInfo"/>
    </table>


In the above example, properties "name" and "description" are grouped under "Basics" category, and properties "price" , "pages" and "available" are under "AdditionalInfo" category.


Adding resource Bundle to category.
<property name="name" column-name="name" display-name="name" data-type="string" category-resource="basics">
 <attribute name="resourceBundle" value="my.Resource"/>
</property> 


And Resource file contains the value for basics.

To sort the properties under category, use the attribute "propertySortPriority" with value. Depending on the value(-ve to +ve), properties will be sorted. If not provided, will be sorted alphabetically. 

<property name="name" column-name="name" display-name="name" data-type="string" category-resource="basics">




<attribute name="resourceBundle" value="my.Resource"/>
 <attribute name="propertySortPriority" value="0"/>
</property>
 <property name="description" column-name="description" display-name="description" data-type="big string" category-resource="basics">
 <attribute name="resourceBundle" value="my.Resource"/>
  <attribute name="propertySortPriority" value="1"/>
</property>

In above example, property "name" would appear above property "description".

Where are display-names, grouping and sorting comes to help?

Ans: When viewing Items in BCC, ACC.