GWT grid widget with row & column headers? - java

I am looking for any GWT grid widget that needs to have row and column headers on X and Y axis. Those needs to be seamlessly scrollable across X and Y axis.
Essentially I am looking for a GWT widget as demonstrated in the below URL
jsfiddle.net/jschlick/Gv26h/
We need to prifix with http:// in the above URL. The above is completely implemented in Java script.
Is there any GWT widget available with above functionality?
Any help would be really appreciated.
<html>
<header>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style>
body, input {
/*font: 15px/1em Arial, Helvetica, sans serif;*/
}
-webkit-scrollbar {
height: 7px;
width: 7px;
-webkit-appearance: none;
}
-webkit-scrollbar-thumb {
background-color: rgba(0,0,0,.5);
border-radius: 4px;
-webkit-box-shadow: 0 0 1px rgba(255,255,255,.5);
}
#divHeader {
border-bottom: 1px solid #d7d7d7;
overflow: hidden;
padding: 0 0 5px 0;
width: 284px;
}
#firstcol {
border-right: 1px solid #d7d7d7;
height: 200px;
overflow: hidden;
padding: 0 10px;
}
#table_div {
height: 210px;
overflow: scroll;
position: relative;
width: 300px;
}
#table_div td {
}
</style>
<script type='text/javascript' src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
fnAdjustTable();
});
fnAdjustTable = function(){
var colCount = $('#firstTr>td').length; //get total number of column
var m = 0;
var n = 0;
var brow = 'mozilla';
jQuery.each(jQuery.browser, function(i, val) {
if(val == true){
brow = i.toString();
}
});
$('.tableHeader').each(function(i){
if (m < colCount){
if (brow == 'mozilla'){
$('#firstTd').css("width",$('.tableFirstCol').innerWidth());//for adjusting first td
$(this).css('width',$('#table_div td:eq('+m+')').innerWidth());//for assigning width to table Header div
}
else if (brow == 'msie'){
$('#firstTd').css("width",$('.tableFirstCol').width());
$(this).css('width',$('#table_div td:eq('+m+')').width()-2);//In IE there is difference of 2 px
}
else if (brow == 'safari'){
$('#firstTd').css("width",$('.tableFirstCol').width());
$(this).css('width',$('#table_div td:eq('+m+')').width());
}
else {
$('#firstTd').css("width",$('.tableFirstCol').width());
$(this).css('width',$('#table_div td:eq('+m+')').innerWidth());
}
}
m++;
});
$('.tableFirstCol').each(function(i){
if(brow == 'mozilla'){
$(this).css('height',$('#table_div td:eq('+colCount*n+')').outerHeight());//for providing height using scrollable table column height
}
else if(brow == 'msie'){
$(this).css('height',$('#table_div td:eq('+colCount*n+')').innerHeight()-2);
}
else {
$(this).css('height',$('#table_div td:eq('+colCount*n+')').height());
}
n++;
});
}
//function to support scrolling of title and first column
fnScroll = function(){
$('#divHeader').scrollLeft($('#table_div').scrollLeft());
$('#firstcol').scrollTop($('#table_div').scrollTop());
}
</script>
</header>
<body>
<table cellspacing="0" cellpadding="0" border="1" >
<tr>
<td id="firstTd">
</td>
<td>
<div id="divHeader">
<table cellspacing="0" cellpadding="10" border="1">
<tr>
<td>
<div class="tableHeader">28</div>
</td>
<td>
<div class="tableHeader">30</div>
</td>
<td>
<div class="tableHeader">32</div>
</td>
<td>
<div class="tableHeader">34</div>
</td>
<td>
<div class="tableHeader">36</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td valign="top">
<div id="firstcol">
<table cellspacing="0" cellpadding="10" border="1">
<tr>
<td class="tableFirstCol">32</td>
</tr>
<tr>
<td class="tableFirstCol">32.5</td>
</tr>
<tr>
<td class="tableFirstCol">33</td>
</tr>
<tr>
<td class="tableFirstCol">33.5</td>
</tr>
<tr>
<td class="tableFirstCol">34</td>
</tr>
<tr>
<td class="tableFirstCol">34.5</td>
</tr>
<tr>
<td class="tableFirstCol">36</td>
</tr>
<tr>
<td class="tableFirstCol">36.5</td>
</tr>
<tr>
<td class="tableFirstCol">38</td>
</tr>
</table>
</div>
</td>
<td valign="top">
<div id="table_div" onscroll="fnScroll()" >
<table width="500px" cellspacing="0" cellpadding="10" border="1">
<tr id="firstTr">
<td>Row1Col1</td>
<td>Row1Col2</td>
<td>Row1Col3</td>
<td>Row1Col4</td>
<td>Row1Col5</td>
</tr>
<tr>
<td>Row2Col1</td>
<td>Row2Col2</td>
<td>Row2Col3</td>
<td>Row2Col4</td>
<td>Row2Col5</td>
</tr>
<tr>
<td>Row3Col1</td>
<td>Row3Col2</td>
<td>Row3Col3</td>
<td>Row3Col4</td>
<td>Row3Col5</td>
</tr>
<tr>
<td>Row4Col1</td>
<td>Row4Col2</td>
<td>Row4Col3</td>
<td>Row4Col4</td>
<td>Row4Col5</td>
</tr>
<tr>
<td>Row5Col1</td>
<td>Row5Col2</td>
<td>Row5Col3</td>
<td>Row5Col4</td>
<td>Row5Col5</td>
</tr>
<tr>
<td>Row6Col1</td>
<td>Row6Col2</td>
<td>Row6Col3</td>
<td>Row6Col4</td>
<td>Row6Col5</td>
</tr>
<tr>
<td>Row7Col1</td>
<td>Row7Col2</td>
<td>Row7Col3</td>
<td>Row7Col4</td>
<td>Row7Col5</td>
</tr>
<tr>
<td>Row8Col1</td>
<td>Row8Col2</td>
<td>Row8Col3</td>
<td>Row8Col4</td>
<td>Row8Col5</td>
</tr>
<tr>
<td>Row9Col1</td>
<td>Row9Col2</td>
<td>Row9Col3</td>
<td>Row9Col4</td>
<td>Row9Col5</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</body>
</html>

