Variable properties with JRapid

From JRapid

Jump to: navigation, search

There are several occasions when it is necessary to include variable properties as part of an entity. This is useful since it provides the user with the possibility to define the names of the properties and how to validate the value entered for those properties. Modeling this using JRapid requires you to define just to extra entities and use the foreach element.

For example, we may wish to offer the end user the possibility to define extra properties that they find important to store along the standard ones a Company should have.

<entity name="Company" label="Company" menu="Company">
   <property name="name" label="Name" display="primary" />
   <property name="phoneNumber" label="Phone" />
   <property name="webSite" label="Web Site" />
   <property name="otherProperties" label="Other properties"
         labelposition="fieldset" entity="CompanyPropertyValue" collection="set"
         embedded="inline" childproperty="company">
      <foreach select="CompanyProperty:findAll()" setproperty="property" />
   </property>
</entity>

<entity name="CompanyPropertyValue">
   <property name="company" entity="Company" />
   <property name="property" label="Property" entity="CompanyProperty" fixed="fixed" 
      display="primary" gridheader="true" />
   <property name="value" label="Value" display="primary" gridvalue="true" />
</entity>

<entity name="CompanyProperty" label="Property" menu="Company">
   <property name="name" label="Property" display="primary" />
   <property name="validateInteger" label="Validate integer" type="boolean" />
   <property name="validateDouble" label="Validate double" type="boolean" />
</entity>

The collection otherProperties is filled with one CompanyPropertyValue instance for each CompanyProperty the user creates. Every time the Company form is shown for a given company, the collection adds any new CompanyProperty the user has created.

File:variable_properties.png

See also

Personal tools