Posts Tagged ‘table’

 

English: example of a data table with rollup f...

 

This tag is used to create table on the page. The component is rendered as an html element. UIColumn child components are responsible for rendering columns of the table. In these columns you can put any type of component like input text box, output text, command button etc.

<h:column> tag is used to create column. There can be many column tags within dataTable tag. You can set header and footer in this table. For this <f:facet> tag is used. data table component and its children column component can use header and footer facet.

 

 

We can associate this table element to backing bean. So we can obtain data from this backing bean and display it on the table. Association of backing bean can also be helpful for event handling purpose. Suppose we inserted command button in columns of the table then event handling can be applied here. If you want to customize the table then cascading stylesheet (CSS) can be used. This will help you to enhance the appearance of the table’s headers, footer, rows, columns.

 

This section provides you the code to which uses this tag and some of its attributes. It uses backing bean that supplies data to the data table to be rendered to the cells of the columns of the table.

code description :

 

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>

<f:view><html><body>
<h:form>
<br><br><br>
<h:dataTable id="dt1" value="#{TableBean.perInfoAll}" var="item" bgcolor="#F1F1F1" border="10" cellpadding="5" cellspacing="3" first="0" rows="4" width="50%" dir="LTR" frame="hsides" rules="all" summary="This is a JSF code to create dataTable." >

<f:facet name="header">
<h:outputText value="This is 'dataTable' demo" />
</f:facet>

<h:column>
<f:facet name="header">
<h:outputText value="id" />
</f:facet>
<h:outputText value="#{item.id}"></h:outputText>
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="name"/>
</f:facet>
<h:outputText value="#{item.name}"></h:outputText>
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="phone"/>
</f:facet>
<h:outputText value="#{item.phone}"></h:outputText>
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="city"/>
</f:facet>
<h:outputText value="#{item.city}"></h:outputText>
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="pin"/>
</f:facet>
<h:outputText value="#{item.pin}"></h:outputText>
</h:column>

<f:facet name="footer">
"The End" />
</f:facet>

</h:dataTable><br><br>

</h:form>
</body></html></f:view>

 

Rendered Output :

 



In this example we have used <h:dataTable> tag. This <h:dataTable> tag has many attributes to give form and shape to the table and getting data from backing bean’s attribute to display this data to the columns of the table. <f:facet> tag is used to create a header and a
footer for a dataTable component and it can create the same for columns also. So in this example we have used facet tag in dataTabe tag to create header and footer of the table component and in column tag also to create header for column. In this example, “This is ‘dataTable’ demo” is the header and “The End” is the footer for the table and “id” “name” “phone” “city” “pin” are headers for columns. In his example we have populated data to the table from bean named “TableBean”. It contains an attribute “perInfoAll” that is an array of objects of type “perInfo” class which contains some attributes like id, name, phone, city, pin that is to be displayed on the table. In the value attribute of dataTable tag, we have specified the binding expression to bind this component to the bean (
value="#{TableBean.perInfoAll}") and value specified in var attribute is used to populate data to the column of the table from attributes defined in class perInfo (value="#{item.id}"). The code for the bean has been given below (remember to specify it in faces-cocfig.xml file) :

 

public class TableBean {

private perInfo[] perInfoAll = new perInfo[]{
new perInfo(101, "CHANDAN", "9891444444", "aaa", 11111),
new perInfo(102, "RAVI", "9911666666", "bbb" ,22222),
new perInfo(103, "JOHN", "9313888888", "ccc", 33333),
new perInfo(104, "ANDREW", "9911222222", "ddd" , 44444),
new perInfo(105, "SYMONDS", "9313999999", "eee", 55555),
};

public perInfo[] getperInfoAll() {
return perInfoAll;
}

public class perInfo {
int id;
String name;
String phone;
String city;
int pin;

public perInfo(int id, String name, String phone, String city, int pin) {
this.id = id;
this.name = name;
this.phone = phone;
this.city = city;
this.pin= pin;
}

public int getid() {
return id;
}

public String getname() {
return name;
}

public String getphone() {
return phone;
}

public String getcity() {
return city;
}

public int getpin() {
return pin;
}

}

}

 

HTML Source Code:

 

<html>
     <body>
          <form id="_id0" method="post" action="/dt/data.jsf;jsessionid