Related

Getting text between html tags

So basically I have this html and what I want is the text under the tag that has the name:, for example I want this cb6a296b-c7ba-4228-b9f2-d6e39947814e, I've tried using soup but for some reason I always obtain a full html instead of the tags themselves. Is there any way of getting this name cb6a296b-c7ba-4228-b9f2-d6e39947814e?
html:
<td>
<div>
<h3>Id:</h3>
<table style="border: none">
<tbody>
<tr>
<td style="border: none"><b>id:</b></td>
<td style="border: none"><span style="margin-left: 15px">testuuid1</span></td>
</tr>
<tr>
<td style="border: none"><b>idtype:</b></td>
<td style="border: none"><span style="margin-left: 15px">uuid</span></td>
</tr>
<tr>
<td style="border: none"><b>territory:</b></td>
<td style="border: none"><span style="margin-left: 15px">GB</span></td>
</tr>
<tr>
<td style="border: none"><b>type:</b></td>
<td style="border: none"><span style="margin-left: 15px">cover</span></td>
</tr>
<tr>
<td style="border: none"><b>version:</b></td>
<td style="border: none"><span style="margin-left: 15px">aa3601f8-219a-43e6-be36-0aa49d2f0943</span></td>
</tr>
</tbody>
</table>
</div>
<div>
<h3>File:</h3>
<table style="border: none">
<tbody>
<tr>
<td style="border: none"><b>extension:</b></td>
<td style="border: none"><span style="margin-left: 15px">jpg</span></td>
</tr>
<tr>
<td style="border: none"><b>md5Checksum:</b></td>
<td style="border: none"><span style="margin-left: 15px">f5e1725f067a697805f4af28bef55720</span></td>
</tr>
<tr>
<td style="border: none"><b>mimeType:</b></td>
<td style="border: none"><span style="margin-left: 15px">image/jpeg</span></td>
</tr>
<tr>
<td style="border: none"><b>name:</b></td>
<td style="border: none"><span style="margin-left: 15px">cb6a296b-c7ba-4228-b9f2-d6e39947814e</span></td>
</tr>
<tr>
<td style="border: none"><b>path:</b></td>
<td style="border: none"><span style="margin-left: 15px"></span></td>
</tr>
</tbody>
</table>
</div>
<div>
<h3>FileInfo:</h3>
<table style="border: none">
<tbody>
<tr>
<td style="border: none"><b>created:</b></td>
<td style="border: none"><span style="margin-left: 15px">2022-08-09T17:05:12Z</span></td>
</tr>
<tr>
<td style="border: none"><b>createdBy:</b></td>
<td style="border: none"><span style="margin-left: 15px">admin</span></td>
</tr>
<tr>
<td style="border: none"><b>expires:</b></td>
<td style="border: none"><span style="margin-left: 15px">2032-06-26T23:30:00Z</span></td>
</tr>
<tr>
<td style="border: none"><b>updated:</b></td>
<td style="border: none"><span style="margin-left: 15px">2022-08-09T17:05:14Z</span></td>
</tr>
<tr>
<td style="border: none"><b>updatedBy:</b></td>
<td style="border: none"><span style="margin-left: 15px">admin</span></td>
</tr>
</tbody>
</table>
</div></td>
Program:
val document: Document = Jsoup.parse(requestBody[0])
val element = document.select("td:contains(name:)").get(0)
You can just give your <span> element an id:
...
<tr>
<td style="border: none"><b>name:</b></td>
<td style="border: none"><span id="file-name" style="margin-left: 15px">cb6a296b-c7ba-4228-b9f2-d6e39947814e</span></td>
</tr>
...
And then you can easily access the value of the field in javascript:
<script>
let fileName = document.getElementById('file-name').innerHTML
...
</script>

