Looping through Collection
Hello I need to loop through the collection to process 500 records at a time from the resultset.
how do i do this?
I have created another variable of same type as resultset output variable type. but not sure how to assign nodes 1 to 1000 to the new variable.
Hi,
You can loop over your collection with a while loop. The following is from the bpel samples directory (112.Arrays) adapted to your needs. Define the variables:
<variable name="iterator" type="xsd:integer"/>
<variable name="count" type="xsd:integer"/>
<variable name="xpath" type="xsd:string"/>
Set the initial values:
<assign name="SetInitialValues">
<copy>
<from expression="1"/>
<to variable="iterator"/>
</copy>
<copy>
<from expression="ora:countNodes('input', 'payload','/tns:collection/tns:item')"/>
<to variable="count"/>
</copy>
</assign>
Make a while loop:
<while condition=" bpws:getVariableData('count') >= bpws:getVariableData('iterator')">
<sequence>
<assign name="setAttribute">
<copy>
<from expression="concat('/tns:collection/tns:item[',bpws:getVariableData('iterator'),']/tns:value')"/>
<to variable="xpath"/>
</copy>
<copy>
<from expression="bpws:getVariableData('input','payload',bpws:getVariableData('xpath'))/>
<to variable="output" part="payload" query="/tns:recordVariable/tns:value"/>
</copy>
<!--
Place here your own actions to be executed for every row
-->
<copy>
<from expression="bpws:getVariableData('iterator') + 1"/>
<to variable="iterator"/>
</copy>
</assign>
</sequence>
</while>
So the trick is to dynamically build an xpath expression based on the while loop counter.
Kind Regards,
Andre
Similar Messages
-
Looping through Collection and getting ConcurrentModificationException
I'm trying to loop through a collection to delete some objects referenced by that collection but keep coming up against a ConcurrentModificationException.
BwView view = svci.getViewsHandler().find("Lists");
Collection<BwSubscription> subarr = new TreeSet<BwSubscription>();
subarr = svci.getSubscriptionsHandler().getAll();
if (subarr == null) {
logger.info("Its not working");
for (BwSubscription sub: subarr) {
logger.info("Removing subs " + sub);
svci.beginTransaction();
svci.getSubscriptionsHandler().delete(sub);
logger.info("Deleting calendars :" + sub);
svci.endTransaction();
The loop is allowing me to delete the first entry but then fails with the exception.
I have tried with a generic loop but this doesn't initialise the sub entity so the loop fails and is ignored leading to problems later in the code.
BwView view = svci.getViewsHandler().find("Lists");
BwSubscription[] subarr = (BwSubscription[])view.getSubscriptions().toArray(new BwSubscription []{});
if (subarr == null) {
logger.info("Its not working");
for (int i=subarr.length - 1; i>=0; i--) {
sub = subarr;
logger.info("Removing subs " + sub);
svci.beginTransaction();
svci.getSubscriptionsHandler().delete(sub);
logger.info("Deleting calendars :" + sub);
svci.endTransaction();
Sub is either not initialised or gets initialised as 0 causing an ArrayIndexOutofBoundsException. I'd be grateful for some advice on getting the code to loop correctly.While iterating over a collection (using its iterator), a ConcurrentModificationException will be thrown if the collection is modified, except if it is modified using the iterator itself.. The enhanched for-loop you're using is iterating over the collection by implicitly using an Iterator. To do what you want, make the Iterator explicit (change the enhanced for-loop to a while loop) and then use iterator.remove().
-
Looping through collection of symbols and populating a drop down on a form EXTENDSCRIPT
Hello everyone-
I got a question. Would it be possible to run a script that would loop through a collection of symbols in a defined library and populate a drop down with the available symbols. My goal is to be able to open Illustrator, and when I run the script the dropdown is populated with all available symbols(text is fine) in a defined library that I can then select and place on the artboard. Any help would be appreciated.
thanks in advance!So...
Dim appref As New Illustrator.Application
Dim docRef As Illustrator.Document 'The work document
Dim docToAdd As Illustrator.Document 'The document which contain the symbol's library
Dim pathArt As Object
Dim ItemSymbol As Object
Dim itemSymbolref As Illustrator.Symbol
Dim artObject As Variant
appref.Open ("C:\..... workDoc.ai")
Set docRef = appref.ActiveDocument 'Assign docRef to your work document
appref.Open ("C:\......symbolDoc.ai")
Set docToAdd = appref.ActiveDocument 'Assign docToAdd to your symbol document
Set symbolref = appref.ActiveDocument.Symbols(Symbol_Name) 'Assign symbol ref the symbol you're looking for
Set itemref = appref.ActiveDocument.SymbolItems.Add(symbolref) 'Copy it on the current active page
itemref.Selected = True 'select it
docToAdd.Copy 'add it to your clibboard
docToAdd.close (aiDoNotSaveChanges) 'Close the library, without changing anything
appref.ActiveDocument.Paste 'Paste the clipboard on your work document
'As soon as you paste the symbol, it will be added in the document symbol library
Clipboard_Clear 'See below why...
SelectedObjects =appref.ActiveDocuments.selection ' Select the symbol you past
' The loop is not necessary if you have only one thing selected
For Each artObject In selectedObjects
artObject.Delete
Next
' Cleanup your pointers
Set artObject = Nothing
Set pathArt = Nothing
Set docToAdd = Nothing
[....] Continue your script on your working document
Set docRef = Nothing 'after closing your working doc...
Remark on clipboard_clear : If you don't do it, the risk is to accumulate plenty other things you don't want...
Public Function ClipBoard_Clear()
Call OpenClipboard(0&)
Call EmptyClipboard
Call CloseClipboard
End Function
With
Public Declare PtrSafe Function OpenClipboard Lib "user32" (ByVal hWnd As Long) As Long
Public Declare PtrSafe Function CloseClipboard Lib "user32" () As Long
Public Declare PtrSafe Function EmptyClipboard Lib "user32" () As Long
be careful I use the PtrSafe pointer due to the fact I'm working in x64 architecture
in x86 it will be
Public Declare Function OpenClipboard Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function CloseClipboard Lib "user32" () As Long
Public Declare Function EmptyClipboard Lib "user32" () As Long
Regards to all
Michel -
How to loop through a collection of records which is return value of func.
Hi all.
Have this situation:
- Stored function (member of pkg procedure) that returns a collection of records.
Package Spec:
=========
type tipo_pvt is table of s08_plan_venta_totalizado_r % rowtype;
rc_pvt tipo_pvt;
(s08_plan_venta_totalizado_r is a view).
Package Body:
=========
select col1
,col2
,etc
bulk collect into rc_pvt
from s08_lista_precio_producto_r lpp
,s03_producto_r prd
where condition;
return rc_pvt;
Once collection is loaded and returned (i know it loads records). I just want to loop through every record on a pl/sql procedure on the client (forms6i procedure), but it gives me the error: ORA-06531 Reference to uninitialized collection:
On the forms6i client procedure i have something like:
procedure p_carga_plan_venta_inv (p_id_plan_venta in number) is
v_contador integer;
v_mensaje varchar2(10);
rc_pvt sk08_gestiona_plan_venta.tipo_pvt; (sk08_gestiona_plan_venta is package name)
begin
rc_pvt := sk08_gestiona_plan_venta.tipo_pvt();
rc_pvt := sk08_gestiona_plan_venta.f_genera_plan_venta_inv (:pvv.lip_id_lista_precio
,:pvv.ems_id_sucursal
,:control4.v_metodo_calculo
,:pvv.unm_co_unidad_monetaria
,:pvp.fe_fin_periodo) ;
-- previous statement dos not fail BUT THIS:
message('rc_pvt.count= '||rc_pvt.count);pause;
DOES FAIL
end;
So my question is : since i have already returned the collection, how come is not initialized....?
Do i have to extend it first? In this case i have to return the number of records in the collection.....
Look what happen when done from sqlplus:
declare
rc_pvt sk08_gestiona_plan_venta.tipo_pvt;
begin
rc_pvt := sk08_gestiona_plan_venta.tipo_pvt();
rc_pvt :=
sk08_gestiona_plan_venta.f_genera_plan_venta_inv (8713171
,null
,'m'
,'BS.F'
,to_date('28/02/2001','dd/mm/yyyy'));
end;
SQL> /
Registros en la coleccion =6
Procedimiento PL/SQL finalizado con éxito.
SQL>
I put a dbms_output.put_line on stored function .....
Please help ....!
Apparently it fails when calling the stored function:
rc_pvt := sk08_gestiona_plan_venta.f_genera_plan_venta_inv (:pvv.lip_id_lista_precio
,:pvv.ems_id_sucursal
,:control4.v_metodo_calculo
,:pvv.unm_co_unidad_monetaria
,:pvp.fe_fin_periodo) ;
I don't undestand since this function return the appropiate type. It seems the collection is empty, although having test that on sqlplus works ...
rc_pvt := sk08_gestiona_plan_venta.f_genera_plan_venta_inv (:pvv.lip_id_lista_precio
,:pvv.ems_id_sucursal
,:control4.v_metodo_calculo
,:pvv.unm_co_unidad_monetaria
,:pvp.fe_fin_periodo) ;
function f_genera_plan_venta_inv (p_id_lista_precio in number
,p_id_sucursal in number
,p_tipo_nivel_inv in varchar2
,p_co_unidad_monetaria in varchar2
,p_fe_fin_periodo in date) return tipo_pvt;
for some reason it works on plus:
SQL> declare
2 rc_pvt sk08_gestiona_plan_venta.tipo_pvt;
3 begin
4 rc_pvt := sk08_gestiona_plan_venta.tipo_pvt();
5 rc_pvt :=
6 sk08_gestiona_plan_venta.f_genera_plan_venta_inv (8713171
7 ,null
8 ,'m'
9 ,'BS.F'
10 ,to_date('28/02/2001','dd/mm/yyyy'));
11 --
12 dbms_output.put_line('Registros en la coleccion = '||rc_pvt.count);
13 for i in 1 .. rc_pvt.count loop
14 --
15 dbms_output.put_line('En '||i||rc_pvt(i).prd_co_producto);
16 end loop;
17 end;
18 /
Registros en la coleccion =6
Registros en la coleccion = 6
En 1PT.REF.PET.KO05
En 2PT.REF.PET.LM15
En 3PT.ALM.VDR.001
En 4PT.REF.GRN.CN
En 5PT.REF.GRN.KO
En 6PT.REF.GRN.LM
Procedimiento PL/SQL finalizado con éxito.
Don't understand why it works on plus8 (same version that comes with 6i).
Can't loop through records on forms...? WHY ...?
Edited by: myluism on 02-abr-2012 14:40Forms 6i is an antique ... write your code to run on the server.
Multiple examples of how to loop through an array loaded with bulk collect can be found here.
http://www.morganslibrary.org/reference/array_processing.html
The main library page is:
http://www.morganslibrary.org/library.html -
How do i loop through a pl/sql collection based on a condition.
hi, can any one help me or provide me sample code where i have to loop through a collection based on condition . just like where clause in sql. your help is highly appreciated....
{code}
create table MODEL1
model_id NUMBER ,
model_seq NUMBER,
p_ind VARCHAR2(1)
insert into model1 (MODEL_ID, MODEL_SEQ, P_IND)
values (4, 103, 'U');
insert into model1 (MODEL_ID, MODEL_SEQ, P_IND)
values (3, 102, 'P');
insert into model1 (MODEL_ID, MODEL_SEQ, P_IND)
values (2, 101, 'U');
insert into model1 (MODEL_ID, MODEL_SEQ, P_IND)
values (1, 100, 'P');
MODEL PROCEDURE......
procedure ( param1,param2) ( assume this procedure is being called from other procedure and collection has been populated already)
TYPE l_tab is table of MODEL1%rowtype;
begin
loop through l_tab records where ltab.model_id=param1 and p_ind =p
Join based on if else condition.
if param2 is not null then
l_tab.model_seq=param2 and ltab.p_ind='P'
if param2 is null then
l_tab.p_ind='P' etc...........
{code}Hi,
Try something like this:
DECLARE
TYPE L_TAB IS TABLE OF MODEL1%rowtype;
TAB L_TAB;
param1 number := 1;
param2 number := 999;
BEGIN
select
model_id
,model_seq
,p_ind
bulk collect into TAB
from
MODEL1
DBMS_OUTPUT.PUT_LINE('PARAM1: ' || PARAM1);
DBMS_OUTPUT.PUT_LINE('PARAM2: ' || PARAM2);
DBMS_OUTPUT.PUT_LINE(' MODEL_ID, MODEL_SEQ, P_IND' );
FOR X IN TAB.FIRST .. TAB.LAST
LOOP
DBMS_OUTPUT.PUT_LINE('OLD: ' || TAB(X).MODEL_ID || ' ' || TAB(X).MODEL_SEQ || ' ' || TAB(X).P_IND );
IF TAB(X).model_id = param1 AND TAB(X).p_ind = 'P' THEN
IF param2 IS NOT NULL THEN
TAB(X).model_seq := param2;
-- TAB(X).p_ind := 'P'; -- THIS IS NOT NEEDED SINCE THE CONDITION STATE L_TAB(X).P_IND = 'P' ALREADY
NULL;
END IF;
IF param2 IS NULL THEN
-- TAB(X).p_ind := 'P'; -- THIS IS NOT NEEDED SINCE THE CONDITION STATE L_TAB(X).P_IND = 'P' ALREADY
NULL;
END IF;
END IF;
DBMS_OUTPUT.PUT_LINE('NEW: ' || TAB(X).MODEL_ID || ' ' || TAB(X).MODEL_SEQ || ' ' || TAB(X).P_IND );
END LOOP;
END;
PARAM1: 1
PARAM2: 999
MODEL_ID, MODEL_SEQ, P_IND
OLD: 4 103 U
NEW: 4 103 U
OLD: 3 102 P
NEW: 3 102 P
OLD: 2 101 U
NEW: 2 101 U
OLD: 1 100 P
NEW: 1 999 P
Regards,
Peter -
How do I loop through tables, not columns in a table?
Sorry if this is a long one. My problem is actually quite simple. I am trying to write either an ad hoc PL/SQL block or a stored procedure to loop 18 times (thru 18 tables) and perform a SQL query on those tables, returning 18 resultsets. I would like the results to show up on the screen (or in a spool file, whatever).
So far I have tried 3 different approaches, none of which have worked.
1. I tried to assign the select query to a variable (qry) and use EXECUTE IMMEDIATE qry. This forced me thru a variety of errors to declare variables and assign the result to them--EXECUTE IMMEDIATE qry into nm0, nm1, nm2...
The problem with that was the resultset returned more than the variable was built for as there might be no rows returned, or it might be a thousand rows of data. So I tried changing the variables to VARRAYS, but it gave me a type mismatch as the underlying columns were NUMBER and VARCHAR2.
DECLARE
ctr number;
TYPE NUMLIST IS VARRAY (1000) OF NUMBER;
TYPE VARLIST IS VARRAY (1000) OF VARCHAR2(15);
nm0 NUMLIST NOT NULL DEFAULT 1;
nm1 VARLIST;
nm2 NUMLIST NOT NULL DEFAULT 1;
nm3 VARLIST;
nm17 NUMLIST NOT NULL DEFAULT 1;
qry VARCHAR2(2000) := 'klx_uln_p000_cells';
BEGIN
FOR ctr IN 1..17 LOOP
IF ctr < 10 THEN
qry := 'SELECT
A.DIM_0_INDEX,
S0.SYM_NAME,
A.DIM_1_INDEX,
S1.SYM_NAME,
A.DIM_2_INDEX,
S2.SYM_NAME,
A.DIM_3_INDEX,
S3.SYM_NAME,
A.NUMERIC_VALUE,
B.NUMERIC_VALUE
FROM
KHALIX.klx_uln_p00'||ctr||'_cells A,
KHALIX.klx_ucn_p00'||ctr||'_cells B,
KHALIX.KLX_MASTER_SYMBOL S0,
KHALIX.KLX_MASTER_SYMBOL S1,
KHALIX.KLX_MASTER_SYMBOL S7
WHERE
A.DIM_0_INDEX=B.DIM_0_INDEX AND
A.DIM_1_INDEX=B.DIM_1_INDEX AND...
A.DIM_7_INDEX=S7.SYM_INDEX';
ELSE
qry := 'SELECT
A.DIM_0_INDEX...
A.DIM_7_INDEX=S7.SYM_INDEX';
END IF;
BEGIN
dbms_output.put_line('SELECT FOR KLX_ULN_P00'||ctr||'_CELLS');
dbms_output.put_line(nm16);
dbms_output.put_line(nm17);
EXECUTE IMMEDIATE qry into nm0,nm1,nm2,nm3,nm4,nm5,nm6,nm7,nm8,nm9,nm10,nm11,nm12,nm13,nm14,nm15,nm16,nm17;
-- dbms_output.put_line(qry);
dbms_output.put_line(nm16);
dbms_output.put_line(nm17);
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('No data found for Query '||ctr);
END;
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('No data found for Query '||ctr);
END;
2. So then I used REF CURSOR to create a stored procedure and return the values. That allowed me to run my query AND tokenize the tablenames with a counter so that it would loop through the different tables! However, I still could not get it to display the results without going to SQL Plus and typing 'print c;'.
3. So, finally I tried to create a looping wrapper around the ref cursor to have some variable (ctr) increment so my query would get performed on table0_cells through table17_cells. This, too, did not work.
If I manually go to SQL Plus and type:
variable ctr number
begin
:ctr := 1;
end;
exec dupe_find(1,:c);
it will execute for the first table (klx_uln_p001_cells) and I can then type 'print c' to see what was returned. But when I try putting this within a wrapper PL/SQL block with a Loop to make ctr go from 0 - 17 (to loop through table_names klx_uln_p000_cells to klx_uln_p017_cells), it does not work.
Help! It should be very simple to loop through tables, shouldn't it? I just want a script that will loop through tables, perform a query on each table and display the results. For some reason, I can only find documentation examples on looping through columns that are all in the same table.
DaveHere's a working example using your first strategy ...
create table t1 (id number);
create table t2 (id number);
insert into t1 values (100);
insert into t1 values (101);
insert into t2 values (200);
insert into t2 values (201);
declare
v_table_name user_tables.table_name%type;
type ttab_id is table of t1.id%type index by binary_integer;
tab_id ttab_id;
begin
for i in 1 .. 2 loop
v_table_name := 't' || i;
execute immediate 'select id from ' || v_table_name
bulk collect into tab_id;
dbms_output.put_line('query from ' || v_table_name);
for j in 1 .. tab_id.count loop
dbms_output.put_line(tab_id(j));
end loop;
end loop;
end;
There are many other ways to do this (especially if you need to do more than just print out the data).
Richard -
Looping through an array to get the index for each measure in a combo box
Hi folks,
I am working on a web application that has two combo boxes, one for year (called yearcombo) and for measures (called myURL) for that selected year, and also two radiobuttons (in radioBtnGroup). I have two years and a bunch of measure for each year. I have a map tool tip that when you mouse over the county you see a measure for that specific year. However I have a bunch of measures for each year and I want to be able to loop through the measures (which are in an array collection inside a combobox) so my "if" expression can find every selectedIndex and bring me the tool tip for that selected measure for that selected radio button. Right now I would have to create if statements for each measure (each selectedIndex inside the myURL combobox)and each radiobutton (inside the radioBtnGroup) instead of creating a if expression to get a map tip tool for each measure. I know I would have to create a loop to search for these indexes and enter that in the if expression and also change the graphic.attributes to reflect the right measure or index selected. Do you API for Flex wizards can give me any tips on how to code this according to my code below ? Any help is greatly appreciated! (the print scree is attached)
Below is the code snippet:
if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 0 && radioBtnGroup.selectedValue == 0)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirIndOut.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
And below is the combo boxes with the arrays
<mx:FormItem label="Year :" >
<mx:ComboBox id="yearcombo" selectedIndex="0" labelField="label" width="100%" change="changeEvt(event)" >
<mx:ArrayCollection id="year" >
<fx:Object label="2007" year="2007" />
<fx:Object label="2009" year="2009" />
</mx:ArrayCollection>
</mx:ComboBox>
</mx:FormItem>
<mx:FormItem label="Measure:">
<mx:ComboBox id="myURL" selectedIndex="8" width="80%" mouseOver="clickEv2(event)" close="closeHandler(event)">
<mx:ArrayCollection id="measures" >
<fx:Object id="forindout07" labeltext="2007 Forestry Industry Output" label="Forestry Industry Output " value="RADIO_BUTTONS/TFEI_07_forest_industry_output" year="2007" />
<fx:Object id="foremp07" label="2007 Forestry Employment " value="RADIO_BUTTONS/TFEI_07_forest_employment" year="2007" />
<fx:Object id="forlabinc07" label="2007 Forestry Labor Income " value="RADIO_BUTTONS/TFEI_07_forest_labincome" year="2007" />
<fx:Object id="forindbustax07" label="2007 Forestry Indirect Business Tax" value="RADIO_BUTTONS/TFEI_07_forest_business_tax" year="2007" />
<fx:Object id="forindout09" label="Forestry Industry Output " value="RADIO_BUTTONS/TFEI_09_forest_industry_output" year="2009" />
<fx:Object id="foremp09" label="2009 Forestry Employment " value="RADIO_BUTTONS/TFEI_09_forest_employment" year="2009" />
<fx:Object id="forlabinc09" label="2009 Forestry Labor Income " value="RADIO_BUTTONS/TFEI_09_forest_labincome" year="2009" />
<fx:Object id="forindbustax09" label="2009 Forestry Indirect Business Tax" value="RADIO_BUTTONS/TFEI_09_forest_business_tax" year="2009" />
<fx:Object id="blank" label=" " />
</mx:ArrayCollection>And here is the entire code
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:esri="http://www.esri.com/2008/ags"
paddingBottom="8" paddingLeft="8"
paddingRight="8" paddingTop="8"
backgroundColor="0xffffff"
layout="vertical" >
<!-- Start Declarations -->
<fx:Declarations>
<esri:SimpleFillSymbol id="mouseOverSymbol" alpha="0.5" color="0x808080">
<esri:SimpleLineSymbol width="0" color="#000000"/>
</esri:SimpleFillSymbol>
<esri:SimpleFillSymbol id="defaultsym" alpha="0.01" color="#E0E0E0" >
<esri:SimpleLineSymbol width="1" color="#000000"/>
</esri:SimpleFillSymbol>
<!-- End Declarations -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import com.esri.ags.Graphic;
import com.esri.ags.SpatialReference;
import com.esri.ags.esri_internal;
import com.esri.ags.events.GraphicEvent;
import com.esri.ags.geometry.Extent;
import com.esri.ags.layers.ArcGISDynamicMapServiceLayer;
import com.esri.ags.symbols.SimpleFillSymbol;
import com.esri.ags.symbols.SimpleLineSymbol;
import flash.utils.flash_proxy;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.controls.RadioButton;
import mx.controls.TextArea;
import mx.events.DropdownEvent;
import mx.events.ItemClickEvent;
import mx.rpc.Fault;
import mx.rpc.events.FaultEvent;
import flash.display.Sprite;
import flash.events.ErrorEvent;
import flash.events.MouseEvent;
private function closeHandler(evt:DropdownEvent):void {
myLabel.text = ComboBox(evt.target).selectedItem.labeltext;
private function loadLayerName():void
myLegend.layers = null;
layerPanel.removeAllChildren();
//loop through each layer and add as a radiobutton
for(var i:uint = 0; i < (dynamicLayer.layerInfos.length); i++)
var radioBtn:RadioButton = new RadioButton;
radioBtn.groupName = "radioBtnGroup";
radioBtn.value = i;
radioBtn.label = dynamicLayer.layerInfos[i].name;
if (dynamicLayer.layerInfos[i].name == "Direct Impact (Million $)")
radioBtn.label = "Direct Impact";
else if (dynamicLayer.layerInfos[i].name == "Total Impact (Million $)")
{radioBtn.label = "Total Impact";
else if (dynamicLayer.layerInfos[i].name == "Total Impact (Jobs)")
{radioBtn.label = "Total Impact";
else if (dynamicLayer.layerInfos[i].name == "Direct Impact (Jobs)")
{radioBtn.label = "Direct Impact";
else
{radioBtn.visible= false;
layerPanel.addChild(radioBtn);
/* myDividerBox.getDividerAt(0).visible = false; */
//set the visible layer the first radio button
radioBtnGroup.selectedValue = 0;
dynamicLayer.visibleLayers = new ArrayCollection([0]);
myLegend.layers = [dynamicLayer];
myLegend.visible = true;
private function radioClickHandler(event:ItemClickEvent):void
myLegend.layers = null;
// update the visible layers to only show the layer selected
dynamicLayer.visibleLayers = new ArrayCollection([event.index]);
myLegend.layers = [dynamicLayer];
private function changeEvt(event:Event):void {
if (yearcombo.selectedItem.year == "2007")
measures.filterFunction=filter1
measures.refresh()
myURL.dataProvider=measures
else if (yearcombo.selectedItem.year == "2009")
measures.filterFunction=filter2
measures.refresh();
public function filter1(item:Object):Boolean
if (item.year=="2007") return true
else return false
public function filter2(item:Object):Boolean
if (item.year=="2009") return true
else return false
private function clickEvt(event:Event):void {
if (yearcombo.selectedItem.year == "2007")
measures.filterFunction=filter3
measures.refresh()
myURL.dataProvider=measures
else if (yearcombo.selectedItem.year == "2009")
measures.filterFunction=filter4
measures.refresh();
public function filter3(item:Object):Boolean
if (item.year=="2007") return true
else return false
public function filter4(item:Object):Boolean
if (item.year=="2009") return true
else return false
private function clickEv2(event:Event):void {
if (yearcombo.selectedItem.year == "2007")
measures.filterFunction=filter5
measures.refresh()
else if (yearcombo.selectedItem.year == "2009")
measures.filterFunction=filter6
measures.refresh();
else if (yearcombo.selectedItem.year == 2007 && myURL.selectedIndex==8)
myLegend.layers = null;
layerPanel.removeAllChildren();
public function filter5(item:Object):Boolean
if (item.year=="2007") return true
else return false
public function filter6(item:Object):Boolean
if (item.year=="2009") return true
else return false
/* IF YOU WANT TO INCLUDE OTHER VALUES IN THE MAP TOOLTIP LIKE COUNTY NAME AND THE LABEL OF THE SELECTED ITEM
if (myURL.selectedIndex==0)
myTextArea.htmlText = "<b>County: </b>" + gr.attributes.NAME + "\n"
+ "<b>Measure: </b>" + myURL.selectedItem.label + gr.attributes.ForDirIndOut.toString()
public function fLayer_graphicAddHandler(event:GraphicEvent):void
event.graphic.addEventListener(MouseEvent.MOUSE_OVER, onMouseOverHandler);
event.graphic.addEventListener(MouseEvent.MOUSE_OUT, onMouseOutHandler);
public function onMouseOverHandler(event:MouseEvent):void
if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 0 && radioBtnGroup.selectedValue == 0)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirIndOut.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 0 && radioBtnGroup.selectedValue == 1)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpIndOut.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 1 && radioBtnGroup.selectedValue == 0)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirEmp.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 1 && radioBtnGroup.selectedValue == 1)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpEmp.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 2 && radioBtnGroup.selectedValue == 0)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirLabInc.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 2 && radioBtnGroup.selectedValue == 1)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpLabInc.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 3 )
fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForIndirBusTax.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 0 && radioBtnGroup.selectedValue == 0)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirIndOut.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 0 && radioBtnGroup.selectedValue == 1)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpIndOut.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 1 && radioBtnGroup.selectedValue == 0)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirEmp.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 1 && radioBtnGroup.selectedValue == 1)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpEmp.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 2 && radioBtnGroup.selectedValue == 0)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirLabInc.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 2 && radioBtnGroup.selectedValue == 1)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpLabInc.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 3 )
fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForIndirBusTax.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
public function onMouseOutHandler(event:MouseEvent):void
var gr:Graphic = Graphic(event.target);
gr.symbol = defaultsym;
myMap.infoWindow.hide();
]]>
</fx:Script>
<fx:Style>
@namespace esri "http://www.esri.com/2008/ags";
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
@namespace esri "http://www.esri.com/2008/ags";
@namespace components "com.esri.ags.components.*";
components|InfoWindow
content-background-alpha : 0.4;
background-color : #4A7138;
background-alpha : 0.7;
border-style : solid;
</fx:Style>
<mx:HBox width="930" height="800" id="mapHbox" horizontalAlign="center" >
<mx:HBox width="80">
</mx:HBox>
<mx:HBox id="myHBox" width="800" height="600" backgroundColor="0xffffff" >
<mx:VBox height="590" width="358" >
<!-- <mx:Panel
width="356" height="100%"
color="0x000000"
borderAlpha="0.15"
>
-->
<mx:Canvas height="100%" width="100%" backgroundColor="0xffffff" >
<esri:Map id="myMap" openHandCursorVisible="false"
height="100%"
logoVisible="false"
doubleClickZoomEnabled="false"
scrollWheelZoomEnabled="false"
zoomSliderVisible="false"
scaleBarVisible="false" scale="4000000" >
<esri:extent>
<esri:Extent xmin="-10736651.061900" ymin="4024099.909700" xmax="-10409195.669800" ymax="3440153.831100" >
<esri:SpatialReference wkid="102100"/>
</esri:Extent>
</esri:extent>
<esri:ArcGISDynamicMapServiceLayer id="dynamicLayer2"
url="http://tfs-24279/ArcGIS/rest/services/RADIO_BUTTONS/counties_layer/MapServer" />
<esri:ArcGISDynamicMapServiceLayer id="dynamicLayer" name=" "
alpha="1"
load="loadLayerName()"
url="http://tfs-24279/ArcGIS/rest/services/{myURL.selectedItem.value}/MapServer" />
<esri:FeatureLayer id="fLayer"
graphicAdd="fLayer_graphicAddHandler(event)"
mode="snapshot"
outFields="*"
symbol="{defaultsym}"
url= "http://tfs-24279/ArcGIS/rest/services/RADIO_BUTTONS/feature_layer_0709_five/FeatureServer/ 0" />
</esri:Map>
</mx:Canvas>
<!-- </mx:Panel>-->
</mx:VBox>
<mx:VBox height="590" width="20" >
</mx:VBox>
<mx:Canvas height="500" width="400" backgroundColor="0xffffff"
horizontalScrollPolicy="off"
verticalScrollPolicy="off" >
<mx:VBox width="420" height="50%" paddingLeft="5" paddingTop="10" paddingRight="10" paddingBottom="10"
verticalGap="8">
<mx:Form >
<mx:FormItem label="Year :" >
<mx:ComboBox id="yearcombo" selectedIndex="0" labelField="label" width="100%" change="changeEvt(event)" >
<mx:ArrayCollection id="year" >
<fx:Object label="2007" year="2007" />
<fx:Object label="2009" year="2009" />
</mx:ArrayCollection>
</mx:ComboBox>
</mx:FormItem>
<mx:FormItem label="Measure:">
<mx:ComboBox id="myURL" selectedIndex="8" width="80%" mouseOver="clickEv2(event)" close="closeHandler(event)">
<mx:ArrayCollection id="measures" >
<fx:Object id="forindout07" labeltext="Forestry Industry Output" label="Forestry Industry Output " value="RADIO_BUTTONS/TFEI_07_forest_industry_output" year="2007" />
<fx:Object id="foremp07" label="Forestry Employment " value="RADIO_BUTTONS/TFEI_07_forest_employment" year="2007" />
<fx:Object id="forlabinc07" label="Forestry Labor Income " value="RADIO_BUTTONS/TFEI_07_forest_labincome" year="2007" />
<fx:Object id="forindbustax07" label="Forestry Indirect Business Tax" value="RADIO_BUTTONS/TFEI_07_forest_business_tax" year="2007" />
<fx:Object id="forindout09" label="Forestry Industry Output " value="RADIO_BUTTONS/TFEI_09_forest_industry_output" year="2009" />
<fx:Object id="foremp09" label="Forestry Employment " value="RADIO_BUTTONS/TFEI_09_forest_employment" year="2009" />
<fx:Object id="forlabinc09" label="Forestry Labor Income " value="RADIO_BUTTONS/TFEI_09_forest_labincome" year="2009" />
<fx:Object id="forindbustax09" label="Forestry Indirect Business Tax" value="RADIO_BUTTONS/TFEI_09_forest_business_tax" year="2009" />
<fx:Object id="blank" label=" " />
</mx:ArrayCollection>
</mx:ComboBox>
</mx:FormItem>
</mx:Form>
<mx:VBox id="layerPanel" width="50%" height="8%" verticalGap="3" paddingLeft="17">
<mx:RadioButtonGroup id="radioBtnGroup" itemClick="radioClickHandler(event)" />
</mx:VBox>
<mx:VBox paddingLeft="17" height="50%" >
<mx:Canvas id="legendPanel" width="100%" >
<mx:Label id="myLabel" text=" " fontWeight="bold" />
<esri:Legend id="myLegend"
layers="{[dynamicLayer]}"
map="{myMap}" visible="false"
respectCurrentMapScale="false"/>
</mx:Canvas>
<mx:TextArea width="275" borderAlpha="0" height="200" >
<mx:htmlText >
<![CDATA[<font size='11'><b>Note:</b> Counties in white indicate either no data is available for that measure or the data has been supressed due to confidentiality.</font>
]]>
</mx:htmlText>
</mx:TextArea>
</mx:VBox>
</mx:VBox>
</mx:Canvas>
</mx:HBox>
</mx:HBox>
</mx:Application> -
Looping through serialized objects?
I have made a program which stores the game score such as seen 3d pinball. I know how to store then but I don't know how to loop through all records so that I can store them in one single array so that I can perform diffenent operations on that array.
such I should arrange them and find out the top five scorer. Give me some valueable hints.Demo:
import java.io.*;
import java.util.*;
public class Example implements Serializable {
private static final long serialVersionUID = 1;
private String text;
public Example(String text) {
this.text = text;
public String toString() {
return text;
public static void main(String[] args) throws IOException, ClassNotFoundException {
List<Example> list = new ArrayList<Example>();
Collections.addAll(list, new Example("hello"), new Example("world"));
File file = new File("temp.dat");
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file));
out.writeObject(list);
out.flush();
out.close();
ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
List<Example> input = (List<Example>) in.readObject();
in.close();
System.out.println(input);
} -
Tree control loop through nodes
Hi All,
I have a tree control. I want to loop through the nodes and
add all the nodes to an array collection.
How do I do it?
Thanks in advance;
JoshIt depends on the data type of the dataProvider.
If XML, then myXML.descendants(); will return an xmlList of
all nodes. You could loop over the XMLList and build an
ArrayCollection
If the dataProvider is a collection, then you will need a
recursive function to process the dataProvider.
Tracy -
Hi,
I'm trying to design business entities with ABAP Objects. I have been able to create internal tables of custom object types.
I stumbled into a very peculiar situation in which i have to loop through my custom object internal table. i couldn't use the WHERE specification since the line type is not a structure. READ TABLE doesnt work either. What i did to overcome the problem was to do a LOOP AT with an IF statement inside and an EXIT command to quit the search when found.
Is there a better solution? And Is the whole idea of wrapping everything in classes and accessing the through an internal idea a good idea in the first place?
Thanks.heres an example:
* DEFINITIONS
CLASS cl_drag_drop_picture DEFINITION INHERITING FROM cl_gui_picture.
PUBLIC SECTION.
DATA: row TYPE I,
col TYPE I.
DATA: g_wa_pic_ctrl TYPE REF TO cl_drag_drop_picture.
DATA: g_it_pic_ctrl LIKE TABLE OF g_wa_pic_ctrl.
* PROCESS
* lets assume that g_it_pic_ctrl has several entries and
* each entry is uniquely identified by the attributes
* row AND col.
PERFORM GetObjectByRowCol USING p_row
p_col
CHANGING g_wa_pic_ctrl.
* SUBROUTINES
FORM GetObjectByRowCol USING p_row
p_col
CHANGING r_pic_ctrl.
DATA: l_wa_pic_ctrl LIKE g_wa_pic_ctrl.
* Search for picture
LOOP AT g_it_pic_ctrl INTO l_wa_pic_ctrl.
IF l_wa_pic_ctrl->row EQ p_row AND
l_wa_pic_ctrl->col EQ p_col.
r_pic_ctrl = l_wa_pic_ctrl.
EXIT.
ENDIF.
ENDLOOP.
* Collect Garbage
CLEAR l_wa_pic_ctrl.
ENDFORM.
What I couldn't do is access my internal table like:
READ TABLE g_it_pic_ctrl
INTO r_pic_ctrl
WITH KEY row = p_row
col = p_col.
OR
LOOP AT g_it_pic_ctrl INTO r_pic_ctrl
WHERE row EQ p_row
col EQ p_col. -
Looping through an arrayCollection
I need to:
1. loop through an array collection,
2. select a specific string from that collection
3. extract a url from that string
4. insert an additional string to the array with that extracted url
The code I am using so far is:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="1024" minHeight="768">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var resultArrayCollection:ArrayCollection;
private function doSearch (e:MouseEvent):void
twitterSearch.url = "http://search.twitter.com/search.atom?q=LDN";
twitterSearch.send();
private function onResult (e:ResultEvent):void
resultArrayCollection = e.result.feed.entry as ArrayCollection;
]]>
</mx:Script>
<mx:HTTPService id = "twitterSearch"
result="onResult(event)" />
the HTTP service pulls in data from Twitter search for example http://search.twitter.com/search.atom?q=LDN.
All help would be greatfully received.Hi
I use this method to find objects in an ArrayCollection, you could probably modify accordingly.
public function findObjInArry(arryRef:ArrayCollection, objId:int):Object
if(arryRef.length == 0)
return null;
for(var i:int=0; i<arryRef.length; i++)
var arryObj:Obejct = arryRef.getItemAt(i) as Object;
if(objId == arryObj.id)
return arryObj;
return null;
Regarding adding items to ArrayCollection you can use the addItem methods. -
How to loop through a KM Folder ?
Hi ....can someone please let me know how to loop through a KM Folder having many documents , files etc .
Waiting for replies !!
Regards
SmitaHi Smita
Here is the code:
String rLocationtest = "/documents/Folder1";
IResourceContext c = ResourceFactory.getInstance().getServiceContext("cmadmin_service");
ICollection collection = (ICollection)ResourceFactory.getInstance().getResource(RID.getRID(rLocationtest),c);
loopFolder(collection,c);
public void loopFolder(ICollection collection, IResourceContext c){
try{
IResourceList resList = collection.getChildren();
IResourceListIterator resItr = resList.listIterator();
while(resItr.hasNext()){
IResource restemp = resItr.next();
if(restemp.isCollection() && LinkType.NONE.equals(restemp.getLinkType())){
loopFolder((ICollection)restemp,c);
//If the restemp is not a collection, it is a resource.
//Do the resource related operations here.
}// End of while
}catch(Exception e){
e.printStackTrace();
}//End of loopFolder
Hope it helps
Thanks
Deepak -
Loop through all layers and sublayers
is there a way that I can loop through all layers and sublayers looking for a name of a layer? I have one that loops through only top level layers. I am thinking I have to somehow incorperate all pathItems, groupItems and the like to incorperate all types of "layers" there might be, since a group is technically not a layer but a groupItem.
this is what I am doing so far:
for (var i = 0; i < numberOfLayers; i++) {
var customName = "div structure";
var myLayer = app.activeDocument.layers[i];
var myLayer = myLayer.name;
alert(myLayer);
//alert (myLayer);
if (customName == myLayer) {
alert("layer matches");
else { break; }
any ideas?Sorry I don't understand what it is you are trying to achieve… Most collections offer a getByName() method if you know what you are looking for eg…
doc.layers.getByName( 'fluff' );
This should return you the first found or error so you need to try & catch when using this… -
Simplest way to loop through a HashMap?
Hi everyone,
I'm a beginner at JSP, so please excuse my ignorance...
I have a HashMap in which I need to loop through and print every "key" and associated "value".
Doing research, I have come across multiple examples, but they all seem (to me) rather complex for something I think should be simple.
Here is some code I have now. C_TITLE is a HashMap. My question is, is there an easier way to do this where I don't have to invoke a subclass? Or is this as simple and easy as it can get?
Thanks!
if (C_TITLE.size() > 0) { //only loop if there are items in this hashmap
for (Iterator i=C_TITLE.entrySet().iterator(); i.hasNext(); ) {
Map.Entry mapentry = (Map.Entry) i.next();
out.print (mapentry.getKey() + "|");
out.print (mapentry.getValue() + "<BR>\n");
}Iteratir iter = C_TITLE.keySet().iterator();
while(iter.hasNext()) //or your for as well
Object key = iter.next();
Object value = C_TITLE.get(key);
}With J2SDK 1.5 there is new for loop to iterate through collections.
This will make Iterators almost unusable. -
Looping through a list with an iterator
Hi I have a list of objects allCrecords which I want to loop through using an iterator In the method printcoauthors I have to create another instance of class Extractdata because that's where the objects are added to the list allCrecords. The getauthor, getcoauthor and gettitle are methods in the Coauthorship class where this method printcoauthors is also
public void printcoauthors(String currentauthor){
Extractdata ed = new Extractdata();
for(Iterator it = ed.allCrecords.iterator();it.hasNext();){
if(currentauthor.equals(getauthor()))
System.out.println(getcoauthor());
else if (currentauthor.equals(getcoauthor()))
System.out.println(getauthor());
System.out.println(gettitle());
Object element = (Object)it.next();
}thanks in advanceHere's the extractdata class it takes data from an xml file and stores it as strings or lists or arrays
public class Extractdata {
public String name1, name2, TITLE;
SNAnalyser sn = new SNAnalyser();
Document doc = sn.extractDoc();
public List allCrecords = new ArrayList();
/** Creates a new instance of extractdata */
public Extractdata(){
public void extract(){
List allauthors = new ArrayList();
allauthors = Collections.synchronizedList(new ArrayList(allauthors));
allCrecords = Collections.synchronizedList(new ArrayList(allCrecords));
List alltitles = new ArrayList();
alltitles = Collections.synchronizedList(new ArrayList(alltitles));
String[] names = new String[20];
NodeList records1 = doc.getElementsByTagName("record");
for( int i = 0; i < records1.getLength();i++)
Record records = null;
Element record = (Element) records1.item(i);
NodeList headers = record.getElementsByTagName("header");
Element header = (Element) headers.item(0);
NodeList ids = header.getElementsByTagName("identifier");
Element id = (Element) ids.item(0);
String ID = getText(id);
NodeList metadatas = record.getElementsByTagName("metadata");
Element metadata = (Element) metadatas.item(0);
NodeList citeseers = metadata.getElementsByTagName("oai_citeseer:oai_citeseer");
Element citeseer = (Element) citeseers.item(0);
NodeList titles = citeseer.getElementsByTagName("dc:title");
Element title = (Element) titles.item(0);
TITLE = getText(title);
NodeList subjects = citeseer.getElementsByTagName("dc:subject");
Element subject = (Element) subjects.item(0);
String SUBJECT = getText(subject);
NodeList descriptions = citeseer.getElementsByTagName("dc:description");
Element description = (Element) descriptions.item(0);
String DESCRIPTION = getText(description);
//Writing data to class Record
Record r = new Record(ID, TITLE, allauthors);
//Write to text files
writeTo(DESCRIPTION,SUBJECT, i);
//Extract attributes authorname(s) from xml file
NodeList authors = citeseer.getElementsByTagName("oai_citeseer:author");
for(int l = 0; l < authors.getLength(); l++){
Element author = (Element) authors.item(l);
names[l] = author.getAttribute("name");
allauthors.add(names[l]);
//Checks if the document was cowritten
if(authors.getLength() > 0)
for(int z = 0; z < authors.getLength(); z++){
//Begin with the second author so not to include the author in the list of coauthors
for(int w = 1; w < authors.getLength(); w++){
//Ensures that the author is not counted as a co-author
if(z != w){
name1 = names[z];
name2 = names[w];
//Creates a new instance of Coauthorship
Coauthorship c = new Coauthorship(name1, name2, TITLE);
allCrecords.add(c);
public void printallCrecords(){
Iterator iter = allCrecords.iterator();
while(iter.hasNext())
System.out.println(iter.next());
public String getname1() {
return name1;
public String getname2() {
return name2;
public String getTITLE() {
return TITLE;
public void writeTo(String DESCRIPTION, String SUBJECT, int i){
try{
//Write to text files
String testing = "test.txt";
File dir = new File ("Description/" + i);
dir.mkdirs();
File file = new File(dir, testing);
FileOutputStream fout = new FileOutputStream(file);
Writer out = new OutputStreamWriter(fout, "UTF-8");
out = new BufferedWriter(out);
out.write(SUBJECT);
out.write(" ");
out.write(DESCRIPTION);
out.flush();
out.close();
catch (IOException e) {
System.out.println(
"Due to an IOException, the parser could not check citeseer.xml");
public String getText(Node node) {
// We need to retrieve the text from elements, entity
// references, CDATA sections, and text nodes; but not
// comments or processing instructions
int type = node.getNodeType();
if (type == Node.COMMENT_NODE
|| type == Node.PROCESSING_INSTRUCTION_NODE) {
return "";
StringBuffer text = new StringBuffer();
String value = node.getNodeValue();
if (value != null) text.append(value);
if (node.hasChildNodes()) {
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
text.append(getText(child));
return text.toString();
}
Maybe you are looking for
-
Text caption to disapear when press play
I have a video fil on the slide, we want a text box/caption to tell the user press play button(on video) to start it and the text caption fade out when U have pressed play, not automatic fade in and fade out. Is that possible?
-
How to find which sequence name is used in a table - Redux
(The other thread was locked before I could respond, so I'm posting this here as a non-question.) Beginning with 12c, there is now a way to associate a sequence with a table. It's a new feature called an Identity column. create table t (some_id numb
-
Change the quanity in the billing document in Background.
Hi, I created a Billing docuemnt in VF01, I am having a transactyion in which all the Item quantities in the Billing docuent are shown, If the user changes the Item quantity I want to change the same billing document. Is the scenario possible? Regard
-
HI Gurus DB bank requires a scenario in a payment file, whereby if If an IBAN exists in the Vendor master record then they want to show that per below: <Cdtr Acct> ID IBAN xxxxxxxxxx ID </Cdtr Acct> If however
-
Left & Right audio channels not linked...
I upgraded my system and had to re-install FCE from scratch and (of course) I lost all my system preferences and filters & such. My one annoyance now is that my audio channels (L & R) are now independant of one another -- if I lower one, the other re