=B95AF7B5F7D80BCB5638B91AC8154C33" enctype="application/x-www-form-urlencoded">
              <br><br><br>
		<table id="_id0:dt1" bgcolor="#F1F1F1" border="10"
 cellpadding="5" cellspacing="3" dir="LTR" frame="hsides" rules="all"
 summary="This is a JSF code to create dataTable." width="50%">
                    <thead>
                       <tr><th colspan="5" scope="colgroup">This is
 'dataTable' demo</th></tr>
                       <tr>
                          <th scope="col">id</th>
                          <th scope="col">name</th>
                          <th scope="col">phone</th>
                          <th scope="col">city</th>
                          <th scope="col">pin</th>
                       </tr>
                    </thead>
                    <tfoot>
                       <tr><td colspan="5">The End</td></tr>
                    </tfoot>
                    <tbody>
                        <tr>
                           <td>101</td>
                           <td>CHANDAN</td>
                           <td>9891444444</td>
                           <td>aaa</td>
                           <td>11111</td>
                        </tr>
                        <tr>
                           <td>102</td>
                           <td>RAVI</td>
                           <td>9911666666</td>
                           <td>bbb</td>
                           <td>22222</td>
                        </tr>
                        <tr>
                           <td>103</td>
                           <td>JOHN</td>
                           <td>9313888888</td>
                           <td>ccc</td>
                           <td>33333</td>
                        </tr>
                        <tr>
                           <td>104</td>
                           <td>ANDREW</td>
                           <td>9911222222</td>
                           <td>ddd</td>
                           <td>44444</td>
                        </tr>
                    </tbody>
                </table>
                <br><br>
		<input type="hidden" name="_id0" value="_id0" />
         </form>
    </body>
</html>

 

This tag has some attributes. These are listed below :

 

  • id : This is used to uniquely identify the table component. This must be unique within the closest parent component.
  • value : It represents the value of the component. It represents the value over which iteration is to be done. It may be an array or any iterator object .
  • var : This is the name of the variable created by the data table that represents the current item in the value. This attribute helps exposing the data in the rows of the table.
  • bgcolor : This attribute is used to set the background color for the table.
  • border : We can set the width of the table’s border around the table.
  • cellpadding : This sets the space between the content and the border of the cell.
  • cellspacing : It specifies the amount of space to leave between cells.
  • first : This is used to specify the row number of the first row from which displaying is to be started onwards. Suppose, this property is set to 3,displaying will be started from the third row of the underlying data.
  • rows : This attribute specifies the number of rows to display. This displaying will be started from the index specified in the “first” attribute. If we set this attribute to zero then all rows will be displayed.
  • width : This is used to set the width of the entire table. Its value is specified in %. Suppose we set it to 50% then this table will be shown in the 50% space of the width of your screen.
  • dir : This attribute indicates the direction of the text to be displayed in the cell. It takes “LTR” (left-to-right) and “RTL” (right-to-left) values. If we don’t specify this attribute then the content will be displayed in center.
  • frame : This attribute specifyes which sides of the frame surrounding this table will be visible. This attribute can take some values shown below :

 

  1. none  No side, Default Value
  2. above  Top side only
  3. below  Bottom side only
  4. hsides   Top and bottom sides only
  5. vsides   Right and left sides only
  6. lhs   Left hand side only
  7. rhs  Right hand side only
  8. box   All four sides 
  9. border  All four sides

 

  • rules : This attribute is used to draw lines between cells. It can take some values given below :
    1. none   No rules, default value
    2. groups  Between row groups
    3. rows   Between rows only
    4. cols  Between columns only
    5. all   Between all rows and columns
  • summary : You can specify summary of the purpose of the table.
  • rendered : It takes boolean value.This indicates whether or not this component should be rendered. Its default value is “true”. If it is set to false then it prevents rendering of this component to the page.
  • captionClass : Space separated list of CSS class or classes that will be applied to any caption generated for this table.
  • captionStyle : It specifies CSS style or styles to be applied when this caption is rendered.
  • columnClasses : Comma seperated list of CSS classes that will be applied to the columns of this table.
  • footerClass : This attribute takes Space-separated list of CSS style class or classes that will be applied to aheaderter generated for this table.
  • headerClass : This attribute takes Space-separated list of CSS style class or classes that will be
    applied to any header generated for this table.
  • rowClasses : It is a list of CSS classes applied to the rows of the table.These classes should be separated by comma. If we want to apply CSS class for individual rows then we can specify space separated list of CSS classes. Style classes are applied to rows in the same order that they are
    defined. If we have two CSS classes then first class is applied to the first row and the second one is applied to the second. Then again in the third row, the first CSS is applied and so on. This process goes on till the last row of the table. 
  • lang :  It sets the base language of an element?s attributes and text i.e. the language used in the generated markup for this component.
  • styleClass : It sets the name of CSS classor classes that is applied at the time of rendering the element.
  • title : The title attribute is used to set the tooltip text to display for the rendered  component.Tooltip describes an element when rendered to the client. 
  • binding : It is a value binding expression that is used to link component to a property in a backing bean.
  • onclick : It sets the JavaScript code to execute when a pointer button is clicked over this element.
  • ondblclick : It sets the JavaScript code to execute when a pointer button is double clicked over this element.
  • onkeydown : It sets the JavaScript code to execute when a key is pressed down over this element.
  • onkeypress : It sets the JavaScript code to execute when a key is pressed and released over this element.
  • onkeyup : It sets the JavaScript code to execute when a key is released over this element.
  • onmousedown : It sets the JavaScript code to execute when a pointer button is pressed down over this element.
  • onmousemove : It sets the JavaScript code to execute when a pointer button is moved within this element.
  • onmouseout : It sets the JavaScript code to execute when a pointer button is moved away from this element.
  • onmouseover : It sets the JavaScript code to execute when a pointer button is moved onto this element.
  • onmouseup : It sets the JavaScript code to execute when a pointer button is released over this element.

 

 

