Printing of table data with a button
I have an application that creates a table with data from a database. I would like to put a button at the top of the page that would allow the user to print the table in paginated format. Does anyone have any sample code or directions as to how I could accomplish this. As an FYI, I am new to JSP and Creator studio.
Example code in the button is like this (I use oracle 10g, and call stored procedure to get the result set. In your case, maybe you just use simple view/table, give the connection to the jasper, and let the jasper query the table).
public String printButton_action() {
FacesContext myFaces = FacesContext.getCurrentInstance() ;
ServletContext svContext = (ServletContext) myFaces.getExternalContext().getContext();
HttpServletResponse response = (HttpServletResponse) myFaces.getExternalContext().getResponse();
File reportFile = new File(svContext.getRealPath("/report.jasper"));
if (reportFile.exists()) {
ResultSet rs;
Integer totrec;
// prepare parameters, connection... etc.
try{
java.sql.Date bdate = new java.sql.Date(begCalendar.getSelectedDate().getTime());
java.sql.Date edate = new java.sql.Date(endCalendar.getSelectedDate().getTime());
Connection con = getSessionBean1().getOracleconnection();
CallableStatement stmt = con.prepareCall("{call webcrpackage.TtcHarian(?,?,?,?)}");
stmt.setDate(1, bdate);
stmt.setDate(2, edate);
stmt.registerOutParameter(3, OracleTypes.NUMBER); //REF CURSOR
stmt.registerOutParameter(4, OracleTypes.CURSOR); //REF CURSOR
stmt.execute();
rs = (ResultSet) stmt.getObject(4);
totrec = Integer.valueOf(stmt.getBigDecimal(3).intValue());
} catch(Exception e) {
error(e.getMessage());
return null;
try {
JRResultSetDataSource dsource = new JRResultSetDataSource(rs) ;
// execute jasper
byte[] bytes = null ;
// prepare jasper parameter!!
Map parameters = new HashMap();
parameters.put("comname", getSessionBean1().getComname());
parameters.put("comdivision", getSessionBean1().getComdivision());
parameters.put("begdate", begCalendar.getSelectedDate());
parameters.put("enddate", endCalendar.getSelectedDate());
parameters.put("totalrecord", totrec);
bytes = JasperRunManager.runReportToPdf(reportFile.getPath(), parameters, dsource);
response.setContentType("application/pdf");
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
} catch (Exception ex) {
error(ex.getMessage());
return null;
} else {
error("Report file doesn't exist!");
return null;
}Long journey, search this forum on how to deploy jasper in jsc, etc..etc.
Hope that helps.
Similar Messages
-
Problem in printing internal table data in Sapscript!
Hi All,
Am trying to print internal table data into main window of sapscript.
This is what I have written.
loop at it_final INTO wa_final.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
window = 'MAIN'
ELEMENT = '670'
TYPE = 'BODY'
FUNCTION = 'APPEND'
EXCEPTIONS
window = 1
element = 2.
IF sy-subrc <> 0.
ENDIF.
ENDLOOP.
IN Sapscript :
/E 670
IT &wa_final-vbeln&,,&wa_final-vbelv&,,&wa_final-payment&
= &wa_final-rundate&,,&wa_final-waers&,,&wa_final-creditcard&
= &wa_final-augru&,,&wa_final-dmbtr&
Pls let me know if am missing anything.
Thanks & Regards
HimayatCheck if your Programm is called at the Sapscript level.
Are you calling the programm from the Sapscript using the PERFORM command? or are these Programm and Sapscript set in customizing?
Using SE16 check the Message Type and see if Sapscript and the programm are connected at all. -
How to export table data with coloring of cell according to value.
Hi all,
I am using jdeveloper 11.1.1.6
i want to export table data with lot of formatting. like with coloring of cell according to value and so many.How to do that?Hi,
like with coloring of cell according to value and so many.How to do that?
Answer is, you can't
Frank -
Hi all,
I want to print an internal table data without displaying it via ALV. That is when clicked on a button, printing should be started.
How can I do that?
Thanks a lot.
Deniz.Hi,
Check the following code this is exactly what you need I guess....
FM to generate spool number for the internal table wt_final_prnt.
CALL FUNCTION 'RSPO_SX_OUTPUT_TEXTDATA'
EXPORTING
name = gv_name
dest = gv_dest
rows = gv_rows
startrow = gv_startrow
pages = gv_pages
rqtitle = 'Z9CS - STD Search Results'
rqcopies = gv_rqcopies
rqowner = gv_rqowner
immediately = gv_immediate
IMPORTING
rqid = gv_rqid
TABLES
text_data = wt_final_prnt
EXCEPTIONS
OTHERS = 1.
CLEAR : wa_final_prnt, wt_final_prnt[].
FM to set the print attributes.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
IMPORTING
out_parameters = wv_pripar
out_archive_parameters = wv_arcpar
valid = wv_val
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4.
FM to submit to the printer
CALL FUNCTION 'RSPO_OUTPUT_SPOOL_REQUEST'
EXPORTING
spool_request_id = gv_rqid.
Regards,
Ram. -
Export and import table data with Java
I need a library for simple exporting and importing table data.
The data should be exported to a SQL file with insert statements.
I just want to tell the library the table name, the connection and where to store the file. The usage should be very simple.
Are there any small libraries for this? Finished calsses and methods which I can just call?I need a library for simple exporting and importing
table data.
The data should be exported to a SQL file with insert
statements.Every database has utilities to export/import data from tables. Take a look at your database manual. -
How join a type table data with a real table.
Hello,
I want make a join with a type table data and real table.
But i don't know how make this.
Can you help me?????
I have this pl/sql:
SET LINESIZE 5000;
DECLARE
valor NUMBER;
TYPE reg_tablita IS RECORD
(cuenta B_TB_CTAFACTU.B_CO_CTAFACTU%TYPE,sistema B_TB_CTAFACTU.B_CO_SISTEMA%TYPE);
TYPE Tabla IS TABLE OF reg_tablita INDEX BY BINARY_INTEGER;
I BINARY_INTEGER;
Array Tabla;
BEGIN
Array(1).cuenta:='000001';
Array(1).sistema:='AA';
Array(2).cuenta:='000002';
Array(2).sistema:='BB';
Array(3).cuenta:='000003';
Array(3).sistema:='CC';
Array(4).cuenta:='000004';
Array(4).sistema:='DD';
Array(5).cuenta:='000005';
Array(5).sistema:='EE';
SELECT count(*) into valor FROM
TABLA A, Array WHERE
B_CO_CTAFACTU=Array.cuenta and B_CO_SISTEMA=Array.sistema
quit;
Thanks very much!!!!You need to have the types defined as SQL types (created in database) in order to be able to use them for joining. PL/SQL object types can not be joined.
-
Order table data with comparing rows
Hi,
My question is...
I have table with with 5 columns this actually is been loaded from a file and there is no direct PK, but for that combination of columns as used to make them unique
code, person, case
Table X
CODE CASE OLD_ID NEW_ID PERSON AUTH
01 ab122 1234 0001 AU123 99393
07 vv353 7872 0919 FV982 78282
01 ab122 1982 9929 AU123 99393
04 hjsss 8839 8302 JK920 32320
01 ab122 0001 1982 AU123 99393
05 cg899 6728 32322 IKL020 65252
07 w353 0919 8282 FV982 78282
now I need to order this data comparing row values of old_id to new_id for each of the combinations of code, person, case
need output like below
Table X
CODE CASE OLD_ID NEW_ID PERSON AUTH
01 ab122 1234 0001 AU123 99393
01 ab122 0001 1982 AU123 99393
01 ab122 1982 9929 AU123 99393
04 hjsss 8839 8302 JK920 32320
05 cg899 6728 32322 IKL020 65252
07 vv353 7872 0919 FV982 78282
07 w353 0919 8282 FV982 78282
hot to get this result, any help is much appreciated..
Thanks,
AK.Yes you are right, I took it down to edit this in that time you have posted the message...
Question:
Table data need to be sorted by matching old_id with new_id
actual table : here rows are randomly arranged
Table X
CODE CASE OLD_ID NEW_ID PERSON AUTH
01 ab122 1234 0001 AU123 99393
07 vv353 7872 0919 FV982 78282
01 ab122 1982 9929 AU123 99393
04 hjsss 8839 8302 JK920 32320
01 ab122 0001 1982 AU123 99393
05 cg899 6728 32322 IKL020 65252
07 w353 0919 8282 FV982 78282
output table: here if you see old_id of row 2 is matched to new_id of row 1.. and so on
Table X
CODE CASE OLD_ID NEW_ID PERSON AUTH
01 ab122 1234 0001 AU123 99393
01 ab122 0001 1982 AU123 99393
01 ab122 1982 9929 AU123 99393
04 hjsss 8839 8302 JK920 32320
05 cg899 6728 32322 IKL020 65252
07 vv353 7872 0919 FV982 78282
07 w353 0919 8282 FV982 78282
so, I need a query where I can generate this output.. -
How to Capture print jobs and Data with WIN32 API?
My organization has about 5 network printers and copiers to which a computer can print. What I'd like to do is build, if possible, a simple JAVA program to intercept what the users are printing (from any application) and capture certain information about the print jobs before it gets sent off to the specified printer.
For example, when a user selects print from the menu in MS Word, and after the Ok button is pressed on the printers dialog window, have my program then pop up asking the user to fill in specific information (who they want to charge for the print job...this is typically an internal billing code, etc.).
The program would have to capture the name/driver of the printer users are printing to, the document they printed, number of pages, number of copies, date/time, etc.
Is/are there Windows API's to help in my programming of this application? I've been, unsuccessfully, searching MSDN, web sites, etc. on how to intercept/detect a print job. Any help would be greatly appreciated!
Thanks ahead of time...Hi,
Printing is nothing to do with database transaction. SP will not apply here. You may only try SDK.
Thanks,
Gordon -
Pdf & Excel for printing af:table data's
Hi,
Good afternoon. :)
Using jdev 11.1.1..50-adfbc.
Say Vo:
Select * from employee where empid=:piddrag and drop execute as params in jsff page.
In Jsff page(dynmaic region)
Employee Id(inputtext box): 101 //entering the data
ExecuteParams // hitting the button
af:table //results came in af:table
employeeid | employeename |employee salary
101 Jack 20000ok. all are working fine.
My requirement is: button named with pdf and another button named excel
while hit pdf button means the particular records write into pdf and should opened the written pdf show to enduser.
as well for excel.
how can i do this?
Edited by: ADF7 on Mar 12, 2012 3:25 AMI think,
as like export to excel ,there is no such for generating pdf in adf.
if we(here 'we means ' adf7 need pdf only) . you(john,timo) both suggesting me go with some third party tools is it so?
jasper-reports
itext
Apache-Fop -
Pages Link Table Data With A Chart
Hello,
I am wondering if in pages one can link the data in a table with the charts in the same document.
Thanks in advanceNo. It might be better for you to work in Numbers if you are doing a lot of this.
Jerry -
Problem getting the Table Data with the selection listener
Hi All,
I am working on a tree and table components. I wrote a logic in the backing bean in such a way that when I expand a node the child nodes for the tree are getting added dynamically and also getting the data in the table for the node expanded in the tree using the same Toplink Query . I added the selection listener for the table and when I am selecting a row in the table I am getting the Null Pointer Exception as the RowKeySet Value for the row selected is coming null.
Can any one please help me out with this problem
I will be very thankful
Regards,
Madhavi.Hi All,
I am working on a tree and table components. I wrote a logic in the backing bean in such a way that when I expand a node the child nodes for the tree are getting added dynamically and also getting the data in the table for the node expanded in the tree using the same Toplink Query . I added the selection listener for the table and when I am selecting a row in the table I am getting the Null Pointer Exception as the RowKeySet Value for the row selected is coming null.
Can any one please help me out with this problem
I will be very thankful
Regards,
Madhavi. -
How to incorporate table data with Oracle Business Rule
hello
I want to use table with data in Oracle Business Rule can i do it.
if yes please write how .
with regs
saleemHi,
like with coloring of cell according to value and so many.How to do that?
Answer is, you can't
Frank -
Replace Table Data With Search
I want to run a search but only on a selected 8 cells, and want to change all the words "Blue" to "Red", even I select those cells when I hit Search it seems to replace all of the cells... Any ideas anyone?
Numbers won't do a find/replace limited to the selection.
Two ways of accomplishing this:
1. Don't use "Replace all". Instead,click "Find Next", then "Replace & Find"for each occurrence you want to change, and "Find next" on each that you wish to stay the same.
2. To limit the changes to a single table, select each of the tables you do NOT wish to change and go Arrange > Lock. When all are locked, proceed with the Find/Replace, using Replace All. All occurrences on the unlocked table will be replaced. All data on the Locked table(s) will remain unchanged.
Regards,
Barry -
Browsing table data with server explorer.
I'm trying to browse data from a table in a different schema. When I double click on the table, I keep getting an error. Schema object MY_TABLE.MY_SCHEMA : Table @ JIN.dbprd/prd1 no longer exists in the database. I can see that (at least in the message), the table and schema is clearly reversed. Anybody else having this problem? is this a known issue? any fix?
If you would like to try to diagnose this, please try the following:
1) Close Visual Studio and all applications that are connected to Oracle
2) In the same Oracle Home as the ODT install, please find the SQLNET.ORA file
3) In that file, add a line:
TRACE_LEVEL_CLIENT=16
4) Start Visual Studio
5) Reproduce the error as efficiently as possible (with no extra steps)
6) Close Visual Studio immediately
7) Search for the newly created SQLNET.TRC file
8) Zip the file, rename the extension to .zipa or something else and email to [email protected]
9) Remove the TRACE_LEVEL_CLIENT entry in SQLNET.ORA -
Select three tables data with Same where condition
Hi i want sum data in three tables with same where condition. how can i do this code very simple.
SELECT SUM(SIGNA) FROM dbo.tblPLAG
WHERE VERSION='ACTUAL' AND STATS='ST_Z010'
AND FACILITY='FA_2003'
AND TD IN ( SELECT TIMEID FROM Time WHERE ID BETWEEN
@YEAR+'.'+(SELECT RIGHT ('000'+ CAST (@PERIOD-6 AS varchar), 3))
AND
@YEAR +'.'+(SELECT RIGHT ('000'+ CAST (@PERIOD AS varchar), 3)))
Try following
SELECT SUM(t1.SIGNA) + sum(t2.SIGNA) + sum(t3.SIGNA) and you query, it will add the SUMs of each table.. hopefully it will work
Maybe you are looking for
-
My iPad cannot find my HP AirPrint printer HP 3050 . We are on the same network
I have recently converted all our family devices to Apple. My Mini-Mac has found my printer as well as my Mac Air. The only device that has not is my wife's iPAD. She is on the same home network as my other systems, but no results. Software updat
-
How can I change my power regulator to a new one?
In august 24,2010, I bought a macbook pro 13-inch from apple on-line store. But today, my power regulator of magsafe was broken. I don't know what's wrong with it. I use my friend's magsafe, and his magsafe is good. So I want to change another. How c
-
I've changed my email address but me Apple ID has not changed how do I change it? Thanks
Can any one help me I need to change my Apple ID on phone and ipad I've changed my email address thank you
-
Dear all, i have oracle 11gR1 installed on RedHat Eterprise linux X86_64 platform. I try to make a heterogeneous connectivity to SQL Server using Oracle Gateway 11g. I already configure initdg4msql.ora, listener.ora and tnsnames.ora as in manual. whe
-
Barcode Scanner app using Javascript for windows 8 tablet
I want to create a barcode scanner app in which i want to start the camera preview, and read the barcode. Is there any sample code? I have used the below code but its working only with windows desktop not working with tablet. function openScanner() {