How use c:forEach to loop over a String[][]
Hello,
Is there anyone that can tell me how to use the c:forEach tag to loop over a double String[][]? I can find examples for resultsets etc....but whatever I try with my String[][], I never can get the results on the screen.
Thanx,
debeumers
You need to set up a double c:forEach loop.
ie
<%
// initialisation of string[][]
String[][] sValues = new String[5][5];
for (int i=0; i<sValues.length; i++){
for (int j=0; j<sValues.length; j++){
sValues[i][j] = "" + (i + j);
pageContext.setAttribute("arrayValues", sValues);
%>
// And now to test print out the values
<c:forEach var="row" items="${arrayValues}">
<c:forEach var="col" items="${row}">
<c:out value="${col}"/>
</c:forEach>
<br>
</c:forEach>
Hope this helps
Cheers, evnafets
Similar Messages
-
How to break foreach inner loop in the jstl tags
break a inner foreach loop in jstl
Unfortunately you can't. You have to design a break yourself - like set an extra condition based on a boolean.
-
Looping over a TreeMap with for|foreach
I am a student programmer and am impressed how the APIs for the different collections are very similar if not completely identical.
I used treemap.keySet() to loop over TreeMap<String, MyVeryOwnClass> successfully with a while loop. But it seems impossible to do the same with the newish for-each loop. Or have I missed the point somewhere?
Regards,
HedleyOkay, I've got the for/each loop working its way through my Applicant TreeMap as follows:
public String findApprovedApplcnt()
String applicantKey = "";
for (Map.Entry<String, Applicant> entry : applicantList.entrySet())
Applicant applicant = entry.getValue();
boolean approved = applicant.isApproved();
if (approved);
applicantKey = applicant.getApplcntKey();
// The String key is hashed and stored in an instance variable when object created.
// It is subsequently retrieved and used when the object is added to the tree map.
break;
return applicantKey;
} // findApprovedApplcnt(..)In the Applicant class is the flag 'private boolean approved = false;' (initially), accessed by the method .isApproved(). What the loop is supposed to do is examine each Applicant object applicant in turn, skip over those where approved = false, and grab the key of the first applicant where approved = true, then break out of the loop and return the key.
Trouble is, it is grabbing the key of the first applicant it encounters regardless of whether approved is either true or false! I have gone nuts over this, stepping through in the debugger, inserting println statements to check the value of approved when it is retrieved, attempting to desk check, etc.
So what is the obvious error to which I am completely blind?
Regards,
Sleepless in Melbourne -
Value Mapping: how to loop over a nested context in a adv. user function
Hello,
i have the following source structure:
<rec> (1:1)
<field1>aaa</field1> (1:1)
<field2>bbb</field2> (1:1)
<b><struc> <u>(1:unbounded)</u>
<name>myName</name>
<value>myValue</value>
</struc></b>
</rec>
Destination structure:
<rec> (1:1)
<field1>aaa</field1> (1:1)
<field2>bbb</field2> (1:1)
<b><field3>bbb</field2> (1:1)</b>
</rec>
In order to fill the destination field3 i have to loop over the input-structure struc.
My problem is, that i don't know how to get access to the name/value pair with a
extended user-defined function. Since each occurrence in struc i not a simple string but consists of 2 fields, i guess it is not enough simply to loop over input String Array.
Please help.just like u have a loop stmt in java prgm. a simple code:
Here a and b are the strings that comes to the udf
for(int i=0;i<a.length;i++)
boolean found = false;
int j = 0;
for(j=0;j<b.length;j++)
if (a<i>.equals(b[j]))
found = true;
break;
if (found == true)
result.addValue(c[j]);
else
result.addValue("");
Message was edited by:
Prabhu S -
Hello,
Can someone please demonstrate how I would use a cfLoop to
loop over and output the contents of this fictious nested
structure?
Thank You!mletson wrote:
> I figured it out. If anyone has a better solution,
please let me know.
>
> <cfloop from="1" to="#structCount(student)#"
index="x">
>
> <cfset variables.studentID = "student00" & x>
>
> <tr>
>
<td><cfoutput>#student[studentID]["firstName"]#</cfoutput></td>
>
<td><cfoutput>#student[studentID]["lastName"]#</cfoutput></td>
>
<td><cfoutput>#student[studentID]["phone"]#</cfoutput></td>
> </tr>
>
> </cfloop>
>
A slightly simpler version using the structure form of the
<cfloop...>
tag. It also demonstrates both array notation, that you used,
as well
as dot notation. Finally it puts a single <cfoutput...>
block around
the entire loop. This can provide a small but accumulative
performance
improvement.
<cfoutput>
<cfloop collection="#student#" item="aStudent">
<tr>
<td>#aStudent["firstName"]# OR
#aStudent.firstName#</td>
<td>#aStudent["lastName"]# OR
#aStudent.lastName#</td>
<td>#aStudent["phone"]# OR #aStudent.phone#</td>
</tr>
</cfloop>
</cfoutput> -
I know I've REALLY struggled with this before. I just don't understand why this has to be soooooo difficult.
I can very easily do a straight Data Pump of a .xlsX File into a SQL Server Table using a normal Excel Connection and a normal Excel Source...simply converting Unicode to DT_STR and then using an OLE DB Destination of the SQL Server Table.
If I want to make the SSIS Package a little more flexible by allowing multiple .xlsX spreadsheets to be pumped in by using a Foreach Loop Container, the whole SSIS Package seems to go to hell in a hand basket. I simply do the following...
Put the Data Flow Task within the Foreach Loop Container
Add the Variable Mapping Variable User::FilePath that I defined as a Variable and a string within the FOreach Loop Container
I change the Excel Connection and its Expression to be ExcelFilePath ==> @[User::FilePath]
I then try and change the Excel Source and its Data Access Mode to Table Name or view name variable and provide the Variable Name User::FilePath
And that's when I run into trouble...
Exception from HRESULT: 0xC02020E8
Error at Data Flow Task [Excel Source [56]]:SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occured. Error code: 0x80004005.
Error at Data Flow Task [Excel Source [56]]: Opening a rowset for "...(the EXACT Path and .xlsx File Name)...". Check that the object exists in the database. (And I know it's there!!!)
I don't understand by adding a Foreach Loop Container to try and make this as efficient as possible has caused such an error unless I'm overlooking something. I have even tried delaying my validations and that doesn't seem to help.
I have looked hard in Google and even YouTube to try and find a solution for this but for the life of me I cannot seem to find anything on pumping a .xlsX file into SQL Server using a Foreach Loop Container.
Can ANYONE please help me out here? I'm at the end of my rope trying to get this to work. I think the last time I was in this quandry, trying to pump a .xlsX File into a SQL Server Table using a Foreach Loop Container in SSIS, I actually wrote a C# Script
to write the contents of the .xlsX File into a .csv File and then Actually used the .csv File to pump the data into a SQL Server Table.
Thanks for your review and am hoping and praying for a reply and solution.Hi ITBobbyP,
If I understand correctly, you want to load data from multiple sheets in an .xlsx file into a SQL Server table.
If in this scenario, please refer to the following tips:
The Foreach Loop container should be configured as shown below:
Enumerator: Foreach ADO.NET Schema Rowset Enumerator
Connection String: The OLE DB Connection String for the excel file.
Schema: Tables.
In the Variable Mapping, map the variable to Sheet_Name, and change the Index from 0 to 2.
The connection string for Excel Connection Manager is the original one, we needn’t make any change.
Change Table Name or View name to the variable Sheet_Name.
If you want to load data from multiple sheets in multiple .xlsx files into a SQL Server table, please refer to following thread:
http://stackoverflow.com/questions/7411741/how-to-loop-through-excel-files-and-load-them-into-a-database-using-ssis-package
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
How can you see the progress when using a ForEach loop?
Hi,
I have an array with about 100 containers in it. My main thread uses a ForEach loop with an inner case structure with six possibilities. My previous program had all the steps in a very long list, executing them one by one. I find this new approach is much nicer to look at, and easier to change, but there isn't really any way of telling how far along the test is (unless you know it by heart). In the long list approach, you could see all the Done/Passed outcomes and how many remained, now there is no way of telling.
Any tips on making some kind of progress indication?
Solved!
Go to Solution.As ObjectReference parameter, you should use 'Nothing'. The last parameter (synchronuous?) you can choose true or false. Please refer to the documentation of PostUIMessageEx for further information.
The numeric parameter should range between 0-100. Since it is "Progress Percent", this makes sense, does it?
The status bar has several panes, one e.g. displaying the logged in user or the used process model. The pane on the right most side will display the Progress Percent if used in your sequence.
The default reporting, as already stated, includes this feature. So if you have a sequence with e.g. 500 steps, the reporting "will have a visible progress" in that pane (with less than 100 steps, it is most often too fast to see). Remember that NI Sequence Editor and the Full Featured User Interfaces do have this feature, the Simple UI does not have it.
Norbert
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it. -
I have this code:
if (s == "file")
file = false;
for (int i = 0; i < treeViewMS1.SelectedNodes.Count; i++)
DeleteFile(treeViewMS1.SelectedNode.FullPath, file);
I know it's a file and it is working if it's a single file.
On the treeView i click on a file right click in the menu i select delete and it's doing the line:
DeleteFile(treeViewMS1.SelectedNode.FullPath, file);
And it's working no problems.
But i want to do that if i selected some files togeather multiple selection then to delete each file.
So i added the FOR loop but then how do i delete from the SelectedNodes each node ?
The treeView SelectedNodes dosen't have FullPath like SelectedNode also doing SelectedNodes[i] dosen't have the FullPath property.
Same as for if i want to delete a single directory or multiple selected directories:
This is the continue of the code if it"s not a "file" (else) it's null i know it's a directory and doing:
else
file = true;
RemoveDirectoriesRecursive(treeViewMS1.SelectedNode, treeViewMS1.SelectedNode.FullPath);
Also here i'm using SelectedNode but if i marked multiple directories then i how do i loop over the SelectedNodes and send each SelectedNode to the RemoveDirectoriesRecrusive method ?
My problem is how to loop over SelectedNode(multiple selection of files/directories) and send each selected file/directory to it's method like i'm doing now ?foreach (TreeNode n in treeViewMS1.SelectedNodes)
// Remove everything associated with TreeNode n here
I don't think it's any harder than that, is it?
If you can multi-select both an item and one of its descendents in the tree, then you'll have the situation that you may have deleted the parent folder and all of its children by the time you get around to deleting the descendent. But that's not such
a big deal. A file can get deleted externally to your program too - so you'll just have to deal with it having been deleted already (or externally) when you get around to deleting it yourself. -
Hello,
I have a foreach loop in SSIS (as part of Visual Studio 10 and with SQL Server 2012).
It loops over all files in a folder (ForEach File Enumerator).
I set the folder: OK
Traverse Sub folders: OK
I have set up a Variable in Variable Mappings called FileName so it shows User::FileName: OK
Index of variable is 0: OK
It almost works ok. Except that the first file it finds is never considered.
I set a breakpoint then and the first file it finds, is shown in black in the watch variable window. All subsequent files found are shown in red font. When I change the names of the files so another file is the first file found then it skips the other one
which now is the first file.
What is going on here? Why does SSIS skip the first file it finds in a foreach file loop?
Any suggestions highly appreciated.
Thank you
Andi
Andreas"red font - interesting, any example to show us (image)
It would be interesting to share with us whether you use any file masks or expressions.
Arthur
MyBlog
Twitter
It appears a variable value turns red when it changes between breakpoints. It started black for the first value (the first file, obtained BEFORE the execution reached the breakpoint), and then turned red. I was able to reproduce this behavior on a test environment.
However, it did not skip any files.
OP, please set up the test shown in the image below. Create a breakpoint in the sequence container for the "OnPreExecute" event. -
How to stop after first loop operation over?
Hi friends.
How to stop after first loop operation over?
I have a loop operation in module pool program.
After first loop over I want to stop.
I used the STOP keyword, but it is going to dump.
Thanking you.
Regards,
SubashHey,
The statement STOP is forbidden in methods and, since release 6.10, leads to an uncatchable expection during the processing of screens called with CALL SCREEN...
As they said above, use a EXIT statement to fix this DUMP...
Regards,
Diogo Carvalho -
Loop over hashMap (c:forEach for JSF)
Hi,
is there anything like c:forEach for JSF?
i need to loop over a hashmap.
i cant use jstl cause ive to use the jsf taglib inside the loop.
thanks,
sebThe h:dataTable can iterate over maps. Tomahawk's t:dataList is an option if you rather want lists instead of tables.
Accessing a map in EL isn't that hard:"#{myBean.map.key}"resolves tomyBean.getMap().get("key"); -
I just bought a new MacBook Air. In my old one, I could go from screen to screen by using three fingers to swipe over the key pad. This one just sits there. It is Yosemite. How do I set up preferences so I can use three fingers to move from screen to screen?
Those choices are controlled via System Preferences, Trackpad.
-
When I used to move the cursor over a link, it would display the address of the link in the lower left hand corner before I clicked on it. This has disappeared, how do I turn it back on?
== This happened ==
Not sure how often
== A few months agoView > Statusbar
-
How to stop a while loop after certain time using Elapsed time vi
how to stop a while loop after certain time using Elapsed time vi.
Hi Frankie,
Just place the Elapsed Time VI inside the WHILE loop, and wire the 'Time Has Elapsed' output to the conditional terminal in the lower right corner (which should be set to 'stop if true' by default).
In the future, please post your LabVIEW questions to the LabVIEW Forum. You have a much better chance of getting your questions answered sooner, and those answers can then help others who are searching the LabVIEW forums. Thanks!
Justin M
National Instruments -
I am on a plan with a basic phone that is breaking. I was given a smartphone that belonged to a relative that is now deceased, (they used the phone since they have passed it is deactivated.) how can I switch my phone over and is there anyway to avoid a data package/plan?
What is your current plan? In some cases it can be cheaper to move to a More Everything plan with an out of contract line. With More Everything, you will get a $15 per month reduction in line fee with a minimal data.
Maybe you are looking for
-
Diff b/w infosource and data source
hai all can any one tell me abt the difference b/w infosource and datasource in b.w?.and also abt the infopackage and how the later relates with the former?. thanxs sri
-
LaserJet Pro 200 color MFP M276 nw
I am able to print, copy, scan I CAN SEND A FAX however I CANNOT RECEIVE A FAX
-
Dear All During Posting Goods Receipt, Systems showing error msg " Account determination for entry INT BSX_____ ______ 3000 not possible, so i used TCode OBYC and OMWD for account determination, but it again showing same error msg, How
-
Secure wireless on existing network
My boss wants to provide internet wireless capability to service customers while they are waiting. We have a small LAN with forty workstations and only one port on our router to the outside. I am worried about security. I was thinking of putting a wi
-
Hi All..... Something very funny I am experiencing.....Funny because may be I am not aware of this.....Please help... I created a Table Maintenance Generator for one of my Customized table, saving it under my Z Package and Function Group. When this R