Defaultset param

From JRapid

Jump to: navigation, search

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

Usage:

   <defaultset name=NAME>
            <param entity|value=ENTITY|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));
    
      ...  
}