Selenium- WebDriver identifying Td value element which is inside the input tag

I am trying to identify the td value, the thing is inside TD i have input tag and i need to identify the value. My Td tag looks like below. I need to identify and get the value 4/11/2016. Trying to add the full source code
<div id="accountsSectionBottomContainer" class="acctBottom" default-path="/ui/app.php/AccountsBottomPane/21/acct_glance">
<div>
<div class="accountsModPLSQLReturn" data-aria-plsql-root="/ui/mod_plsql.php/aria/csrtools/" data-aria-plsql-url="dashboard_plan.plan_inst_unit_inst_dtls">
<div class="workbook_tabname">Accounts</div>
<script language="JavaScript" type="text/javascript"> self.focus(); </script>
<div id="account-name">
<style type="text/css"> .color-block dl { background-color: #F8F8FF; margin: 0; padding: 1em; } .white-block dl { font-size: 1.1em; margin: 0; padding: 1em; } .static-block dt { float: left; font-size: 1.1em; font-weight: bold; margin: 0; padding: 0; width: 300px; } .static-block dd { font-size: 1.1em; margin: 0 0 0 225px; padding: 0 0 5px 15px; } </style>
<script language="javascript" type="text/javascript"> $('.trgprdval').trigger('change'); var inFulfilmentStartDate_cal = new calendar3(document.main.inFulfillmentDate, "MM/DD/YYYY"); inFulfilmentStartDate_cal.year_scroll = true; inFulfilmentStartDate_cal.time_comp = false; function myCdidFunction() { var newCDID = document.getElementById('inClientDefinedIdentifier').value; document.getElementById('inNewCdid').value = newCDID; } function copyRadioVal(inputValue, origVal, inputName, name) { var hiddenValues = document.getElementsByClassName(name); console.log(inputName); console.log(name); console.log(document.getElementById(inputName)); x = document.getElementById(inputName).checked; if (x==true) { $("#"+origVal).val(inputValue); } } function copyCheckboxVal(inputValue, origVal, inputName, inPrimacyNo, inputId) { var x = document.getElementById(inputName).checked; if (x==true) { document.getElementById(origVal).value = inputValue; } if (x==false) { document.getElementById(origVal).value = ""; } var inputType = inPrimacyNo.concat(inputId); document.getElementById(inputType).value = inPrimacyNo; } function joinSelectVal(newInputName, oldInputId) { var selectval = document.forms["main"][oldInputId]; var selectedList = []; for (var i = 0; i < selectval.length; i++) { if (selectval[i].selected) { selectedList.push(selectval[i].value); } } var checkedStr = Array.join(selectedList, "~"); if (checkedStr.length == 0) { checkedStr = "NO#VALUE"; } document.getElementById(newInputName).value = checkedStr; } function validateInputsAndSubmit(button) { var valSuppFields = validateAcctSuppFields('.accountsForm'); if(!valSuppFields['isValid']) { alert(valSuppFields['errorMsg']); return false; } lockAndSubmitForm(button); } </script>
<div class="color-block">
<div class="white-block">
<form class="accountsForm" name="main" method="post" action="/ui/mod_plsql.php/aria/csrtools/dashboard_plan_m.plan_unit_instance_save_m" onsubmit="return false;">
<font size="3">
<br/>
<br/>
<table class="data-table clear-both" cellspacing="0">
<colgroup>
<tbody>
<tr>
<tr class="dataRow1 even">
<td valign="top" style="text-align: left;">
<td valign="top" style="text-align: left;">10089723</td>
<td valign="top" style="text-align: left;">Yes</td>
<td valign="top" style="text-align: left;">Invoiced</td>
<td valign="top" style="text-align: left;">
<input type="hidden" value="10089723" name="INSERVICES[0][inServiceNo]"/>
<input type="hidden" value="1" name="INSERVICES[0][inFulfillmentStatus]"/>
<input type="hidden" value="1" name="INSERVICES[0][inFulfillmentBasedInd]"/>
<input id="inFulfillmentDate10089723" type="text" readonly="readonly" value="4/11/2016" name="INSERVICES[0][inFulfillmentDate]"/>
</td>
</tr>
<tr class="dataRow1 even">
<td valign="top" style="text-align: left;">
<td valign="top" style="text-align: left;">10089726</td>
<td valign="top" style="text-align: left;">Yes</td>
<td valign="top" style="text-align: left;">Invoiced</td>
<td valign="top" style="text-align: left;">
<input type="hidden" value="10089726" name="INSERVICES[1][inServiceNo]"/>
<input type="hidden" value="1" name="INSERVICES[1][inFulfillmentStatus]"/>
<input type="hidden" value="1" name="INSERVICES[1][inFulfillmentBasedInd]"/>
<input id="inFulfillmentDate10089726" type="text" readonly="readonly" value="4/11/2016" name="INSERVICES[1][inFulfillmentDate]"/>
</td>
</tr>
<tr class="dataRow1 even">
<td valign="top" style="text-align: left;">
<td valign="top" style="text-align: left;">10089727</td>
<td valign="top" style="text-align: left;">Yes</td>
<td valign="top" style="text-align: left;">Invoiced</td>
<td valign="top" style="text-align: left;">
<input type="hidden" value="10089727" name="INSERVICES[2][inServiceNo]"/>
<input type="hidden" value="1" name="INSERVICES[2][inFulfillmentStatus]"/>
<input type="hidden" value="1" name="INSERVICES[2][inFulfillmentBasedInd]"/>
<input id="inFulfillmentDate10089727" type="text" readonly="readonly" value="4/11/2016" name="INSERVICES[2][inFulfillmentDate]"/>
</td>
</tr>
<tr class="dataRow1 even">
<td valign="top" style="text-align: left;">
<td valign="top" style="text-align: left;">10089730</td>
<td valign="top" style="text-align: left;">Yes</td>
<td valign="top" style="text-align: left;">Invoiced</td>
<td valign="top" style="text-align: left;">
<input type="hidden" value="10089730" name="INSERVICES[3][inServiceNo]"/>
<input type="hidden" value="1" name="INSERVICES[3][inFulfillmentStatus]"/>
<input type="hidden" value="1" name="INSERVICES[3][inFulfillmentBasedInd]"/>
<input id="inFulfillmentDate10089730" type="text" readonly="readonly" value="4/11/2016" name="INSERVICES[3][inFulfillmentDate]"/>
</td>
</tr>
<tr class="dataRow1 even">
<td valign="top" style="text-align: left;">
<td valign="top" style="text-align: left;">10089747</td>
<td valign="top" style="text-align: left;">Yes</td>
<td valign="top" style="text-align: left;">Invoiced</td>
<td valign="top" style="text-align: left;">
<input type="hidden" value="10089747" name="INSERVICES[4][inServiceNo]"/>
<input type="hidden" value="1" name="INSERVICES[4][inFulfillmentStatus]"/>
<input type="hidden" value="1" name="INSERVICES[4][inFulfillmentBasedInd]"/>
<input id="inFulfillmentDate10089747" type="text" readonly="readonly" value="4/11/2016" name="INSERVICES[4][inFulfillmentDate]"/>
</td>
</tr>
</tbody>
</table>
<br/>
<br/>
<font size="3">
<br/>
<br/>
<table class="simple" cellspacing="0">
<input type="hidden" value="8179" name="inPlanNo"/>
<input type="hidden" value="4066308" name="inPlanUnitInstanceNo"/>
<input id="inNewCdid" type="hidden" name="inClientDefinedIdentifier"/>
<input type="hidden" value="MasterPlan" name="inSelectedPlan"/>
<input type="hidden" value="19328197" name="inPlanInstanceNo"/>
<div class="form-buttons">
<input type="hidden" value="AAAAAAUJTTz9lWKS_TgqUANHCenOnmxH2IQHclhl2zoruTE55z7CFHIdaAAJNyGlNLLnb5f-97HVxpFchLgkkTjIFz9d_I_sKfI7EQd83gmsfyFtQA==" name="as_sfid"/>
<input type="hidden" value="yli8W38Xf7v_849HentO" name="as_fid"/>
</form>
</div>
</div>
</div>
<input id="inFulfillmentDate10089723" type="text" readonly="readonly" value="4/11/2016" name="INSERVICES[0][inFulfillmentDate]"/>
</td>
Hi in case you want to identify value="4/11/2016" you can directly use
in case of dynamic id plz use like
MyDynamicID = "//*[starts-with(#id,'inFulfillmentDate')]"
String value = driver.findElement(By.id(MyDynamicID )).getText();
now print string in the console
UPADTE
// our id = inFulfillmentDate pattern
List<WebElement> myDate = driver.findElements(By.xpath("//*[starts-with(#id,'inFulfillmentDate')]"));
System.out.println(myDate.size());
// now print all value
for(int i=0;i<myDate.size();i++){
System.out.println("value is : " +myDate.get(i).getAttribute("value"));
}
Belwo is the console output
6
value is : 4/11/2016
value is : 4/11/2016
value is : 4/11/2016
value is : 4/11/2016
value is : 4/11/2016
value is : 4/11/2016

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.

JSP how to store image into database from html input

I'm trying to write a code that stores images into database, then later display it on the webpage using the rollnum to retrieve it from the database. I've tried all i could but still no good, i tried reading some tutorials but still no good, anyways here's the code i'm working on. I'd be very grateful if someone could help, Thanks in Advance.
<%#page import="java.sql.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Registration Page</title>
<style>
body{
background-image: url('bg.png');
background-repeat: repeat;
font-family: Courier New;
margin:auto;
width: 1000px;
}
.wrap{
margin-top:10px;
border:solid 1px #000;
height:900px;
}
.header{
font-size: 50px;
font-weight: bold;
font-family: Courier New;
text-align: center;
}
.border{
border-bottom: solid 1px #000;
margin-left: 30px;
margin-right: 30px;
}
.box{
border: solid 1px #000;
padding: 8px;
margin: 30px;
}
</style>
</head>
<body>
<div class="wrap">
<table>
<form method="post">
<br/>
<tr>
<td> Roll Number:</td> <td><input type="text" name="rollnum"/></td>
</tr>
</div>
<tr>
<td> First Name:</td> <td><input type="text" name="fname"/></td>
</tr>
<tr>
<td> Last Name:</td> <td><input type="text" name="lname"/></td>
</tr>
<tr>
<td> Course Name:</td> <td><input type="text" name="course"/></td>
</tr>
<tr>
<td> Gender:</td> <td>Male:<input type="radio" name="gender" value="Male"/> Female:<input type="radio" name="gender" value="Female"/></td>
</tr>
<tr>
<td> Address:</td> <td><input type="text" name="addr"/></td>
</tr>
<tr>
<td> State:</td> <td><input type="text" name="state"/></td>
</tr>
<tr>
<td> Photo:<input type="file" name="photo"/></td>
</tr>
<tr>
<td> <input type="submit" value="Submit" name="submit"/></td>
</tr>
</form>
</table>
<%
try{
if(request.getParameter("submit") != null){
Connection conn;
PreparedStatement prep;
String sql;
String url = "jdbc:derby://localhost:1527/reg";
Class.forName("org.apache.derby.jdbc.ClientDriver");
conn = DriverManager.getConnection(url,"uname","pass");
sql =
"insert into student (rollnum,fname,lname,course,gender,addr,state,photo)"
+"values(?,?,?,?,?,?,?,?)";
ResultSet rs = null;
prep = conn.prepareStatement(sql);
prep.setInt(1, Integer.parseInt(request.getParameter("rollnum")));
prep.setString(2, request.getParameter("fname"));
prep.setString(3, request.getParameter("lname"));
prep.setString(4, request.getParameter("course"));
prep.setString(5, request.getParameter("gender"));
prep.setString(6, request.getParameter("addr"));
prep.setString(7, request.getParameter("state"));
//prep.setString(8, request.getParameter("photo"));
Blob blob = rs.getBlob(request.getParameter("photo"));;
prep.setBlob(8, blob);
int n = prep.executeUpdate();
if(n>0){
%>
<div class="box">Registration Successful!! <b>Login Now!!</b></div>
<%
}
}
}
catch(ClassNotFoundException e){
}
catch(NumberFormatException n){
}
%>
</div>
</body>
You can follow this way:
Get the image
Convert the image with the base64 rappresentation
Store the base64 into your db
when you need the image convert again the base64 into the image

Getting this "org.xhtmlrenderer.render.BlockBox cannot be cast to org.xhtmlrenderer.newtable.TableBox" while trying to render a pdf

I am getting this error while I am trying to render a pdf. I am using Nicolas Leroux's PDF module for the play framework.
This is the entire stackstrace: Pastebin. Googling only reveals 4 results. They suggest removing any float properties, and position attributes, which I have removed, jsut to give it a try. I am still facing this problem. Has anyone been able to solve the issue?
EDIT: This is the html that renders the pdf:
#{extends 'main.html' /} #{set title:'Salary Details' /}
<html>
<head>
<title>Employee Name</title>
<style>
body {
font: 9pt Arial, Helvetica, sans-serif;
}
.container {
margin: 0 auto;
width: 1000px;
border: 1px solid black;
padding: 12px;
}
.logoClass {
width: 200px;
height: 85px;;
}
.companyAddressClass {
width: 60%;
margin: 0 auto;
font-size: 17px;
font-weight: bold;
text-align: center;
}
.empClass table {
width: 100%;
border: 1px solid #ccc;
border-collapse: collapse;
margin: 10px 0px;
}
.empClass table th,td {
border: 1px solid #ccc;
padding: 5px 5px;
}
.empClass table th {
background: #f2f2f2;
}
</style>
</head>
<body onload="window.print();">
%{for(int i=0;i<dataList.size ();i=i+1){}%
<div class="container" style="page-break-after:#{if i == dataList.size()-1} avoid;#{/if} #{else} always; #{/else}">
<div class="logoClass"></div>
<div class="companyAddressClass">
${dataList.get(i).distributorName},<br /> ${dataList.get(i).city},<br />
${dataList.get(i).state} <br /> <br /> <span>Payslip for the
month of ${dataList.get(i).salaryMonth}</span>
</div>
<br class="clear" />
<div class="empClass">
<table border="1">
<tr>
<td>Employee No: ${dataList.get(i).employeeNumber}</td>
<td>Location: ${dataList.get(i).location}</td>
</tr>
<tr>
<td>Name: ${dataList.get(i).employeeName}</td>
<td>Salary for the M/O: ${dataList.get(i).salaryMonth}</td>
</tr>
<tr>
<td>Bank Name: ${dataList.get(i).bankName}</td>
<td>Designation: ${dataList.get(i).designation}</td>
</tr>
<tr>
<td>Bank Acc No: ${dataList.get(i).accountNumber}</td>
<td>Join Date: ${dataList.get(i).joinDate}</td>
</tr>
<tr>
<td>PF No: ${dataList.get(i).pfNumber}</td>
<td>Gender: ${dataList.get(i).gender}</td>
</tr>
<tr>
<td>ESI No: ${dataList.get(i).esiNumber}</td>
<td>LOP: ${dataList.get(i).lop}</td>
</tr>
<tr>
<td>PAN No: ${dataList.get(i).panNumber}</td>
<td>Days Worked: ${dataList.get(i).daysWorked}</td>
</tr>
</table>
</div>
<br />
<div class="empClass">
<table border="1">
<tr>
<th colspan="3">Earnings</th>
<th colspan="2">Deductions</th>
</tr>
<tr>
<th align="left">Header</th>
<th align="right">Actual</th>
<th align="right">Paid</th>
<th align="left">Header</th>
<th align="right">Paid</th>
</tr>
<tr>
<td>Basic</td>
<td align="right">${dataList.get(i).basic}</td>
<td align="right">${dataList.get(i).basic}</td>
<td>PF</td>
<td align="right">${dataList.get(i).pf}</td>
</tr>
<tr>
<td>HRA</td>
<td align="right">${dataList.get(i).hra}</td>
<td align="right">${dataList.get(i).hra}</td>
<td>ESICEE</td>
<td align="right">${dataList.get(i).esicee}</td>
</tr>
<tr>
<td>Conveyance Allowance</td>
<td align="right">${dataList.get(i).conveynanceAllowance}</td>
<td align="right">${dataList.get(i).conveynanceAllowance}</td>
<td>ESICEE(PWS)</td>
<td align="right">${dataList.get(i).esiceePWS}</td>
</tr>
<tr>
<td>Medical Allowance</td>
<td align="right">${dataList.get(i).medicalAllowances}</td>
<td align="right">${dataList.get(i).medicalAllowances}</td>
<td>PT</td>
<td align="right">${dataList.get(i).pt}</td>
</tr>
<tr>
<td>Special Allowance</td>
<td align="right">${dataList.get(i).specialAllowance}</td>
<td align="right">${dataList.get(i).specialAllowance}</td>
<td>PT(PWS)</td>
<td align="right">${dataList.get(i).ptPWS}</td>
</tr>
<tr>
<td>Incentives</td>
<td align="right">${dataList.get(i).midMonthAmountPWS}</td>
<td align="right">${dataList.get(i).midMonthAmountPWS}</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Other Allowances</td>
<td align="right">${dataList.get(i).otherAllowance}</td>
<td align="right">${dataList.get(i).otherAllowance}</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="3" align="right">Total
Earnings:${dataList.get(i).totalEarnings}</td>
<td colspan="2" align="right">Total Deduction
:${dataList.get(i).totalDeduction}</td>
</tr>
<tr>
<td colspan="3"> </td>
<td colspan="2" align="right"><strong>Salary Credited
: ${dataList.get(i).salaryCredited}</strong></td>
</tr>
</table>
<table>
<thead>
<tr>
<th>Position Title</th>
<th>City Name</th>
<th>State Name</th>
</tr>
</thead>
<thead>
<tr>
..
..
..
..
<th>${dataList.get(i).positionTitle}</th>
<th>${dataList.get(i).cityName}</th>
<th>${dataList.get(i).stateName}</th>
</tr>
</thead>
</table>
<br>
<table>
<thead>
<tr>
<th>Some Header</th>
<th>Some Header</th>
<th>Some Header</th>
<th>Some Header</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">Values</td>
..
..
..
..
..
</tr>
</tbody>
</table>
</div>
<div>
<span style="font-size: 15px; font-weight: bold;"> Salary
Credited Amount(In Words): ${dataList.get(i).salaryCreditedInWord} </span>
</div>
</div>
<br />
<br />
%{}}%
</body>
</html>
I am using Windows 7 and Tomcat6 as the testing environment, the same environment that people over here are facing trouble with.
Thanks.
This commit is a fix for your problem. You can download the whole class and put it in your source code, so you haven't to rebuild the library jar.
If you are facing this issue, to fix this just add a span tag inside the td and add the style to that span tag. Example:
<td>
<span style = style="position: absolute;">
</td>
Basically if you add the style to the td, you would get the error because of the bug in fly saucer pdf.

Categories