How to find ArrayList length after filtered in apache royale - actionscript-3

This code snippet is from TDJ List
<j:Card>
<html:H3 text="Jewel List"/>
<j:List id="list" width="200" height="300" dataProvider="{simple}" change="onChange(event)"/>
<j:TextInput width="200">
<j:beads>
<j:TextPrompt prompt="filter list..."/>
<j:SearchFilterForList list="{list}"/>
</j:beads>
</j:TextInput>
<j:Label id="selected" html="{describeItem(list.selectedItem)}"/>
</j:Card>
There is j:SearchFilterForList
What i want to know is when its work (type some text on the filter textbox), how to find filtered list length?
Thankyou

Just use the new "length" property just recently added. Tour de Jewel was updated as well showing the use of this new bead property in the List examples.
<j:Label html="{'list filtered length: ' + filter.length}"/>
<j:TextInput>
<j:beads>
<j:TextPrompt prompt="filter list..."/>
<j:SearchFilterForList id="filter" list="{iconList}"/>
</j:beads>
</j:TextInput>
Notice that the filtering performed by this bead is only visual, and the underlaying dataProvider is not filtered itself. To get a filtered view of the dataProvider you should use ArrayListView API, that is similar to flex ListCollectionView with filterFuncion.

Related

(Reverse) Traverse XPath Query for Accessing a DIV with a particular Text Value

