Defaultset (element)

From JRapid

Jump to: navigation, search

defaultset is an element child of entity.



A defaultset assigns a set of default values to entity properties. Values can be fixed or parameterized.

Defaultsets may be used for opening entity forms for new records with preset values. These values can be fixed values or they can be dynamically calculated based on parameters.

Defaulsets can be specified for forms and listing included in panels, relatedentity type actions and embedded listings.

Using a defaultset overrides any default attribute specified for a property.

For each defaulset defined, a new service is generated.

A defaultset has a name by which it can be referenced. The unique attribute indicates that a defaultset is unique, meaning that the default values are only set the first time and from then on the form is completed with the previously inserted values. This attribute should be used with key elements as children. The param and default elements are defined as children of the defaulset.


<entity ... >
            name = NAME
            unique = UNIQUE
            (restrict?, param*, (default|key)*, (foreach*))>


  • Defaulset in embeddedlisting

You can specify a defaultset for an embeddedlisting so that when a new record is added through that embedded listing, the properties are initialized as needed. For example, take the case where a Company entity embeds an Employee list. The list is filtered so that it only shows the employees that work at the company by using a subset. And it specifies a defaultset that receives a company as parameter and sets the corresponding property on the Employee entity's form. As an extra feature, the loadDate property of the employee entity is set with the current date by using the "now" expression.

    <entity label="Company" menu="Menu" name="Company" order="name">
        <property display="primary" label="Name" name="name"/>
        <embeddedlisting defaultset="forCompanyDef" defaultsetparams="." entity="Employee"
        label="Employees" listing="forCompanyListing" name="employees" subset="forCompany" subsetparams="."/>

    <entity label="Employee" menu="Menu" name="Employee" order="lastName, firstName,">
        <listing displayproperties="firstName,lastName" name="forCompanyListing" subset="forCompany"/>
        <defaultset name="forCompanyDef">
            <param entity="Company" name="companyParam"/>
            <default name="company" value="companyParam"/>
            <default name="loadDate" value="now"/>
        <subset name="forCompany" order="lastName, firstName,">
            <param entity="Company" name="companyParam"/>
            <condition field="company" value="companyParam"/>
        <property display="primary" label="First Name" name="firstName"/>
        <property display="primary" label="Last Name" name="lastName"/>
        <property display="secondary" entity="Company" label="Company" name="company"/>
        <property name="loadDate" label="Load Date" type="date" />

The resulting company form with embeddedlisting and a new employee form with properties set is shown below.

Defaulset used in an embeddedlisting

See also

Personal tools