Introduction
Strictly speaking, one would render a JSF View as PDF using an alternative renderer instead of the default HTML renderer. However, it's more likely that like most people you don't really want to 'export the JSF page to PDF', you want to generate a downloadable document in PDF form for viewing, printing and/or saving on the client's machine. Which is entirely different. Search for jsf to pdf converter or software able to handle these file types. Possible software with support for converting of jsf files to pdf file format. This conversion or rather export seems to be more of a work for a programmer than a conversion utility, something like Java API for generating PDF documents.
In JSF user input is normally of String type which will be submitted to the server for further processing.However when request parameters are mapped to different backing bean properties internally, the String values need to be converted to different data types, such as Integer,boolean,Short and Double.At the same time when the response is created for the user these java data types again need to be changed to String.
To deal with this scenario JSF Converters are used.JSF Converters will take care of converting the user input. JSF has bunch of Standard Converters for most of the conversion process. If you couldn't find a suitable converter specific to your requirement , then you can easily create a Custom Converter specific to your requirement.
Choose target format. You can convert all kinds of documents and images to PDF file or convert PDF file to DOC, DOCX, XLS, XLSX, PPT, PPTX, XML, CSV, ODT, ODS, ODP, HTML, TXT, RTF, SWF, PNG, JPG, TIFF, BMP, PCX, PNM and PSD. Click 'Convert Now!' Button to start batch conversion. The output files will be listed in the 'Conversion Results. The PDF online converter can convert from Microsoft Word to PDF as well as a lot of other formats. If the PDF contains only scans from text pages, you can convert it to a searchable PDF file using the OCR functionality. If you want more advanced features like rotate, merge or sort PDF pages, you can use this free PDF editor.
- JSF Basics
- JSF Managed Bean
- JSF Navigation
- Converters & Validation
Introduction
In JSF user input is normally of String type which will be submitted to the server for further processing.However when request parameters are mapped to different backing bean properties internally, the String values need to be converted to different data types, such as Integer,boolean,Short and Double.At the same time when the response is created for the user these java data types again need to be changed to String.
To deal with this scenario JSF Converters are used.JSF Converters will take care of converting the user input. JSF has bunch of Standard Converters for most of the conversion process. If you couldn't find a suitable converter specific to your requirement , then you can easily create a Custom Converter specific to your requirement.
- JSF Basics
- JSF Managed Bean
- JSF Navigation
- Converters & Validation
Why Converters are important ?
Suppose in a Web Application user asked to provide some data. The values entered by the user is in string format. Even, numerical values like age, salary, phone no etc is also in String format. In this case when form will be submitted the values passed to Server will be in String format. So, there must be some mechanism which will convert the string values into the appropriate type as field value.
In the JSF life cycle, conversion occurs in the apply request values phase.If the conversion process succeeds, then the submitted values are validated against the Validators defined. If either Conversion or the Validation fails, then the form is re-displayed and the model values that are associated for each UI Component would not be updated. If user enters correct data, and Conversion and validation succeeds, then the Model values will be updated.
JSF Supplied Standard Converters
Let us discuss some standard Converters that comes bundled with JSF Implementation.JSF provides standard converters for all basic types like: Byte, Short, Integer,Long, Float, Double, Boolean, Character etc.
Note:-If you don't specify the converter for the component then JSF will apply the appropriate converter for the component. For example, if the component is associated with a property of type double, JSF will choose the Double converter.
Following are the standard Converters available in JSF.
- DoubleConverter:– Used to convert the user input string values into values of type java.lang.Double
- FloatConverter:– Used to convert the user input string values into values of type java.lang.Float
- LongConverter:– Used to convert the user input string values into values of type java.lang.Long
- IntegerConverter:– Used to convert the user input string values into values of type java.lang.Integer
- NumberConverter:– Used to convert the user input string values into values of type java.lang.Number
- ShortConverter:– Used to convert the user input string values into values of type java.lang.Short
- DateTimeConverter:– Used to convert the user input string values into values of type java.lang.Date
- BooleanConverter:– Used to convert the user input string values into values of type java.lang.Boolean
How to use standard converters
DateTime converter :
For all basic Java types JSF will automatically use converters. But if you want to format a Date object JSF provides a converter tag <f:convertDateTime>.This tag must be nested inside a component tag that supports converters.
For formatting date and time, we have to set the type as date. Whether the style of the date to displayed (short, medium, long) is specified in the dateStyle attribute.
The converter DateTime supports attributes dateStyle, to configure the converter. The listing below shows the attributes you can use with the DateTime converter.
Jsf To Pdf Converter Docx
Attribute name | Description |
---|---|
dateStyle | Specifies the formatting style for the date |
timeStyle | Specifies the formatting style for the time |
timeZone | Specifed the time zone for the date. If not |
locale | The specifed local to use for displaying this |
pattern | The date format pattern used to convert this |
type | Specifies whether to display the date, time or |
Jsf To Pdf Converter Dwg
Number converter
If you want to convert a component value to a Number type then <f:convertnumber/> tag can be used inside the component tag.It has many attribute like integerOnly, maxIntegerDigits, currencyCode,currencySymbol, pattern etc.
The following code defines a Number Converter which formats and displays the number in currency format. Depending on the locale set for this Application, it displays the currency symbol along with value. For example, it will display $1999, if the locale is pointing to US.
By specifying the type as 'percentage', the display value will have a '%' symbol followed by the original value.
We will discuss complete example for standard converter in separate article.
Custom Converter
In most of the scenario, JSF provided converters are sufficient. However, for application specific purposes, there may be a need to customize and convert the user entered string into some other data-type like phone no format. This can be done by using JSF Custom Converter.
Following steps are required to create Custom Converters in JSF.
Steps
- Create a converter class by implementing javax.faces.convert.Converter interface.
- Override both getAsObject() and getAsString() methods.
- Map the converter in faces-config.xml file
- Link your custom converter class to JSF component via f:converter tag.
We will discuss more about Custom converters with eclipse project in separate article.