How to use setPropertyActionListener in a c:forEach loop?
Hi, I have the following code, when click "Edit", it'll generate a null pointer exception, looks like "item" was never registered in the backing bean via setPropertyActionListener:
//List<Menu>menus
<c:forEach items="${menus}" var="menu">
<p class="formTitle">${menu.type}:</p>
<table class="displayData">
<c:forEach items="${menu.items}" var="item">
<tr>
<td class="leftCol">${item.name}</td>
<td class="rightCol">
<h:commandLink value="Edit" action="#{backingBean.editRow_click}">
<f:setPropertyActionListener target="#{backingBean.item}" value="#{item}"/>
</h:commandLink>
</td>
</tr>
</c:forEach>
</table>
</c:forEach>in the backing bean, i have:
private Item item;
//getter - setter
public void editRow_click(){
System.out.println("edit row click: "+ this.getItem().getName()); <-- _null pointer exception because item is null, and was not set via setPropertyActionListener_
}Menu class
private String type;
List<Item> items
(and other properties...)
//getter setter//Item class
private String name;
(and other properties...)
//getter setter//
hi, i just try my code again this morning, and noticed i can get setPropertyActionListener to work if i pass String instead of a "Item" object under target attribute. however, the value attribute won't take an expression.... it seems like i can only pass a literal string???
this work...
menuItem are now type String instead of type Item,
<c:forEach items="${sessionScope.ServiceManager.menus}" var="menu">
<p class="formTitle">${menu.stapleType}:</p>
<table class="displayData">
<c:forEach items="${menu.items}" var="item">
<tr>
<td class="leftCol">${item.name} ($${item.price})</td>
<td class="rightCol">
<h:commandLink value="Edit" action="#{menuBean.editRow_click}">
<f:setPropertyActionListener target="#{menuBean.menuItem}" value="lalala"/>
</h:commandLink>
</td>
</tr>
</c:forEach>
</table>
</c:forEach>when clicking the edit link, i'll get "lalala"
public void editRow_click(){
System.out.println("edit row click: "+ this.getMenuItem());
}if i switch to expression, this won't work:
<f:setPropertyActionListener target="#{menuBean.menuItem}" value="#{item.id}"/>when click edit link, i'll get a empty string
if i switch to jstl expression, this will cause run time error:
<f:setPropertyActionListener target="#{menuBean.menuItem}" value="${item.id}"/>
org.apache.jasper.JasperException: /WEB-INF/formDataView/menu_view.jsp(15,4) According to TLD or attribute directive in tag file, attribute value does not accept any expressions
Similar Messages
-
How to use the select statement in for loop
Hi All,
my question is can we use select statement in for loop like as follows .
for key in select key from one_table.
when i am using this am getting an error like Found select invalid i identifier
how to make use of select statement in for loop
please suggest me .
Thanks
SreeSQL>set serveroutput on;
SQL> DECLARE
BEGIN
FOR Cur_Rec IN (SELECT dname FROM dept) LOOP
DBMS_OUTPUT.PUT_LINE(Cur_Rec.dname);
END LOOP;
END;
SQL>
ACCOUNTING
RESEARCH
SALES
OPERATIONSAs per your requirement always filter the Query beforehand
Like
FOR Cur_Rec IN (SELECT key FROM <table> WHERE key=1) LOOP
END LOOP;Edited by: Lokanath Giri on १ दिसंबर, २०११ ३:५६ अपराह्न -
HOW TO USE ATTRIBUTE VALUE IN FOX FORMULA LOOP
HI,
IAM SUMMING UP AMOUNT BASED ON BELOW COMBINATION AND THROWING MESSAGE IF AMOUNT IS EXCEEDING OPENPO VALUE....AND IS WORKING FINE...NOW I HAVE A ENHANCE MENT THAT I HAVE TO USE ATTRIBUTE PROFIT CENTER VALUE IN THE LOOP. I HAVE DECLARED THIS --- PC = ATRV('0PROFIT_CTR',CC,CA). AND TRY TO USE PC IN LOOP..BUT SYSTEM PROPOSING PC SHOULD BE FIELD TO BE CHANGED..BUT IN MY CASE IT IS ATTRIBUTE WHICH WILL DISPLAY IN LAYOUT...AND FIRST LOOP SHOULD HAPPEN BASED ON PC ( FOREACH CCODE,FP,CR,CA,GL,PO,PC.)....PLEASE PROVIDE UR HELP.
DATA SUM1 TYPE F.
DATA SUM TYPE F.
DATA PO TYPE EBELN1.
DATA GL TYPE 0GL_ACCOUNT.
DATA CC TYPE 0COSTCENTER.
DATA VN TYPE 0VENDOR.
DATA SN TYPE SCRNUM1.
DATA SD TYPE SCRDATE.
DATA VS TYPE KDATB.
DATA VE TYPE KDATE.
DATA CCODE TYPE 0COMP_CODE.
DATA CA TYPE 0CO_AREA.
DATA FP TYPE 0FISCPER.
DATA CR TYPE XPRV_CIR.
DATA PC TYPE 0PROFIT_CTR.
CCODE = VARV('XCOMPCO').
CA = VARV('XCOAREA').
FP = VARV('XPERIOD').
CR = VARV('XPRVCIRC').
PC = ATRV('0PROFIT_CTR',CC,CA).
FOREACH CCODE,FP,CR,CA,GL,PO,PC.
SUM = 0.
FOREACH CC,VN,SN,SD,VS,VE.
IF {0AMOUNT,CCODE,CC,CA,FP,GL,PC,VN,PO,VS,VE,SD,SN,CR}
{OPENPOVAL,CCODE,CC,CA,FP,GL,PC,VN,PO,VS,VE,SD,SN,CR}.MESSAGE E001(UPF)WITH
'PROVISION AMOUNT SHOULD BE LESS THAN OPENPOVALUE'.
ELSE.
SUM = SUM +
{0AMOUNT,CCODE,CC,CA,FP,GL,PC,VN,PO,VS,VE,SD,SN,CR}.
ENDIF.
ENDFOR.
FOREACH CC,VN,SN,SD,VS,VE.
IF {0AMOUNT,CCODE,CC,CA,FP,GL,PC,VN,PO,VS,VE,SD,SN,CR} = 0
AND
{OPENPOVAL,CCODE,CC,CA,FP,GL,PC,VN,PO,VS,VE,SD,SN,CR} = 0.
SUM1 = 0.
ELSE.
SUM1 = SUM.
ENDIF.
IF SUM1 >
{OPENPOVAL,CCODE,CC,CA,FP,GL,PC,VN,PO,VS,VE,SD,SN,CR}.
MESSAGE E001(UPF)WITH
'PROVISION AMOUNT(SUM) SHOULD BE LESS THAN OPENPOVALUE'.
ENDIF.
ENDFOR.
ENDFOR.
THANKS,
RAJAHi,
If you want to read the value of profit center using keyword ATRV then you need to input values of parameters CC and CA.
Now the first line that you have written, to derive PC based on CC and CA
PC = ATRV('0PROFIT_CTR',CC,CA).
[code}
here CC value is not determined at runtime ; I mean what will be the value of CC when this line is executed. This line is not inside any foreach loop nor you are reading the value of CC using any variable.
if you want to use PC in first FOREACH CCODE,FP,CR,CA,GL,PO,PC. loop then CC value have to be present.
Put ATRV code inside a loop where CC and CA values are read.
Thanks
Pratyush -
How to use no of iteration of for loop as the input for the for loop
hi all,
i wanna need some help here..
i'm using for loop to iterate to ceratin no of iteration.. then, i would like to use back the no of iteration as the input of 'N' for the next iteration..
in other word, eg:
1st run:
i insert a control to 'N', let say 80
then the iteration run until 80-1 = 79..
2nd run:
i need to insert the no of "N", let say a control of 120.. i want the loop run for "120 - 79", where the 79 is the no of previous run..
easy to say,
how can i connect the "i' as a control to ''N''
n how to make a "run' or ' GO' and ''stop'' button in the front panel and block diagram after the first run without using the stop and run from the labview window
thanks..Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
Attachments:
Untitled 2.vi 9 KB -
How to use String Tokeniser inside this for loop?
[i][i]hi there..
i am reading all the file inside a directory and get the latest modified file than i have to tokenise it and juz read the number. For example my file name that is last modified will be abc_123.txt but i just want it to appear 123.
i manage to do it separately how can i put the tokeniser inside my for loop?
my directory
for (int i = 0; i < files.length; i++)
if(files[i].isFile())
if(lastModifiedFile == null){
lastModifiedFile = files[i];
String mylastModifiedFile = lastModifiedFile.toString();
StringTokenizer tokens = new StringTokenizer (mylastModifiedFile,".");
String modified = tokens.nextToken().substring(modified.length-4);*/
if(lastModifiedFile != null)
if(lastModifiedFile.lastModified() < files[i].lastModified())
lastModifiedFile = files[i];
my tokeniser is this
String mylastModifiedFile = lastModifiedFile.toString();
StringTokenizer tokens = new StringTokenizer (mylastModifiedFile,".");
String modified = tokens.nextToken().substring(modified.length-4);*/
}[i][i][i]hi there..
i am reading all the file inside a directory and get ...
tokens.nextToken().substring(modified.length-4);*/
}[/i][i][/i][/i][/i]Is there some reason for this baroque formatting? Please use the
code tags as explained in one of your other threads on this topic:
http://forum.java.sun.com/thread.jspa?threadID=793441&messageID=4510858#4510858 -
How to set multiple file extension in ForEach Loop Component.
I want to enumerate all *.xls and *.xlsx file. How to fill the Files box?
This is correct, even after you have enumerated over the marked (xls and xlsx files) how do you intend to process these files. What are the subsequent tasks in the for each loop?
Please vote as helpful or mark as answer, if it helps
Cheers, Raunak | t: @raunakjhawar |
My Blog
can the excel data provider process both xlsx and xls file?
is there any way to process both xlsx and xls file in dataflow? -
Characteristics Combinations at FOREACH loops
Hi experts,
I can not use some characteristics combinations at FOREACH loops.
Sample situation is below ;
Planning area is multiple planning area.However, at this situation i gather data from just one cube, not another cubes.
*There is data at below combination in the related cube.
0FISCPER3 (Posting Period)
0FISCYEAR (Posting year)
ZVKBUR (Organizational Unit)
ZVKGRP (Sales Office)
ZMATNR (material number)
ZSS(Sales responsible)
and some other fields.
At first planning level selected characteristics are ;
0FISCPER3 (Posting Period)
0FISCYEAR (Posting year)
ZVKBUR (Organizational Unit)
ZVKGRP (Sales Office)
ZMATNR (material number)
at selection tab, a variable is used for ZVKGRP.
when i use this combination at foreach loop i can see data at lt_cur001 internal table during debugging.
At second planning level selected characteristics are ;
0FISCPER3 (Posting Period)
0FISCYEAR (Posting year)
ZVKBUR (Organizational Unit)
ZVKGRP (Sales Office)
ZSS(Sales responsible)
at selection tab, a variable is used for ZSS.
when i use this combination at foreach loop i can see data at lt_cur001 internal table during debugging.
However, at third combination i can not see any data at ZMATNR field.
0FISCPER3 (Posting Period)
0FISCYEAR (Posting year)
ZVKBUR (Organizational Unit)
ZVKGRP (Sales Office)
ZSS(Sales responsible)
ZMATNR (Material Number)
at selection tab, a variable is used for ZSS.And i added '#' into this variable's values.
when i use this combination at a foreach i cannot see any data at lt_cur001-zmatnr field of internal table during debugging.
What do you recommend me to read data at above combination from this cube?
Best Regards,
KevserThere is transactional data like below combination in my cube :
0fiscyear = 2007
0fiscper3 = 001
zvkbur = 1031
zvkgrp = 101
zmatnr = 000000000000150008
zss = 31301003
and the value 31301003 for ZSS exists within the values of variable ZSS.
Kevser -
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. -
How to use one dynamic connection managers for multiple parallel data flow tasks
hi there:
I have 6 databases residing on the same server. What I want to do is call a store procedure with identical name on each database dbo schema and transport results to a centralized place. The key is to have those SPs run in parallel instead
of in sequence as each SP may take around 10 mins to finish.
The simplest way is to create 6 OLE DB connection managers and create 6 DFT tasks. However, I do not want to maintain 6 OLE DB connection managers as there is a chance to have more connection managers.
What I did so far is to create a OLD DB connection manager and use expression to set up connectionString properties so that it will get populated by variables at run time. It is fine when running all SPs in a Foreach Loop Container. However, it takes
around 60 mins to finish.
When I try to run it in parallel ( basically created 6 DFTs but use only one Dynamic Connection Manager), the connection string gets confused therefore all DFT tasks failed.
Does anyone here have some experience on this topic?
Thanks
hui
--Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --Yes, basically, on the connectionString property of ONE OLEDB, you are using an expression to supply value and this expression is pointing to a variable.
In this case , you can update this variable from a table which contains many connection strings. It's good if you want to execute Store procedures in a sequential order. When in parallel mode, this will cause issues as connectionString gets overwritten.
I am thinking about using script task to exec sp.
The whole idea is that I do not want to maintain a large number of Connection Managers.
Hope it helps
--Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --
So you are not able to run parallel executions using same conn mgmr, even with dynamic connectionstring, is that correct? Yes, script task will be a way to go if you wish to execute it in parallel, you may connect to SS and query the proper conn string with
SELECT/WHERE clause in each script > pass it to a script variable > use that script variable and execute the proc. This will require only two things to change in each script, the WHERE condition to get the conn string and the proc name (you may even
get the proc names the same way you get conn string) and everything else will be same. Let us know how that goes.
Hope no two or more procs doing insert/update/delete on the same tables. -
How to use the .aliases file to resolve a host's address?
I am trying to setup a communication between a
RT PXI system and a windows computer using network shared variables
(shortened to "shared variables" in the further text). Both of the
computers shall run compiled executables. The documentation concerning
this topic has been spread over several places and this is what I ended
up with.
There are three different possible setups.
1.
I am using shared variable nodes both on the RT PXI and on the windows
computer. The shared variables on the RT PXI are defined as "target
absolute" and are residing in a library on the RT PXI. The shared
variables on the windows computer will be set to "target relative" and
are residing in a library on the windows computer. The variables used
on the windows computer will be bound to the corresponding variables on
the RT PXI. If I run the applications on computers different from the
ones I used during development, I have only to change the .aliases file
for the windows computer and set there the correct IP for the RT PXI.
Additionally,
I have to deploy the library both on the RT PXI and on the windows
computer. This can be done from the windows computer, as the RT PXI
target does not support the invoke node that has to be used for this
purpose. Running the invoke node twice, once for localhost with the
client library and once for the IP of the RT PXI system and the host
library, I can deploy the libraries containing the shared variables
programmatically. At this point, the magic of the .aliases file will
fail and I have to find the IP of the RT PXI either by user input or
maybe by running the RT ping controllers.vi. The "Target IPAddress"
property of the "Deploy Library" invoke node makes sense in this
combination as we can deploy libraries also to other computers or
platforms.
See attached Shared Setup 1.png.
2. I am
using shared variable nodes both on the RT PXI and on the
windows computer. The shared variables on the RT PXI are defined as
"target absolute" and are residing in a library on the RT PXI. The
shared variables on the windows computer will also be set to "target
absolute" and will be taken from the library that resides on the RT
PXI. If I run the applications on
computers different from the ones I used during development, I have
only to change the .aliases file for the windows computer and set there
the correct IP for the RT PXI.
Additionally, I have to deploy
the library only on the RT PXI. Again, this can done by a helper
application on windows when the IP of the RT PXI is known or found by
using RT ping controllers.vi.
See attached Shared Setup 2.png.
3. I am using
shared variable nodes only on the RT PXI. The shared variables on the
RT PXI are defined as
"target absolute" and are residing in a library on the RT PXI. On the
windows side, I use direct access to the PSP by using DataSocket
functions. I can address a variable by using a DataSocket Open function
and inputting psp://IP_or_Hostname_of_RT_PXI/LibraryName/VariableName.
The magic of the .aliases files will fail already at this step. So I
have to find the correct IP or hostname by user input, setting a DNS
server to point to the correct IP or using the RT ping controllers.vi.
As
always, I have to deploy the library containing the shared variables to
the RT PXI. Again, this can done by a helper application on windows
when the IP of
the RT PXI is known or found by using RT ping controllers.vi.
As
I can use this approach to setup an array of valid variable names and
process the array by one single DataSocket read function inside of a
for loop more conveniently than using a case selector inside of a
for-loop and reading from different shared variable nodes, I prefer
this approach over the others.
See attached Shared Setup 3.png.
For approaches 2 and 3, at least the deploy process can be run by an
installer application independently of the main application as the
library will remain on the PXI until I manually undeploy it, even if I
reboot the PXI controller.
My questions are:
1. Did I describe the possible setups regarding the use of the shared variables correctly?
2.
Is there any means to get the IP address mapping from the .aliases
file, needed for deploying and for approach 3, other than opening and
reading the file itself?
Attachments:
Shared Setup 3.png 52 KB
Shared Setup 1.png 42 KB
Shared Setup 2.png 51 KBThank you for the reply... I am using a hardcoded filename for the
connection manager. How do I take the variable and change the filename in the connection manager?
Also there will be multiple filename and I would like to take the latest file and not just check if the same file has been updated.
UPDATE: I added the dynamic filename to the expression of the connection
manager and it worked.
You can use Foreach loop with file enumerator for that. It will iterate through files in folder and you can retrieve filenames using a variable created. Then pass variable as a parameter to script task.
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to use an BPM Instance Variable in JSP page
Hi All,
I am using the JSP Presentation, but i don't know how to use an Instance variable in JSP page, that instance already declared in the process. And Can u explain the syntax that to include the JS file into jsp page
Regards
Vasu.
Edited by bpmvasu at 04/03/2007 10:43 PMHi Mariano,
I'm using JSP presentation too. In "Interactive Component Call" active i'm using "Use JSP presentation", but i only can define one instance variable, i need to add more instance variables. In "Advanced" option of this task, i have the argument mapping .. but i don't understand how to use it.
I have a instance variable called "genders" of the type String[Int] (Associative Array) and i'm mapping this instance variable in "Arguments Show In" option of the advanced option of JSP presentation. In JSP presentation i have the code:
<select <f:fieldName att="person.gender"/>>
<c:forEach var="gender" begin="0" items="${genders}" varStatus="status">
<c:choose>
<c:when test="${person.gender == gender}">
<option value="<c:out value="${gender}"/>" selected="true"><c:out value="${gender}"/></option>
</c:when>
<c:otherwise>
<option value="<c:out value="${gender}"/>"><c:out value="${gender}"/></option>
</c:otherwise>
</c:choose>
</c:forEach>
</select>And in my screenflow i have the code:
genders[0] = "Male"
genders[1] = "Female"But when i run my application, i have the error: "The task could not be successfully executed. Reason: 'java.lang.ClassCastException: java.lang.Integer'."
What's the problem? -
How to use For-Each Structure with Multiple node XML structure
Hi,
How to use for-each (BPEL 2.0) construct for Multinode XML structure.
Here is the easy case: I have list of suppliers specified by supplier
<supplierList>
<supplier>1</supplier>
<supplier>2</supplier>
<supplier>3</supplier>
</supplierList>
Now there is a web service http://hostname/getsupplierdetails/wsdl which accepts one supplier at a time.
like
<supplier>1</supplier>
reponse object is
<message> notfound/found </message>
But how can I use for each of XML node to call this service and collect the result like
<supplierList1>
<Suppinfo>
<supplier>1</supplier>
<message> not found</message>
</suppinfo>
<suppinfo>
<supplier>1</supplier>
<message> not found</message>
</suppinfo>
</supplierlist1>
ThanksFor looping you use foreach loop and , loop for the number of occurences and when constructing response, adding a new element you have to use bpelx:append. Good sample at Enterprise Integration: Oracle SOA Suite 11g: Populating a list or an array in BPEL without using XSLT.
-
Introduction
We need to loop through all the flat files that have the same structure in a folder and import all the data to a single SQL Server table. How can we obtain the total count of the rows inserted to the destination SQL Server table?
Solution
We can use Execute SQL Task or Script Task to aggregate the row count increment for each iteration of the Foreach Loop Container. The following steps are the preparations before we add the Execute SQL Task or Script Task:
Create a String type variable FilePath, two Int32 type variables InsertRowCnt and TotalRowCnt.
Drag a Foreach Loop Container to the Control Flow design surface, set the Enumerator to “Foreach File Enumerator”, specify the source folder and the files extension, and set the “Retrieve file name” option to “Fully qualified”.
On the “Variable Mappings” tab of the container, map the variable FilePath to the collection value.
Drag a Data Flow Task to the container, in the Data Flow Task, add a Flat File Source, a Row Count Transformation, and an OLE DB Destination, and join them. Create a Flat File Connection Manager to connect to one of the flat files, and then configure the
Flat File Source as well as the OLE DB Destination adapter. Set the variable for the Row Count Transformation to “User::InsertRowCnt”.
Open the Property Expressions Editor for the Flat File Connection Manager, and set the expression of “ConnectionString” property to
“@[User::FilePath]”.
(I) Execute SQL Task Method:
In the Control Flow, drag an Execute SQL Task under the Data Flow Task and join them.
Create one or using any one existing OLE DB Connection Manager for the Execute SQL Task, set the “ResultSet” option to “Single row”, and then set the “SQLStatement” property to:
DECLARE @InsertRowCnt INT,
@TotalRowCnt INT
SET @InsertRowCnt=?
SET @TotalRowCnt=?
SET @TotalRowCnt=@InsertRowCnt+@TotalRowCnt
SELECT TotalRowCnt=@TotalRowCnt
On to parameter 1.
On the “Result Set” tab of the Execute SQL Task, map result 0 to variable “User::TotalRowCnt”.
(II) Script Task Method:
In the Control Flow, drag a Script Task under the Data Flow Task and join them.
In the Script Task, select variable InsertRowCnt for “ReadOnlyVariables” option, and select variable TotalRowCnt for “ReadWriteVariables”.
Edit the Main method as follows (C#):
public void Main()
// TODO: Add your code here
int InsertRowCnt = Convert.ToInt32(Dts.Variables["User::InsertRowCnt"].Value.ToString()
int TotalRowCnt = Convert.ToInt32(Dts.Variables["User::TotalRowCnt"].Value.ToString());
TotalRowCnt = TotalRowCnt + InsertRowCnt;
Dts.Variables["User::InsertRowCnt"].Value = TotalRowCnt;
Dts.TaskResult = (int)ScriptResults.Success;
Or (VB)
Public Sub Main()
' Add your code here
Dim InsertRowCnt As Integer =
Convert.ToInt32(Dts.Variables("User::InsertRowCnt").Value.ToString())
Dim TotalRowCnt As Integer =
Convert.ToInt32(Dts.Variables("User::TotalRowCnt").Value.ToString())
TotalRowCnt = TotalRowCnt + InsertRowCnt
Dts.Variables("User::TotalRowCnt").Value = TotalRowCnt
Dts.TaskResult = ScriptResults.Success
End Sub
Applies to
Microsoft SQL Server 2005
Microsoft SQL Server 2008
Microsoft SQL Server 2008 R2
Microsoft SQL Server 2012
Microsoft SQL Server 2014
Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.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 to use logic:present tag in struts el tag
Hi
I am trying to use struts el tags in the jsp page.I am struggling with the following exception: Cannot find bean: "result" in any scope.I couldn't understand why this error is coming even i had the property "result" in my ActionForm.
ActionForm:
package com.finocus.cam.struts.bean;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import com.finocus.cam.common.ValidateFormat;
public class DetailsForm extends org.apache.struts.action.ActionForm {
private final static String LOG_TAG = DetailsForm.class.getName() + ".";
private static final long serialVersionUID = 1L;
// VARIABLES DECLARATION
private String name = null;
private String searchField = null;
private String searchCriteria = null;
private String phonenumber = "";
private String email = "";
private List results = null;
private String adminUserName = "";
private String adminUserEmail = "";
public DetailsForm() {
// GETTER AND SETTER METHODS
public String getName() {
return name;
public void setName(String name) {
this.name = name;
public String getSearchCriteria() {
return searchCriteria;
public void setSearchCriteria(String searchCriteria) {
this.searchCriteria = searchCriteria;
public String getSearchField() {
return searchField;
public void setSearchField(String searchField) {
this.searchField = searchField;
public String getEmail() {
return email;
public void setEmail(String email) {
this.email = email;
public List getResults() {
return results;
public void setResults(List results) {
this.results = results;
public String getPhonenumber() {
return phonenumber;
public void setPhonenumber(String phonenumber) {
this.phonenumber = phonenumber;
public String getAdminUserEmail() {
return adminUserEmail;
public void setAdminUserEmail(String adminUserEmail) {
this.adminUserEmail = adminUserEmail;
public String getAdminUserName() {
return adminUserName;
public void setAdminUserName(String adminUserName) {
this.adminUserName = adminUserName;
// DUMPING THE VALUES IN THE CONSOLE
public void dumpValues() {
StringBuffer sb = new StringBuffer();
sb.append("Name'");
sb.append(name);
sb.append("SearchField");
sb.append(searchField);
sb.append("searchCriteria");
sb.append(searchCriteria);
sb.append("'");
sb.append(" ");
System.out.println(sb.toString());
// RESET() METHOD IS USED FOR STORE FORM'S CURRENT VARIABLES DECLARATION
public void reset(ActionMapping actionMapping, HttpServletRequest request) {
System.out.println("reset() method is called");
this.email = null;
this.searchCriteria = null;
this.searchField = null;
this.results = null;
// VALIDATE() METHOD IS USED TO VALIDATE THE FORM DATA
public ActionErrors validate(ActionMapping actionMapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
System.out.println("Validate()is called");
// Determine if name has been entered.
if (getName() == null || getName().length() == 0
|| getName().equals(" ")) {
errors.add("accountText", new ActionError("searchText.error"));
} else if ((getSearchField().equals("name") == true)
&& (ValidateFormat.isValidText(getName()) == false)) {
errors.add("validAccountName", new ActionError("validName.error"));
if (getSearchField() == null || getSearchField().length() == 0) {
errors.add("accountSearchField", new ActionError(
"searchField.error"));
} else if ((getSearchField().equals("email") == true)
&& (ValidateFormat.isValidEmail(getName()) == false)) {
errors
.add("validAccountEmail", new ActionError(
"validEmail.error"));
} else if ((getSearchField().equals("phonenumber") == true)
&& (ValidateFormat.isValidPhoneNoFormat(getName()) == false)) {
errors.add("validPhoneFormat", new ActionError(
"validPhoneFormat.error"));
if ((getSearchField().equals("searchallfields"))
&& ((ValidateFormat.isValidText(getName()) == false)
&& (ValidateFormat.isValidEmail(getName()) == false) && (ValidateFormat
.isValidPhoneNoFormat(getName()) == false))) {
errors.add("validNameEmail",
new ActionError("validNameEmail.error"));
return errors;
Action class:
package com.finocus.cam.struts.action;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.finocus.cam.db.CAMDbAccess;
import com.finocus.cam.struts.bean.DetailsForm;
public class DetailsAction extends org.apache.struts.action.Action implements
com.finocus.cam.common.CAMConstants {
private final static String LOG_TAG = DetailsAction.class.getName() + ".";
// Global Forwards
public static final String GLOBAL_FORWARD_search = "login";
// Local Forwards
public static final String SUCCESS_search = "success";
private boolean dumpRequestParams = true;
public DetailsAction() {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
System.out.println("SearchAccount execute() is called");
HttpSession session = request.getSession(true);
ArrayList results = null;
DetailsForm search = (DetailsForm) form;
String name = search.getName();
String searchField = search.getSearchField();
String searchCriteria = search.getSearchCriteria();
// Dumping the values of input patameters
if (dumpRequestParams == true) {
request.setAttribute("SearchCriteria", searchCriteria);
request.setAttribute("SearchField", searchField);
request.setAttribute("Text", name);
search.dumpValues();
// Perform search based on what criteria and search Field was entered.
CAMDbAccess dbAccess = CAMDbAccess.getInstance();
if (null != searchCriteria && searchField != null) {
System.out.println("Search Criteria =" + searchCriteria
+ "Selected Option =" + searchField);
if (searchCriteria.equals(Search_Account) && searchField != null) {
results = dbAccess.searchByAccountInfo(name, searchCriteria,
searchField);
System.out.println(" Search criteria :Exact Match was selected.<BR>");
// Place search results in SearchForm for access by JSP.
search.setResults(results);
// Forward control to this Action's input page.
return mapping.findForward(SUCCESS_search);
My jsp page:
<%@ taglib uri="/WEB-INF/tld/struts-bean" prefix="bean" %>
<%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic-el" %>
<%@ taglib uri="/WEB-INF/tld/struts-html" prefix="html" %>
<html:html>
<head>
<title>Search Page</title>
</head>
<body colorants="LightGreen">
<table width="100%" bgcolor="LightGreen">
<tr>
<td align="left"><font color="brown"><h3><b>Search Info</b></h3></font><hr></td>
</tr>
<tr>
<td align="left"><h4><font color="brown"><b>Search Text:</b></font><%=request.getAttribute("Text")%></h4></td>
</tr><tr>
<td align="left"><h4><font color="brown"><b>Search Field:</b></font><%=request.getAttribute("SearchField")%></h4></td>
</tr><tr>
<td align="left"><h4><font color="brown"><b>Search Criteria:</b></font><%=request.getAttribute("SearchCriteria")%></h4></td>
</tr><tr>
<html:form action="/results.do">
<td><center><html:submit value="AllSearchOptions " /></center></td>
</html:form>
</tr>
<tr>
<td align="left"><font color="brown"><hr><h2><b>Search Results</b></h2></font></td>
</tr>
<tr>
<td>
<table border="1" cellspacing="1" cellpadding="3" width="70%"
bgcolor="white">
<logic:present name="searchbyaccount" property="results">
Results exists
<c:if test="${size==0 }">
<center><font color="red"><b>No Results Found</b></font></center>
</c:if>
<br>
<c:if test="${size>0}">
Size is greater than ZERO
<table border="1" cellspacing="1" cellpadding="3" width="70%"
bgcolor="white">
<tr>
<th>Customerid</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>phone Number</th>
<th>Details</th>
</tr>
<c:forEach var="result" items="${results}">
<c:out value="${result}"/>
<tr>
<td><bean:write name="result" property="customerid"></bean:write></td>
<td><bean:write name="result"
property="accountAdminFirstName"></bean:write></td>
<td><bean:write name="result"
property="accountAdminLastName" /></td>
<td><bean:write name="result" property="accountability" /></td>
<td><bean:write name="result" property="accountAdminPhone" /></td>
<td><html:form action="/accountDetails.do">
<html:submit value="Details" />
</html:form></td>
</tr>
</c:forEach>
</table>
</c:if>
</logic:present>
</table>
</td>
</tr>
</table>
</body>
</html:html> Please refer me where i done a mistake.Thanks in Advancehi all,
I am doing programs in sturts. My program
My program purpose is to retrieve data from the
database.My database is MySql. I know that we can
write connection code in Action Class, it is ok for
some less prog's if i want to use the sane connection
code in more Action Classes it is vasting time and
so.I don't think it's a good idea to put database code in Action classes. (That's one of the biggest drawbacks of Struts - it's completely tied to Actions, HTTP, and the Web.) Better to move that code into plain old Java objects and let the Actions call them.
You'll be able to test them without the container or Struts, and you'll be able to reuse those objects in other, non-Web contexts.
So i want to use <data-sources> tag that is available
in struts-config.xml. I know that thre is tag withThis is the wrong place to configure a connection pool, too. Struts should have nothing to do with it. What if you change Web frameworks to WebWork or Spring? The connection pool should be configured in the container that hosts your app, not Struts.
this name, but the problem is i don't know how to use
this tag. If any budy know how to use this please
tell me the syntax or any example.
plese... reply soon..Don't do it. Think about doing it in your container, not Struts.
%
Maybe you are looking for
-
Hallo, i have one maschine for dev and test. i know that it is possible to do this with 2 instances. SAP recommend to separate dev and test on separate maschines. But it is possible. have anyone experiance with that? When i don´t want 2 instances it
-
Messages stuck in outgoing folder after update
Hi to all, I migrated data from my old imac (ppc/10.4.11) to a new macbook pro 13", all is ok for files and documents, but all fails about Mail.app It restored all messages without any problems but when i try to send a message it disappear without an
-
When I bought(not rented) The Dark Knight, the movie, I tried to sync it with my iPod touch(2nd gen), but it didn't work.I have a Windows vista, latest itunes, iPod touch,latest software, definetly enough space. Although it gets to a certain point ev
-
IPhoto '09 won't recognize .jpg images for importing.
The resulting pop-up window displays the otherwise normal images as Unix Executable Files. If I convert the .jpg to .jpg 2000, then it imports with no problems. Result is a MUCH larger file. Any fixes?
-
Understanding Storage shared between work process
Hi guys, I was just trying to understand the SAP memory management and I think I don't really have good understanding of the SAP memory pools that we can view via ST02 . Under the Storage shared between work process section we have : So what are th