Creating dynamic html in java with itext best way to approach - java

Im using an example i found on stackoverflow to explain my problem.
Java code :
/**
* Example written by Bruno Lowagie in answer to the following question:
* RowSpan does not work in iTextSharp?
*/
public class ParseHtml {
public static final String DEST = "results/xmlworker/html_table_4.pdf";
public static final String HTML = "D:\\Users\\Documenten\\NetBeansProjects\\ItextTest\\recources\\xml\\table2_css.html";
public static void main(String[] args) throws IOException, DocumentException {
File file = new File(DEST);
file.getParentFile().mkdirs();
new ParseHtml().createPdf(DEST);
}
/**
* Creates a PDF with the words "Hello World"
* #param file
* #throws IOException
* #throws DocumentException
*/
public void createPdf(String file) throws IOException, DocumentException {
// step 1
Document document = new Document();
// step 2
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
// step 3
document.open();
// step 4
// XMLWorkerHelper.getInstance().parseXHtml(writer, document, null, null);
XMLWorkerHelper.getInstance().parseXHtml(writer, document,
new FileInputStream(HTML));
// step 5
document.close();
}
}
Html code:
<table border="1" style="width: 100%">
<tr>
<td colspan="5" align="center" style="background-color: lightblue">INVOICE</td>
</tr>
<tr>
<td colspan="2" rowspan="4" style="background-color: white"><b>AIRNET NETWORKS</b><br />asdadadadaada asd asd a ads adsadsadsadasd</td>
<td>INVOICE</td>
<td>DATE</td>
<td>aDATEsd</td>
</tr>
<tr>
<td>Order</td>
<td>XXXX</td>
<td>Ref XXXXXX</td>
</tr>
<tr>
<td>Delivery</td>
<td>XXXX</td>
<td>Ref XXXXXX</td>
</tr>
<tr>
<td>Due Date</td>
<td>XXXX</td>
<td>Ref XXXXXX</td>
</tr>
<tr>
<td colspan="2" rowspan="4" style="background-color: white"><p><b >CUSTOMER NAME</b></p> asd asd adadaadadadada adadaadsasdad ada asd adad</td>
<td>Customer Care No:</td>
<td colspan="2">544646454,88877978975</td>
</tr>
<tr>
<td>Email Id</td>
<td colspan="2">airnet#gmail.com</td>
</tr>
<tr>
<td>Account Details</td>
<td colspan="2">5522245125545455 IFSC 323hasd<br /> SBI India</td>
</tr>
</table>
<div> </div>
<table border="1" style="width: 100%">
<tr>
<td style="background-color: lightblue" height="15" >Srno</td>
<td style="background-color: lightblue">Particulars</td>
<td style="background-color: lightblue">Quantity</td>
<td style="background-color: lightblue">Rate/Month</td>
<td style="background-color: lightblue">Total Rupees</td>
</tr>
<tr>
<td valign="top">1</td>
<td valign="top">1 MBPS Plan</td>
<td valign="top">1</td>
<td valign="top">600</td>
<td valign="top">692</td>
</tr>
<tr>
<td height="300" valign="top" >1</td>
<td valign="top">1 MBPS Plan</td>
<td valign="top">1</td>
<td valign="top">600</td>
<td valign="top">692</td>
</tr>
<tr>
<td colspan="3" rowspan="3" valign="top">asdasdasd</td>
<td colspan="1">Total</td>
<td colspan="1">692</td>
</tr>
<tr>
<td>Service Tax</td>
<td>692</td>
</tr>
<tr>
<td>Grand Total</td>
<td>692</td>
</tr>
</table>
The problems im facing:
Is it possible to give the html access to a javaclass so i can use it like this:
<tr>
<td>invoice.getdate</td>
<td>invoice.getInvoiceNumber</td>
<td>invoice.getSomethingelse</td>
</tr>
Can you create a dynamic table like this:
<table border="1" style="width: 100%">
<tr>
<td style="background-color: lightblue" height="15" >Srno</td>
<td style="background-color: lightblue">Particulars</td>
<td style="background-color: lightblue">Quantity</td>
<td style="background-color: lightblue">Rate/Month</td>
<td style="background-color: lightblue">Total Rupees</td>
</tr>
for (ServiceDTO service : listServices) {
<tr>
<td valign="top">service.getsomevalue</td>
<td valign="top">service.getsomevalue</td>
<td valign="top">service.getsomevalue</td>
<td valign="top">service.getsomevalue</td>
<td valign="top">service.getsomevalue</td>
</tr>
}
As work around im using a stringbuilder. Where i create a temporarily html page then load the html page inside itext. But there has to be a better way ? Can someone give me some direction where to start ?

Related

how to send html email in android?

