Param (element child of defaultset)

From JRapid

Jump to: navigation, search

Defaultsets can specify fixed values for the entity's properties or either receive parameters for dynamic initialization of properties.

Usage

<defaultset name=NAME>
   <param 
       entity = ENTITY
       value = VALUE
       name = PARAM_NAME
    />
   <default name = NAME value = PARAM_NAME />
</defaultset>

Example

  • Passing a param to a defaultset:
<entity label="Discard" name="Discard" transient="transient">
   ...
   <defaultset name="defaultForOpportunity">
            <param entity="Opportunity" name="opportunityParam"/>
            <default name="opportunity" value="opportunityParam"/>
            <default name="comments" value="'Write a comment here...'"/>
   </defaultset>
   ...
</entity>

Generated java code:

public Discard findDefaultForOpportunity(String opportunityParamId) throws ELException {
        // step 1: find params
      Opportunity opportunityParam = Opportunity.DAO().findById(opportunityParamId);
      
      ...

      Discard obj = new Discard();
      obj.setOpportunity((Opportunity)el.evaluate("${opportunityParam}", Opportunity.class,
      evr, fm));

      obj.setComments((String)el.evaluate("${'Write a comment here...'}", String.class, evr,
      fm));
    
      ...  
}

See also

Personal tools