Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1033] ListView searchView property throws error if set in XML

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-09-12T13:47:32.000+0000
Affected Version/sAlloy 1.4.0, Alloy 1.3.1
Fix Version/sAlloy 1.5.0
ComponentsXML
Labelsn/a
ReporterTim Poulsen
AssigneeTim Poulsen
Created2014-05-28T18:21:12.000+0000
Updated2014-09-15T08:58:44.000+0000

Description

One option for enabling list view searching is to set the searchView property of the list equal to a reference to the SearchBar component. *Expectation* I should be able to set this property as an attribute of the <ListView> tag in the XML. *Actual* As demonstrated by the attached app, doing so throws this error:
[ERROR] Script Error {
[ERROR]     backtrace = "#0 () at file:///Users/tpoulsen/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/D10A7127-56CA-485E-99C7-FE9A5C9DDD60/ListViewSearch.app/alloy.js:231";
[ERROR]     line = 95;
[ERROR]     message = "Invalid type passed to function";
[ERROR]     nativeLocation = "-[TiUIListView setSearchView_:] (TiUIListView.m:746)";
[ERROR]     nativeReason = "expected: TiUISearchBarProxy or nil, was: String";
[ERROR]     sourceId = 259295456;
[ERROR]     sourceURL = "file:///Users/tpoulsen/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/D10A7127-56CA-485E-99C7-FE9A5C9DDD60/ListViewSearch.app/alloy/controllers/index.js";
[ERROR] } 
*Reason and workaround* The attribute's value is being passed as a string to the ListView component, rather than as a reference to the component with that ID. As a workaround, you can set the searchView property in the controller.

Attachments

FileDateSize
ListViewSearch.zip2014-05-28T18:21:12.000+00005906989

Comments

  1. Tim Poulsen 2014-05-29

    PR: https://github.com/appcelerator/alloy/pull/422 Test app: test/apps/testing/ALOY-1033 Functional test: 1. Run the app (should see no errors in console or app). Tap in the search box and search for items (should work). 2. Edit the app's index.xml to move the within the . Run the app and it should work as before.
  2. Feon Sua Xin Miao 2014-05-30

    Tested Tim's PR, functional tests passed.
  3. Tim Poulsen 2014-05-30

    PR merged
  4. Tim Poulsen 2014-09-12

    This is an SDK issue, not Alloy.
       var win = Ti.UI.createWindow({
           backgroundColor: 'blue',
           fullscreen: false
       });
       
       // Use action bar search view
       var search = Ti.UI.Android.createSearchView({
           hintText: "Table Search",
           top: 0
       });
       
       win.add(search);
       
       var listView = Ti.UI.createListView({
       	searchView: search, /* comment this out & it runs*/
       	top: 40
       });
       var sections = [];
       
       var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits'});
       var fruitDataSet = [
           {properties: { title: 'Apple'}},
           {properties: { title: 'Banana'}},
       ];
       fruitSection.setItems(fruitDataSet);
       sections.push(fruitSection);
       
       var vegSection = Ti.UI.createListSection({ headerTitle: 'Vegetables'});
       var vegDataSet = [
           {properties: { title: 'Carrots'}},
           {properties: { title: 'Potatoes'}},
       ];
       vegSection.setItems(vegDataSet);
       sections.push(vegSection);
       
       listView.sections = sections;
       win.add(listView);
       win.open();
       
    Crashes in the same way.
  5. Feon Sua Xin Miao 2014-09-12

    Master: https://github.com/appcelerator/alloy/pull/554 1_5_X: https://github.com/appcelerator/alloy/pull/555 Update the test app to reflect the platform differences, such that the SearchBar is outside the list for iOS and inside the list for Android.
  6. Tim Poulsen 2014-09-12

    PRs tested and merged
  7. Visalakshi Chidambaram 2014-09-15

    Verified in the following environment : 
 Appcelerator Studio, build: 3.4.0.201409131030 CLI: 3.4.0-rc3 Alloy: 1.5.0-rc2 Code processor: 1.1.1 SDK: 3.4.0.v20140913174915 Mac OSX version 10.9.4 Xcode: Xcode 6 GM seed Windows 8.1 Device: ipad (ios8) and samsung galaxy (4.4.2)

JSON Source