...
- Make note of the Active Layer from the Weave client for which you want to define a Search.
- Open your
entity.xml
and search for the Active Layer name. It will appear as thelabel
in anentity
XML Tag. Make note of the value of theid
XML Attribute and search for it within the same file. It will appear in amapping
XML Tag. Make a note of the values of thespatialengine
,table
andkey
XML Tags.
- Ensure the Search panel is visible somewhere in the Weave application by adding the
<view id='com.cohga.html.client.main.searchView'>
item to theclient_main.xml
file - this . This will most likely have been done during your Weave installation.
- Also during During your Weave installation, some searches will may have been configured in the
search.xml
. In order to get the correct structure of the search XML, the easiest thing to do is to copy an existingsearch:attribute
XML Element, and then edit it. Modify the XML Attribute values so that they reflect your database and the fields you want to search. Keep in mind that databases have different rules regarding the case of field names (PostgreSQL uses lower case, Oracle uses upper case, SQL Server uses mixed case, etc.).
Start with a simple search where the input is typed in by the Weave user as shown in the example below.
Code Block <search:attribute id='counciltrees' entity='counciltrees' displayname='Council Trees by Details' datasource='gis' table='mann.counciltrees' key='fid'> <search:parameter id='treenum' promptText='Tree Number' dataType='float' alignment='right' helptext='Type in the tree number' column='tree_no' /> </search:attribute>
The resulting search in Weave will appear as shown below:If you want to have a drop-down list as part of your Search, the
controlType
XML Attribute of "listbox
" needs to be included as shown below. The content of the list is specified by thedataset
XML Attribute (which will be created in the next step).Code Block <search:attribute id='counciltrees' entity='counciltrees' displayname='Council Trees by Details' datasource='gis' table='mann.counciltrees' key='fid'> <search:parameter id='treenum' promptText='Tree Number' dataType='float' alignment='right' helptext='Type in the tree number' column='tree_no' /> <search:parameter id='treespecies' label='Species' controlType='listbox' column='species' dataset='specieslist' labelcolumn='label' valuecolumn='value' /> </search:attribute>
The above step adds a drop-down list to the Search panel but the list won't have any values in it. To populate the list, a Data Definition needs to be created in the
data.xml
file. The Data Definition specifies which values will be in the list.Code Block <data:datadefinition id='specieslist> <datasourcedataconnection datasource='gis' table='counciltrees' prefix='DISTINCT'> <parameter type='string' name='label' label='Label' column='species' /> <parameter type='string' name='value' label='Value' column='species' /> </datasourcedataconnection> </data:datadefinition>
- You will need to refresh your Weave browser to see the new list in the Search panel.
- The Config Tool in the Administration Tool reports on all the valid Data Definitions created so you can use it to find and view the definitions of all the Data Definitions. The Data Definition you created for your drop-down list should be shown, together with others used in Data Grids. Press the Open button to view the XML for it.
- In some cases, the values in a list may appear in the incorrect order, e.g. they are stored as a string but they are quantitative rather than qualitative, as shown in the example below.
In order to get the list items displayed in a different order, you can set up this search parameter as a value list. This requires some configuration the configuration of the XML file but it will produce a better result for the Weave user and is a good alternative to an automatic list if the number of possible values is small.
Add the following code to your
search.xml
file.Code Block <search:parameter id="treeheight" label="Height" controlType="listbox" column="height"> <list label="0-2m" value="0-2m"/> <list label="2-5m" value="2-5m"/> <list label="5-10m" value="5-10m"/> <list label="10-15m" value="10-15m"/> <list label="15+m" value="15+m"/> </search:parameter>
The resulting list in Weave will appear as shown below:
You could also use radio buttons to get the listing in the correct order. This works for a short list and five items is probably the maximum number of items you'd want to use for this type of list.
Code Block <search:parameter id="treeheight" label="Height" controlType="radiobutton" column="height"> <list label="0-2m" value="0-2m"/> <list label="2-5m" value="2-5m"/> <list label="5-10m" value="5-10m"/> <list label="10-15m" value="10-15m"/> <list label="15+m" value="15+m"/> </search:parameter>
The resulting list in Weave will appear as shown below:
...