Tutorials > Management Center > Add a Recipes tool to the Management Center

< Previous | Next >


Define search

As part of creating a custom tool for the Management Center, you define an OpenLaszlo library class for each search definition.

As part of creating a custom tool for the Management Center, you define search definitions for each search type.

This task file provides the generic steps for defining a search definition. For more information about search definitions before you start to define a search definition, see wcfSearchDefinition.


Procedure

  1. Complete one of the following steps:

    • In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > src > lzx > mycompany > recipe.

    • In the Enterprise Explorer view, expand LOBTools > WebContent > config > mycompany > recipe.

  2. Create a new directory named searchDefinitions, if it does not exist.

  3. Right-click the searchDefinitions folder and select Import. Expand General and select File system.

  4. Click Next, then click Browse and navigate to:

    Option Description
    TutorialSource\LOBTools\WebContent\WEB-INF\src\lzx\mycompany\recipe\searchDefinitions, where TutorialSource is the location where you unzipped the Tutorial sample source code

    1. Select the FindRecipesSearchDefinition.lzx file.

    2. Click Finish to import the file.
    TutorialSource\LOBTools\WebContent\config\mycompany\recipe\searchDefinitions, where TutorialSource is the location where you unzipped the Tutorial sample source code

    1. Select the FindRecipesSearchDefinition.def file.

    2. Click Finish to import the file.

  5. Open one of the following files and examine the contents:

    • FindRecipesSearchDefinition.lzx (search class file)

    • FindRecipesSearchDefinition.def (search definition file)

    Option Description
    FindRecipesSearchDefinition.lzx The following code sample shows two search classes, one for the Recipe object and the other for the Recipe Collection, defined within a search class file.

    <library>    
           
    <!-- Search for Recipe -->
             1 
    <class name="recFindRecipesSearchDefinition"  extends="wcfSearchDefinition" 
                             2  searchType="FindRecipes" 
                            displayName="Recipes" 
                            isDefault="true" 
                             3  listClass="recRecipeSearchGrid">
                   
    <wcfSearchService name="FindRecipes" url="/cmc/FindRecipes">
                           
    <wcfServiceParam name="storeId"/>                       
                   
    </wcfSearchService>
           
    </class>
           
    <!-- Search for Recipe Collection -->
           
    <class name="recFindRecipeCollectionsSearchDefinition"  extends="wcfSearchDefinition" 
                            searchType="FindRecipeCollections" 
                            displayName="Recipe Collections" 
                            isDefault="false" 
                            listClass="recCollectionGrid">
                     4 
    <wcfSearchService name="FindRecipeCollections" url="/cmc/FindRecipeCollections">
                           
    <wcfServiceParam name="storeId"/>                       
                   
    </wcfSearchService>
           
    </class>  
    </library>
    

     1  recFindRecipesSearchDefinition

    Used to define the search on recipes.

     2  searchType

    Must be consistent with the searchType property of the corresponding primary object definition.

     3  listClass

    Sets the search result list grid.

     4  wcfSearchService

    Sets the search service to be called to run the query, which has already been defined. The query is mapped to the URL "/cmc/FindRecipes" in the lesson: Retrieving Management Center objects by transforming Nouns into XML.
    FindRecipesSearchDefinition.def The following code sample shows two search definitions, one for the Recipe object and the other for the Recipe Collection, defined within a search definition file.

    <Definitions>
        <!-- Search for Recipe -->
     1 
    <SearchDefinition definitionName="FindRecipes"
                 2  searchType="FindRecipes"
                displayName="Recipes"
                isDefault="true"
                 3  listDefinitionName="recRecipeSearchGrid">
             4 
    <SearchService name="FindRecipes" url="/cmc/FindRecipes">
                <ServiceParam name="storeId"/>
            </SearchService>
        </SearchDefinition>
        <!-- Search for Recipe Collection -->
        <SearchDefinition definitionName="FindRecipeCollections"
                searchType="FindRecipeCollections"
                displayName="Recipe Collections"
                isDefault="false"
                listDefinitionName="recCollectionGrid">
            <wcfSearchService name="FindRecipeCollections"
                    url="/cmc/FindRecipeCollections">
                <ServiceParam name="storeId"/>                       
            </SearchService>
        </SearchDefinition>  
    </Definitions>
    

     1  FindRecipes

    Used to define the search on recipes.

     2  searchType

    Must be consistent with the searchType attribute of the corresponding primary object definition.

     3  listDefinitionName

    Sets the search results list grid.

     4  SearchService

    Sets the search service to be called to run the query, which has already been defined. The query is mapped to the URL "/cmc/FindRecipes" in the lesson: Retrieving Management Center objects by transforming Nouns into XML.

  6. After defining the search definition, configure the search type to the primary object.

    1. Complete one of the following steps:

      1. In the Enterprise Explorer view, expand LOBTools > WebContent > WEB-INF > src > lzx > mycompany > recipe > objectDefinitions.

      2. In the Enterprise Explorer view, expand LOBTools > WebContent > config > mycompany > recipe > objectDefinitions.

    2. Open the primary object definition file:

      • RecipePrimaryObjectDefinition.lzx

      • RecipePrimaryObjectDefinition.def

    3. Find the Recipe and RecipeCollection object definitions and the searchType attribute for these object definitions. The following code samples show the searchType attribute for the Recipe and RecipeCollection object definitions, in boldface.

      <class name="recRecipePrimaryObjectDefinition" extends="wcfPrimaryObjectDefinition"
                      objectType="Recipe"
                      creatable="true"
                      displayName="${extRecipeResources.recipe_DisplayName.string}"
                      displayNameProperty="name"
                      idProperty="recipeId"
                      searchType="FindRecipes"
                      newDisplayName="${extRecipeResources.recipe_NewDisplayName.string}"
                      propertiesClass="recRecipeProperties"
                      icon="productIcon"
                      headerIcon="productHeaderIcon"  
                      >                    
              ... ...
              ... ...
      </class>
      
      <class name="recRecipeCollectionPrimaryObjectDefinition" extends="wcfPrimaryObjectDefinition"
                      creatable="true"
                      idProperty="collectionId"
                      objectType="RecipeCollection"
                      searchType="FindRecipeCollections" 
                      displayName="${extRecipeResources.recipeCollection_DisplayName.string}"
                      displayNameProperty="collectionName"  
                      newDisplayName="${extRecipeResources.recipeCollection_NewDisplayName.string}"
                      propertiesClass="recCollectionProperties" 
                      >                            
              ... ...
              ... ...
      </class>
      


      <PrimaryObjectDefinition definitionName="Recipe"
              objectType="Recipe"
              creatable="true"
              displayName="${extRecipeResources.recipe_DisplayName}"
              displayNameProperty="name"
              idProperty="recipeId"
              searchType="FindRecipes"
              newDisplayName="${extRecipeResources.recipe_NewDisplayName}"
              propertiesDefinitionName="recRecipeProperties"
              icon="productIcon"
              headerIcon="productHeaderIcon">                    
          ... ...
          ... ...
      </PrimaryObjectDefinition>
      
      <PrimaryObjectDefinition definitionName="RecipeCollection"
              creatable="true"
              idProperty="collectionId"
              objectType="RecipeCollection"
              searchType="FindRecipeCollections"
              displayName="${extRecipeResources.recipeCollection_DisplayName}"
              displayNameProperty="collectionName"
              newDisplayName="${extRecipeResources.recipeCollection_NewDisplayName}"
              propertiesDefinitionname="recCollectionProperties">                            
          ... ...
          ... ...
      </PrimaryObjectDefinition>
      

  7. Right-click the LOBTools project and select Build OpenLaszlo Project.

< Previous | Next >


+

Search Tips   |   Advanced Search