Using client side JavaScript is an efficient way to validate the user input in web forms. When there are many fields in the form, the JavaScript validation becomes too complex.

The JavaScript class presented here makes the form validations many times easier.

Contents

  1. Download the JavaScript form validation script
  2. Using the form validation script
  3. Adding a custom validation
  4. Table of Validation Descriptors
  5. Showing the form validation errors next to the element
  6. ‘Conditional’ form validations
  7. Form validation without coding!

How to add JavaScript Form Validation quickly

First, download the JavaScript form validation script here.
The zip file contains the javascript file, examples.

The script has a catalog of almost all the common validation types built-in.

The idea is to create a set of “validation descriptors” associated with each element in a form. The “validation descriptor” is nothing but a string specifying the type of validation to be performed.

Each field in the form can have zero one or more validations. For example, you can have an input field that should not be empty, should be less than 25 chars and should be alpha-numeric.

In other words, in order to validate a field, you just associate a set of validation descriptors for each input field in the form.

Just Choose Validations!
Simfatic Forms is a feature-rich web form maker.
You just have to choose the validations. More info & downloads

Using the form validation script

  1. Include gen_validatorv4.js in your html file just before closing the HEAD tag
<script src="gen_validatorv4.js" type="text/javascript"></script>
</head>
  1. Just after defining your form, create a Validator() object passing the name of the form
<form id='myform' action="">
 <!----Your input fields go here -->
 </form>
<script type="text/javascript">
 var frmvalidator  = new Validator("myform");
                     //where myform is the name/id of your form
  1. Now, add the validations required
frmvalidator.addValidation("FirstName","req","Please enter your First Name");

The format of the addValidation() function is:

frmvalidator.addValidation(Field Name, Validation Descriptor, Error String);

See below for the complete list of validation descriptors. The third parameter ( Error string ) is optional.
You can add any number of validations to a field.

frmvalidator.addValidation("FirstName","req","Please enter your First Name");
frmvalidator.addValidation("FirstName","maxlen=40",
                                          "Max length for FirstName is 40");

Example

Here is a complete example:

<form action="" id="myform" >
<p>
    <label for='FirstName'>First Name:</label>
    <input type="text" id="FirstName" name="FirstName" />
</p>
<p>
    <label for='LastName'>Last Name:</label>
    <input type="text" id="LastName" name="LastName" />
</p>
<p>
    <label for='EMail'>EMail:</label>
    <input type="text" id="EMail" name="EMail" />
