Subsetparams (attribute of embeddedlisting)

From JRapid

Jump to: navigation, search

The "subsetsetparams" attribute specifies the parameters that are sent to the subset that the element uses. The parameters are FPath expressions.

Usage

 <embeddedlisting name = NAME entity = ENTITY label = LABEL subsetparams = "COLON_SEPARATED_FPATH | '.'">
 
 <property entity = ENTITY_NAME subset = SUBSET_NAME subsetparams = COLON_SEPARATED_FPATH />
 
 <action subset = SUBSET subsetparams = COLON_SEPARATED_PARAMS />

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