Subsetparams (attribute of property)

From JRapid

Jump to: navigation, search

subsetparams is an attribute of property.


Contents

Description

The subsetsetparams attribute specifies the parameters to be passed to the subset element that the property uses. The parameters are FPath expressions. If more than one parameter is used, each expression is separated from the other using a semicolon.

Usage

<property 
   ...
   entity = ENTITY_NAME
   subset = SUBSET_NAME
   subsetparams = SEMICOLON_SEPARATED_FPATH
/>

Example

In the following example a Seller's form displays an embeddedlisting of Companies.

Subset example

The companies displayed by this listing are only the ones which fulfils the "forSeller" subset's conditions and restrictions, these are, the companies in which the seller is the "responsable" or the ones in which he has an Opportunity.

<subset name="forSeller">
            <param entity="Seller" name="sellerParam"/>
            <or>
                <condition field="responsable" value="seller"/>
                <restriction expr="exists (select opp from Opportunity as opp where opp.company.id=me.id and opp.seller.id=?)">
                    <param value="sellerParam.id"/>
                </restriction>
            </or>
<subset>

The definition of the embeddedlisting is the following:

<embeddedlisting entity="Company" listing="companiesListing" label="Companies" name="companies"   subset="forSeller" subsetparams="."/>

As said above, the "subsetparams" attribute is an FPath expression. JRapid defines the '.' character as the context Entity in which the user is placed and it resolves it as '/@id"' XPath expression which refers to the "id" attribute of the entity.

In this example the Seller's "id" attribute is being passed to the subset.

That id is passed to the generated service method in the CompanyServicesAbstract class for that subset which fetches the corresponding Seller for that id and then executes the corresponding HQL query for fetching the companies.

public Collection<Company> findSubsetForSellerInternal(String sellerId, String storedFilterName, String page, String
 pattern, String order, List<Restriction> otherRestrictions, int pageSize, String hints) throws ELException {
		// step 1: find params
		Seller seller = Seller.DAO().findById(sellerId);
                 ...
}

See also

Personal tools