</p>
<p>
    <label for='Phone'>Phone:</label>
    <input type="text" id="Phone" name="Phone" />
</p>
<p>
    <label for='Address'>Address:</label>
    <textarea cols="20" rows="5" id="Address" name="Address"></textarea>
</p>
<p>
    <label for='Country'>Country:</label>
    <select id="Country"  name="Country">
        <option value="000" selected="selected">[choose yours]</option>
        <option value="008">Albania</option>
        <option value="012">Algeria</option>
        <option value="016">American Samoa</option>
        <option value="020">Andorra</option>
        <option value="024">Angola</option>
        <option value="660">Anguilla</option>
        <option value="010">Antarctica</option>
        <option value="028">Antigua And Barbuda</option>
        <option value="032">Argentina</option>
        <option value="051">Armenia</option>
        <option value="533">Aruba</option>
    </select>
</p>
<p>
    <input type="submit" name="submit" value="Submit">
</p>
</form>
<script  type="text/javascript">
 var frmvalidator = new Validator("myform");
 frmvalidator.addValidation("FirstName","req","Please enter your First Name");
 frmvalidator.addValidation("FirstName","maxlen=20",
        "Max length for FirstName is 20");
 frmvalidator.addValidation("LastName","req");
 frmvalidator.addValidation("LastName","maxlen=20");
 frmvalidator.addValidation("Email","maxlen=50");
 frmvalidator.addValidation("Email","req");
 frmvalidator.addValidation("Email","email");
 frmvalidator.addValidation("Phone","maxlen=50");
 frmvalidator.addValidation("Phone","numeric");
 frmvalidator.addValidation("Address","maxlen=50");
 frmvalidator.addValidation("Country","dontselect=000");
</script>

Some Additional Notes

  • The form validators should be created only after defining the HTML form (only after the tag. )
  • Your form should have a distinguished name. If there are more than one form in the same page, you can add validators for each of them. The names of the forms and the validators should not clash.
  • You can’t use the javascript onsubmit event of the form if it you are using this validator script. It is because the validator script automatically overrides the onsubmit event. If you want to add a custom validation, see the section below

Adding a custom validation

If you want to add a custom validation, which is not provided by the validation descriptors, you can do so. Here are the steps:

  1. Create a javascript function which returns true or false depending on the validation
function DoCustomValidation()
{
  var frm = document.forms["myform"];
  if(frm.pwd1.value != frm.pwd2.value)
  {
    sfm_show_error_msg('The Password and verified password does not match!',frm.pwd1);
    return false;
  }
  else
  {
    return true;
  }
}

sfm_show_error_msg() function displays the error message in your chosen style. The first parameter is the error message and the second parameter is the input object.

  1. Associate the validation function with the validator object.
frmvalidator.setAddnlValidationFunction("DoCustomValidation");

The custom validation function will be called automatically after other validations.

If you want to do more than one custom validations, you can do all those validations in the same function.

function DoCustomValidation()
{
  var frm = document.forms["myform"];
  if(false == DoMyValidationOne())
  {
    sfm_show_error_msg('Validation One Failed!');
    return false;
  }
  else
  if(false == DoMyValidationTwo())
  {
    sfm_show_error_msg('Validation Two Failed!');
    return false;
  }
  else
  {
    return true;
  }
}

where DoMyValidationOne() and DoMyValidationTwo() are custom functions for validation.

Clear All Validations

In some dynamically programmed pages, it may be required to change the validations in the form at run time. For such cases, a function is included which clears all validations in the validator object.

frmvalidator.clearAllValidations();

This function call clears all validations you set.

Set focus on validation failure

By default, if there is a validation error, the focus is set on the input element having the error. You can disable this behavior by calling:

frmvalidator.EnableFocusOnError(false);

Table of Validation Descriptors

