Defining search
In this lesson, you create a search definition XML file to include the search definitions for each Recipe object type.
Procedure
- In the Enterprise Explorer view, expand .
- Within this directory, create a subdirectory that is named searchDefinitions.
- Right-click the searchDefinitions folder and select Import. Expand General and select File system.
-
Click Next, then click Browse to the following
directory:
TutorialSource\LOBTools\WebContent\WEB-INF\src\xml\mycompany\recipe\searchDefinitions, where TutorialSource is the location where you extracted the Tutorial sample source code
- Select the FindRecipesSearchDefinition.xml search definition files within this directory. Click Finish to import the file.
-
Open the file within your workspace to examine the contents:
The following sample code shows two search definitions within the file, one for the Recipe object and the other for the Recipe Collection.
<Definitions> ... 1<SearchDefinition definitionName="cmc/recipe/FindRecipes" displayName="${ExtRecipeResources.findRecipesSearchDefinition_DisplayName}" isDefault="true" 2listDefinition="cmc/recipe/RecipeSearchGrid" 3
searchType="FindRecipes"
> <dependency localName="ExtRecipeResources" moduleName="cmc/recipe/ExtRecipeResources"/> 4<SearchService name="FindRecipes" url="/cmc/FindRecipes"> <ServiceParam name="storeId"/> </SearchService> </SearchDefinition> <SearchDefinition definitionName="cmc/recipe/FindRecipeCollections" displayName="${ExtRecipeResources.findRecipeCollectionsSearchDefinition_DisplayName}" isDefault="false" listDefinition="cmc/recipe/CollectionGrid"searchType="FindRecipeCollections"
> <dependency localName="ExtRecipeResources" moduleName="cmc/recipe/ExtRecipeResources"/> <SearchService name="FindRecipeCollections" url="/cmc/FindRecipeCollections"> <ServiceParam name="storeId"/> </SearchService> </SearchDefinition> </Definitions>- 1 FindRecipes
- Used to define the search on recipes.
- 2 listDefinitionName
- Sets the search results list grid.
- 3 searchType
- Must be consistent with the
searchType
attribute of the corresponding primary object definition. - 4 SearchService
- Sets the search service to be called to run the query. The query is mapped to the URL "/cmc/FindRecipes" in the lesson: Retrieving Management Center objects by transforming Nouns into XML.
-
After you define the search definition, you need to map the search type to the primary
object.