Working with a DOM that has the same HTML loop 100+ times that looks like this
<div class="intro">
<div class="header">
<h1 class="product-code"> <span class="code">ZY001</span> <span class="intro">ZY001 Title/Intro</span> </h1>
</div>
<div>
<table>
<tbody>
<tr>
<td>Available</td>
<td> S </td>
<td> M </td>
<td> XL </td>
</tr>
I was previously using this XPath Query to get ALL the node values back (all 100+ instances of the DOM Query in connection with the variable nodes that may contain in Available
//div[#class='intro']/div/table/tbody/tr/td[contains(text(),'Available')]/following-sibling::td
object(DOMNodeList)[595]
public 'length' => int 591
Now I am needing to target the product-code / code specifically to retrieve all the td attributes for a particular code
Because the div that contains the unique identifier (in the example above, ZY001) is not a direct ancestor, my thinking is I have to do a Reverse XPath Query
Here's one of my attempts:
//h1[#class='product-code']/span[contains(#class, 'code') and text() = 'ZY001']/../../div[#class='intro']/div/table/tbody/tr/td[contains(text(),'Available')]/following-sibling::td
As I am defining /span[contains(#class, 'code') and text() = 'ZY001'] and then attempting to traverse the dom backwards twice using /../../ I was hoping/expecting to get back the div[#class='intro'] with the text ZY001 immediately above it, or rather a public 'length' => int 1
But all my attempts thus far have resulted in 0 results. Not false, indicating an improper XPath, but 0.
How can I modify my XPath Query to get back the single instance in the one-of-many <div class="intro">'s that contain the <h1 class="product-code">/<span class="code"> text value ZY001?
Use
//h1[#class='product-code']/span[contains(#class, 'code') and text() = 'ZY001']/../../../div/table/tbody
instead of
//h1[#class='product-code']/span[contains(#class, 'code') and text() = 'ZY001']/../../div[#class='intro']/div/table/tbody
You can use any of the below xpath's for that:
//div[#class='intro' and //h1[#class='product-code']/span[#class='code' and text()='ZY001']]//tbody/tr[td[text()='Available']]/td[2]
//div[#class='intro' and //span[#class='code' and text()='ZY001']]//tbody/tr[td[text()='Available']]/td[2]
//div[#class='intro' and //span[#class='code' and text()='ZY001']]//tr[td[text()='Available']]/td[2]
Change td[2] to td[3] and td[4] to get the 3rd and 4th td respectively

How can I get the first item in a list using free marker?

I have the following code which contains about 12 items but I only need to retrieve the first item. How can I display the first item in my list?
My code is:
<#list analysttest.rss.channel.item as item>
<div>
<h3 class="bstitle">${item.title}</h3>
<span class="bsauthor">${item.author}</span>
<span>${item.pubDate}</span>
<p>${item.description}</p>
</div>
</#list>
analysttest.rss.channel.item[0] gives the fist item, which you can #assign to a shorther name for convenience. Note that at least 1 item must exist, or else you get an error. (Or, you can do something like <#assign item = analysttest.rss.channel.item[0]!someDefault>, where someDefault is like '', [], {}, etc, depending on what you need. There's even a shorter <#assign item = analysttest.rss.channel.item[0]!> form, which uses a multi-typed "generic nothing" value as the default... see in the Manual.)
Listing is also possible, though odd for only one item: <#list analysttest.rss.channel.item[0..*1] as item>, where *1 means at most length of 1 (requires FreeMarker 2.3.21 or later). This works (and outputs nothing) even if you have 0 items.
<#assign item = analysttest.rss.channel.item[0]>
<div>
<h3 class="bstitle">${item.title}</h3>
<span class="bsauthor">${item.author}</span>
<span>${item.pubDate}</span>
<p>${item.description}</p>
</div>

Querying Intersection of two geometry columns in Mysql

I have tables with Geometry (Multipolygon Shape field) in Mysql. I am able to successfully run Area and Centroid. Is there a way in MySql however to query the intersection between two shapes expressed as a percentage of one in the other?
As per comment/request I am pasting in two mutlipoint geometry fields as I cannot figure out how to create a shape based table in sqlfiddle to make that easier, my apologies.
Zip Code 07024:
POLYGON((-73.982967 40.85601, -73.982439 40.856535, -73.982753 40.856696, -73.981338 40.858725, -73.98116 40.858553, -73.98071 40.858127, -73.979611 40.860178, -73.979382 40.860799, -73.978783 40.860699, -73.977687 40.8605, -73.977625 40.861338, -73.976375 40.863927, -73.975979 40.866037, -73.97581 40.86715, -73.97595 40.867368, -73.976498 40.868123, -73.975997 40.868331, -73.975852 40.868393, -73.975695 40.868462, -73.975424 40.868732, -73.975409 40.868767, -73.973501 40.867578, -73.972993 40.867361, -73.969825 40.865568, -73.969308 40.866081, -73.96889 40.866665, -73.967939 40.86767, -73.967224 40.868426, -73.966833 40.868573, -73.966599 40.868801, -73.965903 40.868417, -73.966106 40.868212, -73.965416 40.867819, -73.964641 40.867337, -73.963922 40.866921, -73.963033 40.866334, -73.961553 40.865627, -73.961057 40.865172, -73.959983 40.864747, -73.959338 40.864314, -73.958603 40.864012, -73.957929 40.863618, -73.95707 40.863094, -73.956499 40.862808, -73.955373 40.862408, -73.954582 40.861799, -73.953682 40.861199, -73.948385 40.858471, -73.951755 40.852121, -73.952044 40.851599, -73.952172 40.851368, -73.953482 40.849, -73.953982 40.848, -73.961982 40.8481, -73.96428 40.845936, -73.964416 40.846578, -73.965254 40.846613, -73.965508 40.846873, -73.965588 40.847314, -73.965493 40.847721, -73.965655 40.847583, -73.966297 40.847017, -73.967897 40.847412, -73.968466 40.84673, -73.968146 40.845991, -73.968481 40.845201, -73.969975 40.843707, -73.970303 40.843316, -73.971301 40.84213, -73.971575 40.841806, -73.972478 40.839104, -73.973107 40.835428, -73.973165 40.834416, -73.972952 40.834229, -73.972949 40.834164, -73.972968 40.834096, -73.973174 40.833617, -73.973334 40.832466, -73.973306 40.831923, -73.973267 40.831735, -73.973956 40.831892, -73.974176 40.831515, -73.974314 40.831326, -73.975646 40.828897, -73.976382 40.8276, -73.977731 40.82829, -73.978276 40.828543, -73.979977 40.829541, -73.98278 40.83107, -73.983573 40.831429, -73.983872 40.831592, -73.984742 40.832144, -73.985562 40.832688, -73.986268 40.833146, -73.986988 40.833553, -73.987719 40.83392, -73.988414 40.834306, -73.988761 40.83452, -73.989092 40.834704, -73.989874 40.835095, -73.990621 40.835377, -73.991325 40.835884, -73.991221 40.836037, -73.991102 40.836253, -73.990782 40.836634, -73.990063 40.83715, -73.988368 40.838989, -73.98773 40.839638, -73.987034 40.840345, -73.985915 40.841463, -73.984496 40.84288, -73.982203 40.84517, -73.982909 40.845573, -73.981298 40.847192, -73.981261 40.847214, -73.981144 40.847338, -73.981849 40.847781, -73.982608 40.848169, -73.98345 40.848469, -73.983527 40.848719, -73.984391 40.849063, -73.984835 40.849151, -73.984801 40.849419, -73.984896 40.850679, -73.985459 40.851398, -73.986166 40.850754, -73.98666 40.850301, -73.986718 40.850249, -73.987145 40.850414, -73.987891 40.850822, -73.987985 40.850884, -73.985961 40.853208, -73.984196 40.854911, -73.984091 40.854855, -73.98367 40.85531, -73.98354 40.85544, -73.982967 40.85601))
Fort Lee, NJ:
POLYGON((-73.985961 40.853208, -73.985344 40.853804, -73.984777 40.854344, -73.984228 40.854929, -73.983651 40.85551, -73.983092 40.856083, -73.982599 40.856605, -73.982753 40.856696, -73.981338 40.858725, -73.98116 40.858553, -73.980744 40.858154, -73.98071 40.858127, -73.980363 40.858773, -73.979611 40.860178, -73.979382 40.860799, -73.978783 40.860699, -73.977687 40.8605, -73.977625 40.861338, -73.976375 40.863927, -73.975979 40.866037, -73.97581 40.86715, -73.975695 40.868462, -73.97569 40.868903, -73.975409 40.868767, -73.973501 40.867578, -73.972993 40.867361, -73.970023 40.865686, -73.969825 40.865568, -73.969308 40.866081, -73.96889 40.866665, -73.967939 40.86767, -73.967224 40.868426, -73.966833 40.868573, -73.966106 40.868212, -73.965416 40.867819, -73.964641 40.867337, -73.963922 40.866921, -73.963033 40.866334, -73.962108 40.865929, -73.961553 40.865627, -73.961057 40.865172, -73.959983 40.864747, -73.959338 40.864314, -73.958603 40.864012, -73.957929 40.863618, -73.95707 40.863094, -73.956499 40.862808, -73.955373 40.862408, -73.954582 40.861799, -73.953682 40.861199, -73.948385 40.858471, -73.951755 40.852121, -73.952044 40.851599, -73.952172 40.851368, -73.953482 40.849, -73.953982 40.848, -73.961982 40.8481, -73.96428 40.845936, -73.964416 40.846578, -73.965212 40.846846, -73.96479 40.84776, -73.965493 40.847721, -73.965655 40.847583, -73.96588 40.847401, -73.965979 40.847321, -73.966155 40.847204, -73.966226 40.847134, -73.966286 40.847041, -73.966297 40.847017, -73.966418 40.847051, -73.966735 40.847137, -73.967225 40.847271, -73.967897 40.847412, -73.968193 40.847056, -73.968203 40.847044, -73.968466 40.84673, -73.968146 40.845991, -73.968303 40.845524, -73.968481 40.845201, -73.969975 40.843707, -73.970303 40.843316, -73.971301 40.84213, -73.971575 40.841806, -73.972478 40.839104, -73.973107 40.835428, -73.973165 40.834416, -73.973225 40.834413, -73.973289 40.834392, -73.973332 40.834364, -73.973379 40.834284, -73.973394 40.834221, -73.973391 40.834167, -73.973355 40.833909, -73.973351 40.833778, -73.973398 40.833352, -73.973433 40.833179, -73.973485 40.833009, -73.973814 40.832198, -73.973956 40.831892, -73.97406 40.831701, -73.974176 40.831515, -73.974314 40.831326, -73.975646 40.828897, -73.976382 40.8276, -73.977731 40.82829, -73.978276 40.828543, -73.979977 40.829541, -73.98278 40.83107, -73.983573 40.831429, -73.983872 40.831592, -73.984742 40.832144, -73.985562 40.832688, -73.986268 40.833146, -73.986988 40.833553, -73.987719 40.83392, -73.988414 40.834306, -73.988761 40.83452, -73.989092 40.834704, -73.989874 40.835095, -73.990621 40.835377, -73.991325 40.835884, -73.991221 40.836037, -73.991102 40.836253, -73.990782 40.836634, -73.990707 40.836688, -73.990063 40.83715, -73.988368 40.838989, -73.98773 40.839638, -73.987034 40.840345, -73.985915 40.841463, -73.984496 40.84288, -73.982203 40.84517, -73.981262 40.84611, -73.980579 40.846792, -73.980459 40.846915, -73.981144 40.847338, -73.981849 40.847781, -73.982608 40.848169, -73.98345 40.848469, -73.983527 40.848719, -73.984391 40.849063, -73.984835 40.849151, -73.985717 40.849611, -73.98625 40.850043, -73.986394 40.850027, -73.986431 40.850024, -73.986718 40.850249, -73.987145 40.850414, -73.987891 40.850822, -73.987985 40.850884, -73.985961 40.853208))

SAPUI5 Googlemaps library : multiple markers via list

i'm using the SAPUI5 Googlemaps library. It works great for one marker, but i need to add multiple markers based on a list. How can i add all these items to the map ?
<Map height="500px" zoom="10" lat="52,03838" lng="5,67866">
<markers> --> add items="{/GmapMarkers}" ????
<Marker lat="{lat}" lng="{lng}" info="{info}" />
</markers>
</Map>
Based on the items in /GmapMarkers i want to fill the map.
Is this possible ?
gr
Hans
I think you can use aggregation binding. Here is the example from http://jasper07.secondphase.com.au/openui5-googlemaps/. Look for Marker cluster.
<mvc:View xmlns:mvc="sap.ui.core.mvc" xmlns:gmaps="openui5.googlemaps" controllerName="sampleController">
<gmaps:Map lat="33.408495" lng="-104.521889" width="950px" height="475px" zoom="4" zoomControl="true">
<gmaps:markerCluster>
<gmaps:MarkerCluster markers="{/features}">
<gmaps:markers>
<gmaps:Marker lat="{geometry/coordinates/1}" lng="{geometry/coordinates/0}" info="{properties/city}" icon="http://www.w3schools.com/googleapi/pinkball.png"></gmaps:Marker>
</gmaps:markers>
</gmaps:MarkerCluster>
</gmaps:markerCluster>
</gmaps:Map>
</mvc:View>

Having trouble getting ID from JSON on Autocomplete

I have a typeahead that looks like this:
<input type="text" class='tk-proxima-nova degreeIn candidateProfile' placeholder="School / Institution" ng-model="university" typeahead="university.Service_Provider_Name for university in universitySuggest($viewValue)" />
it returns JSON that looks similar to this:
[{"Service_Provider_ID":133368,"Service_Provider_Name":"Duke University","Service_Provider_Desc":null,"NAICS_Id":1809},{"Service_Provider_ID":196282,"Service_Provider_Name":"Duke University Medical Center","Service_Provider_Desc":null,"NAICS_Id":1809},{"Service_Provider_ID":222220,"Service_Provider_Name":"Duke University Psychology Internship","Service_Provider_Desc":null,"NAICS_Id":1809},{"Service_Provider_ID":223427,"Service_Provider_Name":"Duke University Medical Center Psychology Internship","Service_Provider_Desc":null,"NAICS_Id":1809}]
When I select the option from the typeahead it puts the school name in the field as it's supposed to, but is there a way to also set the id to another hidden input so I can send that with my selected data as well. The ID is what is important here, but the name is needed for viewing.
Yes, you can do something like :
<input type="text"
ng-model="selected"
typeahead-on-select="changeSelect($item)"
typeahead="university as university.Service_Provider_Name for university in universities | filter:{Service_Provider_Name:$viewValue} " />
Here is the Plunkr
I've a little indented your code for more clarity.
In addition to the comments Apercu gave above regarding the format of the typeahead="..." ,you need to have a typeahead-input-formatter like this
typeahead-input-formatter="univChosen($model)"
$scope.univChosen = function(theId) {
var theItem = jQuery.grep($scope.universities,function(p) {
return p.Service_Provider_ID == theId});
return theItem[0].Service_Provider_Name;
};
I'm assuming here that $scope.universities contains the complete list of all the items in the typeahead choices. I've used jQuery here to find the matching item but you can just do a for(...) loop if you want. The function returns the string that will actually get displayed, in this case the name.