Validation Descriptor Usage
required or
req
The field should not be empty.Note that this validation if for fields like Textbox and multi-line text box. For ‘selections’ like drop down and radio group, use an appropriate validation like ‘dontselect’ or ‘selone_radio’.
maxlen=??? or
maxlength=???
Limits the length of the input.
For example, if the maximum size permitted is 25, give the validation descriptor as “maxlen=25″
minlen=??? or
minlength=???
Checks the length of the entered string to the required minimum.
Example “minlen=5″
alphanumeric or
alnum
The input can contain alphabetic or numeric characters only.
(Note that space or punctuation also are not allowed since those characters are not alpha numeric)
alphanumeric_space
alnum_s
Allows only alphabetic, numeric and space characters
num
numeric
Allow numbers only
alpha
alphabetic
Allow only alphabetic characters.
alpha_s
alphabetic_space
Allows alphabetic and space characters
email Validates the field to be a proper email address.
(Note, However that the validation can’t check whether the email address exists or not)
lt=???
lessthan=???
Verify the data to be less than the value passed. Valid only for numeric fields.
Example: if the value should be less than 1000 give validation description as “lt=1000″
gt=???
greaterthan=???
Verify the data to be greater than the value passed. Valid only for numeric fields.
Example: if the value should be greater than 10 give validation description as “gt=10″
regexp=??? Match the input with a regular expression.
Example: “regexp=^[A-Za-z]{1,20}$” allow up to 20 alphabetic characters.
dontselect=?? This validation descriptor is valid only for drop down lists. The drop down select list boxes usually will have one item saying ‘Select One’ (and that item will be selected by default). The user should select an option other than this ‘Select One’ item.
If the valueof this default option is ’000′, the validation description should be “dontselect=000″Dropdown box with default selected

Drop down list source

dontselectchk=?? This validation descriptor is only for check boxes. The user should not select the given check box. Provide the value of the check box instead of ??
For example, dontselectchk=on
shouldselchk=?? This validation descriptor is only for check boxes. The user should select the given check box. Provide the value of the check box instead of ??
For example, shouldselchk=on
selone_radio One of the radio buttons should be selected.
Example:

chktestValidator.addValidation("Options","selone");
Compare two input elements
eqelmnt=??? Compare two input elements. For example: password and confirm password. Replace ??? with the name of the other input element.
Example:

frmvalidator.addValidation("confpassword","eqelmnt=password",
 "The confirmed password is not same as password");
neelmnt=??? The value should not be equal to the other input element
Example:

frmvalidator.addValidation("password","neelmnt=username",
"The password should not be same as username");
ltelmnt=??? The input should be less than the other input. Give the name of the other input instead of ???
leelmnt=??? The input should be less than or equal to the other input. Give the name of the other input instead of ???
gtelmnt=??? The input should be greater than the other input. Give the name of the other input instead of ???
geelmnt=??? The input should be greater than or equal to the other input. Give the name of the other input instead of ???

Go to the second part of this post to learn about the advanced features of this validation script.

Java PDF Generation with IText

Posted: January 4, 2012 in Random Posts
Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Multi Site Keyword Extractor Tool
Analyze Keywords

First Method creates ur PDF File and Second Download your file from the relative Path in JSF

