Server-side conditionals

From JRapid

(Redirected from Disabledcondition (element))
Jump to: navigation, search

Server-side conditionals expressions validate against data stored in the database (client-side conditionals do it against data inside the form).

Important: Expressions for this type of conditionals are written in EL language and params
in FPath. See the examples below.

Usage

            <property name = NAME label = LABEL>
                <displaycondition expr = EL>
                    <param entity = ENTITY name = NAME value = VALUE/>
                </displaycondition>

                <visiblecondition expr = EL>
                    <param entity = ENTITY name = NAME value = VALUE/>
                </visiblecondition>

                <readonlycondition expr =EL>
                    <param entity = ENTITY name = NAME value = VALUE/>
                </readonlycondition>

                <disabledcondition expr = EL>
                    <param entity = ENTITY name = NAME value = VALUE/>
                </disabledcondition>
            </property>
  • "expr" = a boolean EL expression.
  • "param" = a paramter for the EL expression.
  • "value" = the value for the condition's expression written in FPath

Example

Given the following Company entity:

 <entity name=company label="Company>
     ...
     <property label="Status" name="status" entity="CompanyStatus" />
     <property label="Comments" name="comments" type="text"/>
     ...
 </entity>
 <entity label="CompanyStatus" name="CompanyStatus">
     <property display="primary" label="Name" name="name"/>
 </entity>
  • Example for displaycondition and visiblecondition:

Suppose we want to hide the "comments" field when a company's status is "closed". This can be done either with displaycondition or visiblecondition, the diference is that visiblecondition will save the space of the hidden property and displaycondition no. (see css-display:none and css-visible).

 <property label="Comments" labelposition="top" name="comments" type="text">
      <displaycondition expr="statusParam.name != 'Closed'">
              <param entity="CompanyStatus" name="statusParam" value="status"/>
      </displaycondition>
 </property>

or

 <property label="Comments" labelposition="top" name="comments" type="text">
      <visiblecondition expr="statusParam.name != 'Closed'">
              <param entity="CompanyStatus" name="statusParam" value="status"/>
      </visiblecondition>
 </property>
  • Example for disabledcondition and readonlyconditions:

In the previous example we wanted to hide the "comments" property, but we could have disabled the property or mark it as readonly for users to only see the comments but no editing the.

We could have written:

 <property label="Comments" labelposition="top" name="comments" type="text">
      <disabledcondition expr="statusParam.name != 'Closed'">
              <param entity="CompanyStatus" name="statusParam" value="status"/>
      </disabledcondition >
 </property>

to disable de property, or

 <property label="Comments" labelposition="top" name="comments" type="text">
      <readonlydcondition expr="statusParam.name != 'Closed'">
              <param entity="CompanyStatus" name="statusParam" value="status"/>
      </readonlydcondition >
 </property>

A "statusParam" is passed to the expression as we need to fetch first the "status" value inside the form using an FPath expression for the EL expression to operate with it.

This example can be also resolved using client-side conditionals as there is no need to fetch any data from the databse.

See also

Personal tools