Naty,
Here is your MiniSearch updated to a Flex Viewer 2.4 actual widget.
Also I forgot to mention in the readme.txt that the widget has to go in the UI section at the top of the config.xml like the NavigationWidget.
Naty,
OK, it's fixed.
Robert u are great!!
When I will have time (I hope soon) I compare the old SearchWidget with the new...so I can see the difference and maybe I will better understand what u did and how it works..thank u sooooo much.
Naty
public function querybmpid(sParam:String):void
{
//hide infowindow if any
hideInfoWindow();
var i:int = 0;
queryLayer = configSearchText.layer;
showMessage(queryLayer.name, false);
if (queryLayer && !queryLayer.loaded)
{
queryLayer.addEventListener(LayerEvent.LOAD, queryLayer_loadHandler);
function queryLayer_loadHandler(event:LayerEvent):void
{
querybmpid(sParam)
}
return;
}
queryExpr = configSearchText.expr;
queryFields = configSearchText.fields;
queryTitleField = configSearchText.titlefield;
queryLinkField = configSearchText.linkfield;
if (queryLayer && sParam)
{
var query:Query = new Query();
var expr:String = queryExpr.replace(/\[value\]/g, sParam);
query.where = expr;
query.outSpatialReference = map.spatialReference;
queryLayer.queryFeatures(query, new AsyncResponder(onResult, onFault, queryFields));
showMessage(loadingLabel, true);
showStateResults();
function onResult(featureSet:FeatureSet, token:XMLList = null):void
{
try
{
searchResultAC = createSearchResults(featureSet, token);
// share data
addSharedData(widgetTitle, searchResultAC);
if (featureSet.features.length < 1)
{
showMessage(noResultLabel, false);
}
else
{
showMessage(selectionLabel + " " + featureSet.features.length, false);
var searchResult:SearchResult = searchResultAC[0] as SearchResult;
showHighlight([searchResult]);
}
}
catch (error:Error)
{
showMessage(error.message, false);
}
}
function onFault(info:Object, token:Object = null):void
{
showMessage(info.toString(), false);
}
}
}
Naty,
In your querybmpid function add the red lines below:public function querybmpid(sParam:String):void { //hide infowindow if any hideInfoWindow(); var i:int = 0; queryLayer = configSearchText.layer; showMessage(queryLayer.name, false); if (queryLayer && !queryLayer.loaded) { queryLayer.addEventListener(LayerEvent.LOAD, queryLayer_loadHandler); function queryLayer_loadHandler(event:LayerEvent):void { querybmpid(sParam) } return; } queryExpr = configSearchText.expr; queryFields = configSearchText.fields; queryTitleField = configSearchText.titlefield; queryLinkField = configSearchText.linkfield; if (queryLayer && sParam) { var query:Query = new Query(); var expr:String = queryExpr.replace(/\[value\]/g, sParam); query.where = expr; query.outSpatialReference = map.spatialReference; queryLayer.queryFeatures(query, new AsyncResponder(onResult, onFault, queryFields)); showMessage(loadingLabel, true); showStateResults(); function onResult(featureSet:FeatureSet, token:XMLList = null):void { try { searchResultAC = createSearchResults(featureSet, token); // share data addSharedData(widgetTitle, searchResultAC); if (featureSet.features.length < 1) { showMessage(noResultLabel, false); } else { showMessage(selectionLabel + " " + featureSet.features.length, false); var searchResult:SearchResult = searchResultAC[0] as SearchResult; showHighlight([searchResult]); } } catch (error:Error) { showMessage(error.message, false); } } function onFault(info:Object, token:Object = null):void { showMessage(info.toString(), false); } } }
Naty,
That has never been an option in the search widget only the eSearch widget.
private function execSearch():void
{
if(advancedAutoComplete.selectedItem){
try{
var aaa:String=advancedAutoComplete.selectedItem.@code;
var msArr:ArrayCollection = new ArrayCollection();
msArr.addItem(aaa);
addSharedData("MiniSearch_Search", msArr);
var id:Number = ViewerContainer.getInstance().widgetManager.getWidgetId("Enhanced Search");
var bWidget:IBaseWidget = ViewerContainer.getInstance().widgetManager.getWidget(id, true) as IBaseWidget;
if (bWidget){
var vSW:* = bWidget;
vSW.queryFromURL(aaa,0,0);
}
}catch (error:Error){
AppEvent.showError( error.message );
}
}
}Naty,
Sure the url portion of the search would not use the minisearch at all just the built in capability of the eSearch to query based on the URL. The URL would look like this
index.html?search=1&slayer=0&exprnum=0
you need to look at the documentation that comes with the eSearch to see what each of these are doing.
Here is the code changes you need to use in the MiniSearch to use the eSearch instead:private function execSearch():void { if(advancedAutoComplete.selectedItem){ try{ var aaa:String=advancedAutoComplete.selectedItem.@code; var msArr:ArrayCollection = new ArrayCollection(); msArr.addItem(aaa); addSharedData("MiniSearch_Search", msArr); var id:Number = ViewerContainer.getInstance().widgetManager.getWidgetId("Enhanced Search"); var bWidget:IBaseWidget = ViewerContainer.getInstance().widgetManager.getWidget(id, true) as IBaseWidget; if (bWidget){ var vSW:* = bWidget; vSW.queryFromURL(aaa,0,0); } }catch (error:Error){ AppEvent.showError( error.message ); } } }
And add the same commented areas I had in the original SearchWidget.mxml