public String mypdfGeneratorAmd() {
// fileCreation();
List mylist = this.getListDfAmd();
if (mylist != null) {
Document pdf = new Document();
Date today = new Date();
ServletContext servletContext = null;
// (ServletContext)
// FacesContext.getCurrentInstance().getExternalContext().getContext();
// String logo1 = servletContext.getRealPath(“”) + “/” +
// “WebContent”
// + “/” + “reports” + “/”;

String fileName = “AssistedMaintenanceDocking.pdf”;

File f;
String fileTitle = “AssistedMaintenanceDocking ”
+ (new Date().toString());
servletContext = (ServletContext) FacesContext.getCurrentInstance()
.getExternalContext().getContext();
String logo = servletContext.getRealPath(“”) + “/” + “images” + “/”
+ “user-image.jpg”;

int rowCount = mylist.size();
PdfPTable t = new PdfPTable(5);
Paragraph title1 = new Paragraph();
try {
Image img = Image.getInstance(logo);
String mypdfFile = servletContext.getRealPath(“”) + “/”
+ “reports” + “/” + “DefectAndHistory.pdf”;
f = new File(mypdfFile);
// “/home/shussain/workspace2/DNRMS-PMSA/WebContent/reports/”+
// “AssistedMaintenanceDocking.pdf”);
if (!f.exists()) {
try {
f.createNewFile();
System.out
.println(“New file ‘AssistedMaintenanceDocking.pdf’ has been created to the current directory”);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
System.out
.println(“File ‘AssistedMaintenanceDocking.pdf’ Already in the current directory”);
}
PdfWriter.getInstance(pdf, new FileOutputStream(f));
pdf.addTitle(fileTitle);
pdf.setMargins((float) 1.5, (float) 1.5, 30, 30);
pdf.addAuthor(session.getAttribute(“sessionUserName”)
.toString());
pdf.addCreationDate();
pdf.addCreator(session.getAttribute(“sessionUserName”)
.toString());
pdf.addSubject(“Assisted Maintenance Docking”);
pdf.open();

title1.add(new Paragraph(“Assisted Maintenance Docking” + “\n”
+ (new Date().toString()), FontFactory.getFont(
FontFactory.HELVETICA, 20, Font.BOLD,
new Color(0, 0, 0))));
title1.setAlignment(“CENTER”);
Chapter chapter1 = new Chapter(title1, 1);
chapter1.setNumberDepth(0);

pdf.add(chapter1);
addEmptyLine(title1, 2);
Phrase phraseOfImage = new Phrase();
phraseOfImage.add(new Chunk(img, 18, -18));
pdf.add(phraseOfImage);

pdf.add(Chunk.NEWLINE);
pdf.add(Chunk.NEWLINE);

t.setWidthPercentage(90);
Phrase phrase1 = null;

float[] columnWidths = { 200, 200, 200, 200, 200 };
t.setWidths(columnWidths);

PdfPCell c1 = new PdfPCell(new Phrase(“Ship/Unit”,
FontFactory.getFont(FontFactory.HELVETICA, 12,
Font.BOLD, Color.BLACK)));

c1.setBackgroundColor(Color.gray);
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
t.addCell(c1);

c1 = new PdfPCell(new Phrase(“Last AMD”, FontFactory.getFont(
FontFactory.HELVETICA, 12, Font.BOLD, Color.BLACK)));
c1.setBackgroundColor(Color.gray);
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
t.addCell(c1);

c1 = new PdfPCell(new Phrase(“AMD Plan”, FontFactory.getFont(
FontFactory.HELVETICA, 12, Font.BOLD, Color.BLACK)));
c1.setBackgroundColor(Color.gray);
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
t.addCell(c1);

c1 = new PdfPCell(new Phrase(“Duration”, FontFactory.getFont(
FontFactory.HELVETICA, 12, Font.BOLD, Color.BLACK)));
c1.setBackgroundColor(Color.gray);
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
t.addCell(c1);

c1 = new PdfPCell(new Phrase(“Package”, FontFactory.getFont(
FontFactory.HELVETICA, 12, Font.BOLD, Color.BLACK)));
c1.setBackgroundColor(Color.gray);
c1.setHorizontalAlignment(Element.ALIGN_CENTER);
t.addCell(c1);

t.setHeaderRows(1);

for (int i = 0; i < rowCount; i++) {

dfamd = (DfAmd) mylist.get(i);
t.addCell(dfamd.getDfShipUnits().getShip());

t.addCell(dfamd.getLastAmd());
t.addCell(dfamd.getAmdPlan());
t.addCell(dfamd.getDuration());
t.addCell(dfamd.getPackage_());

}

pdf.add(t);

// section1.add(t);
pdf.setPageSize(PageSize.A4);

pdf.add(pdf.getPageSize());

} catch (DocumentException e) {
System.err.println(e.getMessage());
} catch (IOException ex) {
System.err.println(ex.getMessage());
}
pdf.close();
try {
downloadPDF();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
msging = new FacesMessage(FacesMessage.SEVERITY_WARN, "Error",
"Your Report Is Empty Please Search Some Data");
// msging ="Your Report Is Empty Please Search Some Data";

}
FacesContext.getCurrentInstance().addMessage(null, msging);
return "success";
}

// put new line after specific Element
private static void addEmptyLine(Paragraph paragraph, int number) {
for (int i = 0; i 0) {
output.write(buffer, 0, length);
}

// Finalize task.
output.flush();
} finally {
// Gently close streams.
close(output);
close(input);
}

facesContext.responseComplete();
}

private static void close(Closeable resource) {
if (resource != null) {
try {
resource.close();
} catch (IOException e) {

e.printStackTrace();
}
}
}