Hi I am making an app in which I am sending an email to a specific address
This email is a html email with table and images and all...
Is I have tried to add Html.fromhtml() but it keeps saying type mismatch
needed string found spanned....
If you need any of my code please comment
Please suggest any tutorial if you have in mind
EDIT
I forgot to mention I am sending mail using javax.maillibrary I am not using Intents
I tried to use Html.tohtml(Spanned text) its giving the message of type mismatch cant convert String to spannedtext
I have no idea whats happening
I am receiving the html data in my mail if i just go with it
UPDATE
I am fetching the content from a string resource
and this is what I am getting as result
$message = ' For Support enquiry#makeintern.comContact Form Enquiry !
Name: :'.$name.'Email: :'.$email.'Contact: :'.$mobile.'Message:
:'.$message.'Date-Time: :'.$current_date.'
Thanks and Regards MakeIntern Team Account Manager - MakeIntern Cell
www.makeintern.com enquiry#makeintern.com
If any query Please call us on : 011-45544188  www.makeintern.com |
enquiry#makeintern.com 
from---
<string name="email">$message = \'<center>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center" bgcolor="#FFFFFF">
<table width="620px" cellpadding="0" cellspacing="0">
<tr>
<td width="400px" bgcolor="#000000" style="color:#FFFFFF; text-
decoration:none; float:left;font-size:10px;margin: -18px 3px -1px 11px; font-weight:bold; padding:2px; text-decoration:none; padding-left:0px;">For Support <span style="text-decoration:none; color:#FFFFFF;">enquiry#makeintern.com</span></td>
<td width="220px" bgcolor="#000000"></td>
</tr>
<tr style="background-color:#737373;">
<td width="290" align="left" valign="middle"><a href="http://makeintern.com" target="_blank"><img src="http://www.makeintern.com/images/makeintern.jpg" width="136" border="0" alt="MakeIntern" style="display:block; padding-left:0px;"></a></td>
<td width="290" align="right" style="text-align:right; font-family:Arial, Segoe UI,Helvetica Neue, Helvetica, sans-serif; font-size:18px; line-height:18px; color:#FFFFFF; font-weight:normal; padding-right:10px;">Contact Form Enquiry !<br>
</td>
</tr>
<tr>
<td height="12px" colspan="2"></td>
</tr>
<tr>
<td colspan="2" align="center" style="line-height:16px; font-family:arial; font-size:12px; color:#888888; text-align:left;">
<table cellspacing="0" cellpadding="0">
<tr>
<td width="200px" style="font-weight:bold;">Name: </td>
<td width="100px">:</td>
<td>\'.$name.\'</td>
</tr>
<tr>
<td width="200px" style="font-weight:bold;">Email: </td>
<td width="100px">:</td>
<td>\'.$email.\'</td>
</tr>
<tr>
<td width="200px" style="font-weight:bold;">Contact: </td>
<td width="100px">:</td>
<td>\'.$mobile.\'</td>
</tr>
<tr>
<td width="200px" style="font-weight:bold;">Message: </td>
<td width="100px">:</td>
<td>\'.$message.\'</td>
</tr>
<tr>
<td width="200px" style="font-weight:bold;">Date-Time: </td>
<td width="100px">:</td>
<td>\'.$current_date.\'</td>
</tr>
</table>
<br/><br/>
Thanks and Regards <br/>
MakeIntern Team <br/>
Account Manager - MakeIntern Cell <br/>
www.makeintern.com<br/>
enquiry#makeintern.com<br/><br/>
<b>If any query Please call us on : 011-45544188</b><br/>
</td>
</tr>
<tr>
<td height="12px"></td>
</tr>
<tr>
<td colspan="2"><img src="http://www.myhotbooking.com/images/email-template/bar.png"></td>
</tr>
<tr>
<td colspan="2" bgcolor="#737373" height="90px">
<table cellpadding="0" cellspacing="0" width="620px">
<tr>
<td height="10px"></td>
</tr>
<tr>
<td align="center" style="color:#FFFFFF;" height="20px"><a href="http://www.makeintern.com/">www.makeintern.com </a>| <span style="color:#FFFFFF; text-decoration:none;">enquiry#makeintern.com</span></td>
</tr>
<tr>
<td align="center" valign="middle">
<a href="https://www.facebook.com/makeinterns" target="_blank"><img src="http://www.myhotbooking.com/images/email-template/icon-facebook.png" width="26" height="26" border="0" alt="Facebook"></a><a href="https://twitter.com/makeintern" target="_blank"><img src="http://www.myhotbooking.com/images/email-template/icon-twitter.png" width="26" height="26" border="0" alt="Twitter"></a><a href="https://www.linkedin.com/company/makeintern" target="_blank"><img src="http://www.myhotbooking.com/images/email-template/icon-linkedin.png" width="26" height="26" border="0" alt="Linkedin"></a><a href="https://plus.google.com/+makeintern" target="_blank"><img src="http://www.myhotbooking.com/images/email-template/icon-google-plus.png" width="26" height="26" border="0" alt="Google+"></a></td>
</tr>
<tr>
<td align="center" style="color:#FFFFFF;"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>\'</string>
Thankyou in advance
Try Below Code :
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT,getResources().getString(R.string.email_subject));
sendIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(getResources().getString(R.string.email_text)));
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, ""));
string.xml
<resources>
<string name="email_subject">Download App for your smartphone.</string>
<string name="email_text"><![CDATA[Hey,<br/>I just downloaded App on my Android.<br/>It is a smartphone Manager.This app even lets me book parties,search restaurants.<br/>App is available for Android.<br/>
Get it now from http://www.exampleapp.com/download]]></string>
</resources>

BufferReader not able to read full file in java

Hello Friends I have following data in store in file.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
<div id="divOldReceipt" style="width:100%">
<style>
.tableStyle{border-collapse: collapse;
width: 100%;
font-family: Times New Roman;
font-size: 17px;
border: 1px solid black;}
.tableStyle th td {border: 1px solid black;}
.tableStyle td {border: 1px solid black;padding-left:3px;}
</style>
<table cellspacing="0" cellpadding="0" style="width: 8in; font-family:Times New Roman;">
<tbody>
<tr>
<td style="width: 20%;text-align:center" rowspan="2">
<img style="height: 84px; width: 71px" src={%images_path%}></img>
</td>
<td style="width: 60%;text-align: center; font-size: 25px;">
<b>
CORPORATION OF CHENNAI
</b>
</td>
<td></td>
</tr>
<tr>
<td style="text-align: center; font-size: 18px">
<b>
PROPERTY TAX RECEIPT
</b>
</td>
<td></td>
</tr>
<tr>
<td colspan="3">
<table class="tableStyle" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width: 20%"></td>
<td style="width: 20%"></td>
<td style="width: 10%"></td>
<td style="width: 10%"></td>
<td style="width: 40%"></td>
</tr>
<tr>
<td style="height: 25px;">
<b>
Receipt No:
</b>
</td>
<td colspan="2" style="height: 25px;">
<b>
{%receiptNo%}
</b>
</td>
<td colspan="2" style="text-align:center;height: 25px;">
<b>
Receipt Date: {%Receipt_date%}
</b>
</td>
</tr>
<tr>
<td style="height: 25px;">
<b>
Name:
</b>
</td>
<td style="height: 25px;" colspan="4">
{%persone_name%}
</td>
</tr>
<tr>
<td style="height: 25px;">
<b>
Address:
</b>
</td>
<td style="height: 25px;" colspan="4">
{%address%}
</td>
</tr>
<tr>
<td rowspan="2" style="height: 25px;">
<b>
Payment Details:
</b>
</td>
<td style="height: 25px;border-right-style:none;">
Description:
</td>
<td colspan="3" style="height: 25px;border-left-style:none;">
New Property Tax Number : {%new_property_tax_no%}
<br>
Old Property Tax Number : {%old_property_tax_no%}
</td>
</tr>
<tr>
<td style="height: 25px;border-right-style:none;">
Paid By:
</td>
<td colspan="3" style="height: 25px;border-left-style:none;">
{%paid_by%}
</td>
</tr>
<tr>
<td style="text-align:center;height: 25px;" colspan="3">
<b>
Description Head of A/C
</b>
</td>
<td style="text-align:center;height: 25px;" colspan="2">
<b>
Amount (in Rupees)
</b>
</td>
</tr>
<tr>
<td style="height: 25px;text-align: center;" colspan="3">
{%installment%}
</td>
<td style="text-align:center;padding-right:5px;height : 25px;" colspan="2">
{%adjistment%}
</td>
</tr>
<tr>
<td style="text-align:right;padding-right:5px;height: 25px;" colspan="3">
<b>
Total:
</b>
</td>
<td style="text-align:center;padding-right:5px;height : 25px;" colspan="2">
<b>
{%adjistment%}
</b>
</td>
</tr>
{%Bank Details%}
<tr>
<td colspan="5" style="height: 25px;">
This is computer generated receipt. Signature is not neccessary.Except Online payment the receipt is subject to realisation of cheque.
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
I Want to read this file in java using following code
public String readTemplateFile(String fileName) throws Exception
{
BufferedReader bufferedReader = new BufferedReader(new FileReader(fileName));
String line =null;
StringBuilder sb = new StringBuilder();
while((line = bufferedReader.readLine())!=null)
{
sb.append(line);
}
return sb.toString();
}
OR
public String readFile(String filepath) throws IOException {
File f = new File(filepath);
if (f.exists()) {
FileInputStream in = new FileInputStream(f);
int size = in.available();
byte c[] = new byte[size];
for (int i = 0; i < size; i++) {
c[i] = (byte) in.read();
}
String filedata = new String(c, "utf-8");
return filedata.toString().trim();
} else {
return null;
}
}
But Full file is not getting read
following is output
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head></head> <body> <div id="divOldReceipt" style="width:100%"> <style> .tableStyle{border-collapse: collapse; width: 100%; font-family: Times New Roman; font-size: 17px; border: 1px solid black;} .tableStyle th td {border: 1px solid black;} .tableStyle td {border: 1px solid black;padding-left:3px;} </style> <table cellspacing="0" cellpadding="0" style="width: 8in; font-family:Times New Roman;"> <tbody> <tr> <td style="width: 20%;text-align:center" rowspan="2"> <img style="height: 84px; width: 71px" src="../Images/Corporation.gif"></img> </td> <td style="width: 60%;text-align: center; font-size: 25px;"> <b> CORPORATION OF CHENNAI </b> </td> <td></td> </tr> <tr> <td style="text-align: center; font-size: 18px"> <b> PROPERTY TAX RECEIPT </b> </td> <td></td> </tr> <tr> <td colspan="3"> <table class="tableStyle" cellspacing="0" cellpadding="0"> <tbody> <tr> <td style="width: 20%"></td> <td style="width: 20%"></td> <td style="width: 10%"></td> <td style="width: 10%"></td> <td style="width: 40%"></td> </tr> <tr> <td style="height: 25px;"> <b> Receipt No: </b> </td> <td colspan="2" style="height: 25px;"> <b> {%receiptNo%} </b> </td> <td colspan="2" style="text-align:center;height: 25px;"> <b> Receipt Date: {%Receipt_date%} </b> </td> </tr> <tr> <td style="height: 25px;"> <b> Name: </b> </td> <td style="height: 25px;" colspan="4"> {%persone_name%} </td> </tr> <tr> <td style="height: 25px;">
I am confused why my code is behaving like this can some one plz help me to solve this issue.
Thanks In advance
Is the output you mention produced by the first or by the second code sample?
For your first code example, note that bufferedReader.readLine() returns the next line of the file but discard the end-of-line characters. These end-of-line characters are not added again by the sb.append(line) method call. This might explain why the end-of-lines are removed from your file.
For your second code examle, in.available() only returns an estimate of the number of bytes remaining in the stream, so don't use to determine the size of the input. It is better to read through the stream sequentially until the end-of-file has been reached. If the end-of-file is reached, in.read() will return -1.

How to select elements using Jsoup

I have table where I want to iterate over rows (tr) in root tbody and not rows in it child
I try this but with no success:
Elements tableRows = table.select("tr");
this get tr also in it child so I have there duplicates
Elements tableRows = table.select("tbody > td:first-child");
this doesnt work too
here is my table:
<table border="0" cellspacing="0" cellpadding="2" width="100%" align="center">
<tbody>
<tr>
<td class="head">Rank</td>
<td class="Head"> </td>
<td class="Lhead">Club</td>
<td class="head">Nation</td>
<td class="head">Rank points</td>
<td class="head">Five best results (by points)</td>
</tr>
<tr>
<td class="playerB">60. (1.)</td>
<td class="Lplayer">Imrich Blasko</td>
<td class="Lplayer">THC Blue Dragon Kosice</td>
<td class="player"><img src="flags/SVK.gif" alt="SVK" /></td>
<td class="playerB">3 398</td>
<td class="Lplayer">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="Lplayer">World Championships 2013</td>
<td class="Rplayer">817</td>
</tr>
<tr>
<td class="Lplayer">Czech Open 2012</td>
<td class="Rplayer">674</td>
</tr>
<tr>
<td class="Lplayer">Czech Open 2013</td>
<td class="Rplayer">668</td>
</tr>
<tr>
<td class="Lplayer">Slovak Championships 2013</td>
<td class="Rplayer">621</td>
</tr>
<tr>
<td class="Lplayer">Bratislava Cup 2013</td>
<td class="Rplayer">617</td>
</tr>
</tbody>
</table></td>
</tr>
<tr>
<td colspan="6">
<hr color="#008080" width="100%" /></td>
</tr>
<tr>
<td class="playerB">159. (2.)</td>
<td class="Lplayer">Tibor Valachovic ml.</td>
<td class="Lplayer">SHK Skalica</td>
<td class="player"><img src="flags/SVK.gif" alt="SVK" /></td>
<td class="playerB">2 847</td>
<td class="Lplayer">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="Lplayer">Czech Open 2013</td>
<td class="Rplayer">639</td>
</tr>
<tr>
<td class="Lplayer">Brno 2013</td>
<td class="Rplayer">594</td>
</tr>
<tr>
<td class="Lplayer">Brno 2014</td>
<td class="Rplayer">583</td>
</tr>
<tr>
<td class="Lplayer">Slovak Championships 2013</td>
<td class="Rplayer">569</td>
</tr>
<tr>
<td class="Lplayer">Czech Open 2011</td>
<td class="Rplayer">461</td>
</tr>
</tbody>
</table></td>
</tr>
<tr>
<td colspan="6">
<hr color="#008080" width="100%" /></td>
</tr>
</tbody>
</table>
Try:
Elements tableRows = table.select(":root > tbody > tr");

The method println(boolean) in the type PrintStream is not applicable for the arguments (void)

I want to print resultset value retrive from SQL JSTL tags.but it gave error
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 219 in the jsp file: /testVoucher.jsp
The method println(boolean) in the type PrintStream is not applicable for the arguments (void)
216:
217:
218: <%
219: System.out.println(
220: %>
221:
222: <%
An error occurred at line: 220 in the jsp file: /testVoucher.jsp
Syntax error, insert ")" to complete Expression
217:
218: <%
219: System.out.println(
220: %>
221:
222: <%
223: );
An error occurred at line: 223 in the jsp file: /testVoucher.jsp
Syntax error on token ")", delete this token
220: %>
221:
222: <%
223: );
224: %>
225:
226:
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
The Main part of code is as follows
<sql:preparedStatement id="pst" conn="conn">
<sql:query>
SELECT A.BANK_NAME,B.SCHEME_NAME SCHEME_DESC,
TO_CHAR(SUM(B.GROSS),'99,99,99,99,990.00') GROSS,
round(SUM(B.TDS),0) TDS,
TO_CHAR(SUM(B.ADVANCE),'99,99,99,99,990.00') ADVANCE,
TO_CHAR(SUM(B.PARTIAL),'99,99,99,99,990.00') PARTIAL,
TO_CHAR(SUM(B.NET),'99,99,99,99,990.00') NET
FROM VW_VOUCHER_ALLOCATION_DETAIL B, VW_SCHEME_ACCOUNT A
WHERE B.VOUCHER_NO='<%=voucher%>'
AND B.ID = A.EXPENSE_SCH_CODE
AND (B.GROSS>0 OR B.ADVANCE>0 OR B.PARTIAL>0)
GROUP BY A.BANK_NAME,B.SCHEME_NAME
ORDER BY A.BANK_NAME, B.SCHEME_NAME
</sql:query>
<sql:resultSet id="rs">
<tr style="height:20px">
<td CLASS="BORDER_"><b><sql:getColumn colName="BANK_NAME"/></b></td>
<td CLASS="BORDER_" ><sql:getColumn colName="SCHEME_DESC"/></td>
<td CLASS="BORDER_" align="right"><sql:getColumn colName="GROSS"/></td>
<td CLASS="BORDER_" align="right"><sql:getColumn colName="TDS"/></td>
<td CLASS="BORDER_" align="right" bgcolor="#e2d36d"><sql:getColumn colName="ADVANCE"/></td>
<td CLASS="BORDER_" align="right" bgcolor="#e2d36d"><sql:getColumn colName="PARTIAL"/></td>
<td CLASS="BORDER_" align="right"><sql:getColumn colName="NET"/></td>
</tr>
/////it give error here ///////////////////////////
<%
System.out.println(
%>
<sql:getColumn colName="SCHEME_DESC"/>
<%
);
%>
</sql:resultSet>
Whole code is As follows:
<%# include file="/include_session_check.jsp" %>
<%# include file="/include_db_tld.jsp" %>
<%#page import="java.util.ArrayList"%>
<center>
<%!
ArrayList<String> BankName_list=new ArrayList<String>();
%>
<%
String voucher="2012-2013/001188";
//com.GEN_Utility.nvl(request.getParameter("voucher"));
ArrayList<String> Scheme_list=new ArrayList<String>();
ArrayList<Float> Gross_List=new ArrayList<Float>();
ArrayList<Float> TDS_List=new ArrayList<Float>();
ArrayList<Float> Adv_List=new ArrayList<Float>();
ArrayList<Float> Partial_List=new ArrayList<Float>();
ArrayList<Float> Net_List=new ArrayList<Float>();
System.out.println(" voucher "+voucher);
%>
<br>
<DIV CLASS="PGBREAK" STYLE="background-color: white; WIDTH: 800px;">
<table width="793" height="70">
<TR>
<TD width="55%">
<img src="<%=STRpath%>index/Logo_new.bmp">
</TD>
<TD width="45%"><br><b>Mirae Asset Global Investments(I) Pvt Ltd</b> <br>
Unit No. 606, 6th Floor, Windsor Bldg.,<br>
Off CST Road, Kalina, Santacruz(E),<br>
Mumbai - 400 098.<br>
www.miraeassetmf.co.in
</TD>
</TR>
</table>
<hr width="793" noshade="true">
<sql:preparedStatement id="pst" conn="conn">
<sql:query>
SELECT DISTINCT A.VOUCHER_NO,A.DT_CASHFLOW,
TO_CHAR(A.AMT_FINAL,'99,99,99,99,990.00') AMT_FINAL,A.TDS,
TO_CHAR(A.AMT_ADJUST,'99,99,99,99,990.00') AMT_ADJUST,
TO_CHAR(A.AMT_NET,'99,99,99,99,990.00') AMT_NET,
TO_CHAR(A.AMT_ADVANCE,'99,99,99,99,990.00') AMT_ADVANCE,
TO_CHAR(A.AMT_PARTIAL,'99,99,99,99,990.00') AMT_PARTIAL,
A.EXPENSE_DESC,A.EXPENSE_CHARGE,A.ALLOCATION_PERIOD,
DECODE(B.ALLOCATION_ID,'7','(Quarterly AUM)',
'8',(SELECT (TO_CHAR(A.FROM_DT,'Mon-YYYY')||' - '||TO_CHAR(A.TO_DT,'Mon-YYYY')) ALLOCDT FROM DATA_AVG_AUM A, DATA_TRAN_BILL B
WHERE A.TRAN_ID = B.TRAN_ID
AND B.VOUCHER_NO='<%=voucher%>')) QTRAUM
FROM VW_VOUCHER_DETAIL A, DATA_TRAN_BILL B , MAST_ALLOCATION C
WHERE A.VOUCHER_NO = B.VOUCHER_NO
AND B.ALLOCATION_ID = C.ID
AND A.VOUCHER_NO='<%=voucher%>'
</sql:query>
<sql:resultSet id="rs">
<b>Approval Memo</b><br><br>
<table width="793" border="0" cellspacing="0" cellpadding="0" style="border: 1px solid #6e6e6e;">
<tr>
<td colspan="4" valign="TOP" align="center">
<%--------------------------%>
<table width="98%" border="0" cellspacing="0" cellpadding="0" >
<tr bgcolor="#c5c5c5" style="height:20px">
<td width="10"> </td>
<td width="200" nowrap><b>Vocuher No.</b></td>
<td width="10">:</td>
<td width="0" colspan="5"><sql:getColumn colName="VOUCHER_NO"/></td>
</tr>
<tr>
<td> </td>
<td><b>Allocation Period</b></td>
<td>:</td>
<td><sql:getColumn colName="ALLOCATION_PERIOD"/> <sql:getColumn colName="QTRAUM"/></td>
<td> </td>
<td><b>Expense Type</b></td>
<td>:</td>
<td><sql:getColumn colName="EXPENSE_DESC"/></td>
</tr>
<tr>
<td> </td>
<td><b>Cash Flow Date</b></td>
<td>:</td>
<td><sql:getColumn colName="DT_CASHFLOW"/></td>
<td> </td>
<td><b>Expense Charge To</b></td>
<td>:</td>
<td><sql:getColumn colName="EXPENSE_CHARGE"/></td>
</tr>
<tr>
<td> </td>
<td><b>Gross Amount</b></td>
<td>:</td>
<td><sql:getColumn colName="AMT_FINAL"/></td>
</tr>
<tr>
<%-- <td> </td>
<td><b>Gross Amount</b></td>
<td>:</td>
<td><sql:getColumn colName="AMT_FINAL"/></td>
--%>
<td> </td>
<td><b>TDS (%)</b></td>
<td>:</td>
<td><sql:getColumn colName="TDS"/>%</td>
</tr>
<tr>
<td> </td>
<td><b>Adjusted Amount</b></td>
<td>:</td>
<td><sql:getColumn colName="AMT_ADJUST"/></td>
</tr>
<tr>
<td> </td>
<td><b>Advance/Partial</b></td>
<td>:</td>
<td><sql:getColumn colName="AMT_ADVANCE"/> / <sql:getColumn colName="AMT_PARTIAL"/></td>
<%-- <td> </td>
<td><b>Net Payable</b></td>
<td>:</td>
<td><sql:getColumn colName="AMT_NET"/></td> --%>
</tr>
<tr>
<td> </td>
<td><b>Net Payable</b></td>
<td>:</td>
<td><b><sql:getColumn colName="AMT_NET"/></b></td>
</tr>
<tr>
<td colspan="4"> </td>
</tr>
<tr>
<td> </td>
<td><b>Narration</b></td>
<td>:</td>
<td colspan="5">
<sql:preparedStatement id="pst" conn="conn">
<sql:query>
SELECT PAYMENT_REMARKS FROM DATA_TRAN_BILL
WHERE VOUCHER_NO='<%=voucher%>'
</sql:query>
<sql:resultSet id="rs">
<sql:getColumn colName="PAYMENT_REMARKS"/>
</sql:resultSet>
</sql:preparedStatement>
</td>
</tr>
<!-- <tr>
<td colspan="4"> </td>
</tr>-->
<tr>
<td> </td>
<td><b>Scheme Allocation</b></td>
<td>:</td>
<td> </td>
</tr>
</table>
<%--------------------------%>
</td>
</tr>
<sql:preparedStatement id="pst" conn="conn">
<sql:query>
SELECT A.BANK_NAME,B.SCHEME_NAME SCHEME_DESC,
TO_CHAR(SUM(B.GROSS),'99,99,99,99,990.00') GROSS,
round(SUM(B.TDS),0) TDS,
TO_CHAR(SUM(B.ADVANCE),'99,99,99,99,990.00') ADVANCE,
TO_CHAR(SUM(B.PARTIAL),'99,99,99,99,990.00') PARTIAL,
TO_CHAR(SUM(B.NET),'99,99,99,99,990.00') NET
FROM VW_VOUCHER_ALLOCATION_DETAIL B, VW_SCHEME_ACCOUNT A
WHERE B.VOUCHER_NO='<%=voucher%>'
AND B.ID = A.EXPENSE_SCH_CODE
AND (B.GROSS>0 OR B.ADVANCE>0 OR B.PARTIAL>0)
GROUP BY A.BANK_NAME,B.SCHEME_NAME
ORDER BY A.BANK_NAME, B.SCHEME_NAME
</sql:query>
<tr>
<td colspan="4" align="center">
<%--------------------------%>
<DIV STYLE="height: 510px;" ID="fix">
<table width="750" border="0" cellspacing="1" cellpadding="0" style="border: 1px solid #6e6e6e;">
<tr bgcolor="#c5c5c5" style="height:20px;">
<td CLASS="BORDER_" style="border-bottom: 1px solid #6e6e6e;"><B>Custody Name</B></td>
<td CLASS="BORDER_" style="border-bottom: 1px solid #6e6e6e;"><B>Scheme Name</B></td>
<td CLASS="BORDER_" style="border-bottom: 1px solid #6e6e6e;"><B>Gross</B></td>
<td CLASS="BORDER_" style="border-bottom: 1px solid #6e6e6e;"><B>TDS</B></td>
<td CLASS="BORDER_" style="border-bottom: 1px solid #6e6e6e;"><B>Advance</B></td>
<td CLASS="BORDER_" style="border-bottom: 1px solid #6e6e6e;"><B>Partial</B></td>
<td CLASS="BORDER_" style="border-bottom: 1px solid #6e6e6e;"><B>Net</B></td>
</tr>
<sql:resultSet id="rs">
<tr style="height:20px">
<td CLASS="BORDER_"><b><sql:getColumn colName="BANK_NAME"/></b></td>
<td CLASS="BORDER_" ><sql:getColumn colName="SCHEME_DESC"/></td>
<td CLASS="BORDER_" align="right"><sql:getColumn colName="GROSS"/></td>
<td CLASS="BORDER_" align="right"><sql:getColumn colName="TDS"/></td>
<td CLASS="BORDER_" align="right" bgcolor="#e2d36d"><sql:getColumn colName="ADVANCE"/></td>
<td CLASS="BORDER_" align="right" bgcolor="#e2d36d"><sql:getColumn colName="PARTIAL"/></td>
<td CLASS="BORDER_" align="right"><sql:getColumn colName="NET"/></td>
</tr>
</sql:resultSet>
</sql:preparedStatement>
<%
for(int index=0;index<BankName_list.size();index++){
System.out.println("BankName_list "+BankName_list.get(index));
}
%>
<sql:preparedStatement id="pst" conn="conn">
<sql:query>
SELECT TO_CHAR(SUM(B.GROSS),'99,99,99,99,990.00') GROSS,
TO_CHAR(SUM(B.TDS),'99,99,99,99,990.00') TDS,
TO_CHAR(SUM(B.ADVANCE),'99,99,99,99,990.00') ADVANCE,
TO_CHAR(SUM(B.PARTIAL),'99,99,99,99,990.00') PARTIAL,
TO_CHAR(SUM(B.NET),'99,99,99,99,990.00') NET
FROM VW_VOUCHER_ALLOCATION_DETAIL B
WHERE B.VOUCHER_NO='<%=voucher%>'
AND (B.GROSS>0 OR B.ADVANCE>0 OR B.PARTIAL>0)
</sql:query>
<sql:resultSet id="rs">
<tr style="height:20px">
<td CLASS="BORDER_"> </td>
<td CLASS="BORDER_" align="right"><b>Grand Total </b></td>
<td CLASS="BORDER_" align="right"><b><sql:getColumn colName="GROSS"/></b></td>
<td CLASS="BORDER_" align="right"><b><sql:getColumn colName="TDS"/></b></td>
<td CLASS="BORDER_" align="right"><b><sql:getColumn colName="ADVANCE"/></b></td>
<td CLASS="BORDER_" align="right"><b><sql:getColumn colName="PARTIAL"/></b></td>
<td CLASS="BORDER_" align="right"><b><sql:getColumn colName="NET"/></b></td>
</tr>
</sql:resultSet>
</sql:preparedStatement>
<tr style="height:20px">
<td CLASS="BORDER_"> </td>
<td CLASS="BORDER_" align="right" colspan="2"><b>Adjusted Amount </b></td>
<td CLASS="BORDER_" colspan="5" align="right"><sql:getColumn colName="AMT_ADJUST"/></td>
</tr>
<tr style="height:20px" bgcolor="#c5c5c5">
<td CLASS="BORDER_"> </td>
<td CLASS="BORDER_" align="right" colspan="2"><b>Net Payable Amount </b></td>
<td CLASS="BORDER_" colspan="5" align="right"><b><sql:getColumn colName="AMT_NET"/></b></td>
</tr>
</sql:resultSet>
</sql:preparedStatement>
</table>
</DIV>
<%--------------------------%>
</td>
</tr>
<TFOOT>
<sql:preparedStatement id="pst" conn="conn">
<sql:query>
SELECT DECODE(CNT,1,
C.MAP_1 || ' ' ||
B.VENDOR_NAME,
' '
) DESCR
FROM
(
SELECT A.VOUCHER_NO,COUNT(DISTINCT(VENDOR_ID)) CNT,MAX(A.VENDOR_ID) VENDOR_ID,MAX(A.PAYMENT_MODE) PAYMENT_MODE
FROM DATA_TRAN_BILL A
GROUP BY A.VOUCHER_NO
) A,MAST_VENDOR B,MAST_PAYMENT_MODE C
WHERE A.VENDOR_ID=B.ID
AND A.PAYMENT_MODE=C.ID
AND A.VOUCHER_NO='<%=voucher%>'
</sql:query>
<sql:resultSet id="rs">
<TR>
<TD colspan="3" STYLE="font-size: 13px; "> <sql:getColumn colName="DESCR"/></TD>
</sql:resultSet>
</sql:preparedStatement>
<TD STYLE="font-size: 10px; ">
<DIV STYLE="height:60px; " ID="fix">
<sql:preparedStatement id="pst" conn="conn">
<sql:query>
SELECT DISTINCT V.BANK_NAME,V.ACC_NO,C.DESCR,V.IFSC_NEFT
FROM DATA_TRAN_BILL A,MAST_PAYMENT_MODE C, MAST_VENDOR V
WHERE A.PAYMENT_MODE = C.ID
AND A.VENDOR_ID = V.ID
AND C.DESCR IN ('NEFT','RTGS','RTGS/NEFT')
AND A.VOUCHER_NO = '<%=voucher%>'
</sql:query>
<sql:resultSet id="rs">
<table align="right" border="0" width="70%">
<tr>
<td>Bank Name : </td>
<td><sql:getColumn colName="BANK_NAME"/> </td>
</tr>
<tr>
<td>Account No. : </td>
<td><sql:getColumn colName="ACC_NO"/> </td>
</tr>
<tr>
<td><sql:getColumn colName="DESCR"/> Code : </td>
<td><sql:getColumn colName="IFSC_NEFT"/> </td>
</tr>
</table>
</sql:resultSet>
</sql:preparedStatement>
</DIV>
</TD>
</TR>
</TFOOT>
</table>
<br><br><br>
<table width="793" border="0" cellspacing="0" cellpadding="0">
<tr style="height:15px">
<td colspan="5"> </td>
</tr>
<tr align="center">
<td width="30"> </td>
<td width="153" style="border-top: 1px solid #6e6e6e;">Maker</td>
<td width="500"> </td>
<td width="153" style="border-top: 1px solid #6e6e6e;">Checker</td>
<td width="500"></td>
<td width="153" style="border-top: 1px solid #6e6e6e;">Approver</td>
<td width="30"> </td>
</tr>
</table><BR>
</DIV>
<BR>
</center>
<sql:closeConnection conn="conn"/>
The method println(boolean) in the type PrintStream is not applicable for the arguments
<sql:getColumn colName="SCHEME_DESC"/> is coming as empty here
There in no method is avaialable println with 0-arguments.
It seems you have mixed script lets and jstl tags together.
System.out.println( %><sql:getColumn colName="SCHEME_DESC"/><% ..

How to fetch from a jquery datatable an array of second colum cells subject to checkbox in first column

I have a table as follows
<table id="vainTbl6" class="dtable" cellpadding="3" cellspacing="1" border="0">
<thead>
<tr><th>check</td><th>Morphosal</th><th>goat </th><th>the other</th></tr>
</thead>
<tbody id="tbdy">
<tr class="gradeX">
<td><input type="checkbox" class = "chcktbl" /></td>
<td style="width:55%">-Approve the femuneration Gommiqee purpirt</td>
<td>pontpose</td></tr>
<tr class="gradeX">
<td><input type="checkbox" class = "chcktbl" /></td>
<td style="width:55%">-Declare a final truce</td>
<td>More</td></tr>
<tr class="gradeX"><td><input type="checkbox" class = "chcktbl" /></td>
<td style="width:55%">-Amend the articles of asscotonation</td>
<td>Four</td></tr>
<tr class="gradeX"><td><input type="checkbox" class = "chcktbl" /></td>
<td style="width:55%">-Re-elect Bandanna la banana for warden</td>
<td>Floor</td></tr>
</tbody>
</table>
and the first column is a checkbox. I need to fetch all the second column cells where the checkbox in the first column is set to true
I tried using this, but to no avail.
function extractRowCell(divNode){
alert(divNode.id);
$('#tbdy tr td').each(function() {
alert('hello');
var aRowData = this.cells
alert(aRowData[1].firstChild.value);
return aRowData;
});
}
The call is as follows:
<a id="la" href='#' onclick='extractRowCell(this.parentNode)' style="position:absolute; top:280px; left:350px;">Votes & Concerns</a>
The alert in the function triggers though with the correct value.
TIA
To iterate over the td's simply do the following.
$('#tbdy tr td').each(function() {
alert( $(this).text() );
});
You can do this
<table><tbody id="tbdy">
<tr class="gradeX">
<td><input type="checkbox" class = "chcktbl" /></td>
<td style="width:55%" class="item">-Approve the femuneration Gommiqee purpirt</td>
<td>pontpose</td></tr>
<tr class="gradeX">
<td><input type="checkbox" class = "chcktbl" /></td>
<td style="width:55%" class="item">-Declare a final truce</td>
<td>More</td></tr>
<tr class="gradeX"><td><input type="checkbox" class = "chcktbl" /></td>
<td style="width:55%" class="item">-Amend the articles of asscotonation</td>
<td>Four</td></tr>
<tr class="gradeX"><td><input type="checkbox" class = "chcktbl" /></td>
<td style="width:55%" class="item">-Re-elect Bandanna la banana for warden</td>
<td>Floor</td></tr>
</tbody>
</table>
<button>Get</button>
<script>
$("button").click(function(){
var ret="";
$("#tbdy tr td:first").each(function()
{
if($("input:checked").length!=0)
{
ret=$("input:checked").parent().parent().find("td.item").text();
}
});
alert(ret);
});
</script>

Categories