{"id":1582,"date":"2012-07-04T16:00:00","date_gmt":"2012-07-04T16:00:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/full-web-application-tomcat-jsf-primefaces-jpa-hibernate-part-3.html"},"modified":"2014-04-29T11:49:09","modified_gmt":"2014-04-29T08:49:09","slug":"full-web-application-tomcat-jsf_4954","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html","title":{"rendered":"Full Web Application Tomcat JSF Primefaces JPA Hibernate &#8211; Part 3"},"content":{"rendered":"<h2>Primefaces AutoComplete, JSF Converter<\/h2>\n<p>This post continues from <a href=\"http:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf.html\">part 1<\/a> and <a href=\"http:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_04.html\">part 2<\/a>.<\/p>\n<p>The JSF has the Converter tool that helps us get some data from the user view and transform into an object loaded from the database or a cache.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n<p>In the \u201ccom.converter\u201d package create the following class:            <\/p>\n<pre class=\"brush:java\">package com.converter;\r\n\r\nimport javax.faces.application.FacesMessage;\r\nimport javax.faces.component.UIComponent;\r\nimport javax.faces.context.FacesContext;\r\nimport javax.faces.convert.*;\r\n\r\nimport com.facade.DogFacade;\r\nimport com.model.Dog;\r\n\r\n@FacesConverter(forClass = com.model.Dog.class)\r\npublic class DogConverter implements Converter {\r\n\r\n @Override\r\n public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {\r\n  DogFacade dogFacade = new DogFacade();\r\n  int dogId;\r\n\r\n  try {\r\n   dogId = Integer.parseInt(arg2);\r\n  } catch (NumberFormatException exception) {\r\n   throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, 'Type the name of a Dog and select it (or use the dropdow)', 'Type the name of a Dog and select it (or use the dropdow)'));\r\n  }\r\n\r\n  return dogFacade.findDog(dogId);\r\n }\r\n\r\n @Override\r\n public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {\r\n\r\n  if (arg2 == null) {\r\n   return '';\r\n  }\r\n  Dog dog = (Dog) arg2;\r\n  return String.valueOf(dog.getId());\r\n }\r\n}<\/pre>\n<p>About the above code:            <\/p>\n<ul>\n<li>In the @Converter annotation there is an attribute named \u201cforClass\u201d. This attribute indicates to the de JSF that all classes of the specified in the \u201cforClass\u201d will invoke the Converter. The DogConverter is annotated with \u201c<em>forClass = com.model.Dog.class<\/em>\u201d, every time the JSF needs a Converter for a Dog class the JSF will invoke the DogConverter. It was not necessary to write any code in the \u201cweb.xml\u201d file.<\/li>\n<\/ul>\n<p>The Converter code is required in the Primefaces AutoComplete. Bellow you see how easy is to use the AutoComplete:            <\/p>\n<p><em>personUpdateDialog.xhtml<\/em><br \/>\n<em><br \/>\n<\/em><\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/2.bp.blogspot.com\/-tHw6e8Rp_Os\/T_MyP2nUtPI\/AAAAAAAAA4I\/GoKeRQZVs5M\/s1600\/03.png\"><img decoding=\"async\" border=\"0\" height=\"23\" src=\"http:\/\/2.bp.blogspot.com\/-tHw6e8Rp_Os\/T_MyP2nUtPI\/AAAAAAAAA4I\/GoKeRQZVs5M\/s320\/03.png\" width=\"320\" \/><\/a><\/div>\n<p><em>PersonMB.java<\/em><\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/2.bp.blogspot.com\/-OZoWm9BzGqc\/T_MybR-SuAI\/AAAAAAAAA4Q\/8vJuCB66sZ4\/s1600\/04.png\"><img decoding=\"async\" border=\"0\" height=\"170\" src=\"http:\/\/2.bp.blogspot.com\/-OZoWm9BzGqc\/T_MybR-SuAI\/AAAAAAAAA4Q\/8vJuCB66sZ4\/s320\/04.png\" width=\"320\" \/><\/a><\/div>\n<p>About the above code:            <\/p>\n<ul>\n<li>The AutoComplete function has several options like minimum query length, delay to start a query, dropdown to display all values and more. It is worth to see all the options: <a href=\"http:\/\/primefaces.org\/showcase\/ui\/autoCompleteBasic.jsf\">http:\/\/primefaces.org\/showcase\/ui\/autoCompleteBasic.jsf<\/a> and <a href=\"http:\/\/primefaces.org\/showcase\/ui\/autocompleteHome.jsf\">http:\/\/primefaces.org\/showcase\/ui\/autocompleteHome.jsf<\/a><\/li>\n<li>The \u201c<em>complete<\/em>\u201d method has a cache of the values found in the database. The method goes to each object of the List&lt;Dog&gt; and keeps the matches.<\/li>\n<li>Notice that the Converter will always be called because the \u201c<em>itemValue=\u201d#{dog}\u201d<\/em>\u201d that you will find in the AutoComplete component.<\/li>\n<\/ul>\n<p>You can see bellow the AutoComplete working:<\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/3.bp.blogspot.com\/-hOrTkWvxpHg\/T_MykUtcb0I\/AAAAAAAAA4Y\/bJHQa3vWao4\/s1600\/04a.png\"><img decoding=\"async\" border=\"0\" height=\"203\" src=\"http:\/\/3.bp.blogspot.com\/-hOrTkWvxpHg\/T_MykUtcb0I\/AAAAAAAAA4Y\/bJHQa3vWao4\/s320\/04a.png\" width=\"320\" \/><\/a><\/div>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/3.bp.blogspot.com\/-IFed14xPPeY\/T_MytD9GMaI\/AAAAAAAAA4g\/btEZKsLjEsA\/s1600\/04b.png\"><img decoding=\"async\" border=\"0\" height=\"133\" src=\"http:\/\/3.bp.blogspot.com\/-IFed14xPPeY\/T_MytD9GMaI\/AAAAAAAAA4g\/btEZKsLjEsA\/s320\/04b.png\" width=\"320\" \/><\/a><\/div>\n<h2>CSS\/javascript\/images with JSF<\/h2>\n<p>Take a look at the pictures bellow, it will display how that the application of this post handles resources:            <\/p>\n<p>\u201c<em>master.xhtml<\/em>\u201d<\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/2.bp.blogspot.com\/-CpEByV4xmq0\/T_MzNlXxe_I\/AAAAAAAAA4o\/ljQUbzD_hVk\/s1600\/05.png\"><img decoding=\"async\" border=\"0\" height=\"26\" src=\"http:\/\/2.bp.blogspot.com\/-CpEByV4xmq0\/T_MzNlXxe_I\/AAAAAAAAA4o\/ljQUbzD_hVk\/s320\/05.png\" width=\"320\" \/><\/a><\/div>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/1.bp.blogspot.com\/-gXYSan9AwVY\/T_MzYZ3y1II\/AAAAAAAAA4w\/Kv3-dwu9Yhk\/s1600\/06.png\"><img decoding=\"async\" border=\"0\" height=\"23\" src=\"http:\/\/1.bp.blogspot.com\/-gXYSan9AwVY\/T_MzYZ3y1II\/AAAAAAAAA4w\/Kv3-dwu9Yhk\/s320\/06.png\" width=\"320\" \/><\/a><\/div>\n<p>\u201cindex.xhtml\u201d<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/4.bp.blogspot.com\/-AB-PpX6nY9Q\/T_MzhdEPLVI\/AAAAAAAAA44\/m4olazn7yAc\/s1600\/07.png\"><img decoding=\"async\" border=\"0\" height=\"19\" src=\"http:\/\/4.bp.blogspot.com\/-AB-PpX6nY9Q\/T_MzhdEPLVI\/AAAAAAAAA44\/m4olazn7yAc\/s320\/07.png\" width=\"320\" \/><\/a><\/div>\n<p>With JSF it is very easy to handle this kind of resources. The developer does not need to use the file relative path anymore. To use your resources like that create your files like bellow:<\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/4.bp.blogspot.com\/-hEqlmPXaH9I\/T_MzpfWxl6I\/AAAAAAAAA5A\/Vpt2P0y3q3A\/s1600\/08.png\"><img decoding=\"async\" border=\"0\" src=\"http:\/\/4.bp.blogspot.com\/-hEqlmPXaH9I\/T_MzpfWxl6I\/AAAAAAAAA5A\/Vpt2P0y3q3A\/s1600\/08.png\" \/><\/a><\/div>\n<p>The JSF will map all resources found in the folder \u201c\/WebContent\/resources\u201d and the developer will be able to use the resources like displayed above.<\/p>\n<h2>\u201cweb.xml\u201d configurations<\/h2>\n<p>In the folder \u201c<em>WebContent\/WEB-INF\/<\/em>\u201d create the files bellow:            <\/p>\n<p>\u201c<em>web.xml<\/em>\u201d            <\/p>\n<pre class=\"brush:xml\">&lt;?xml version='1.0'?&gt;\r\n&lt;web-app version='3.0' xmlns='http:\/\/java.sun.com\/xml\/ns\/javaee'\r\n xmlns:xsi='http:\/\/www.w3.org\/2001\/XMLSchema-instance'\r\n xsi:schemaLocation='http:\/\/java.sun.com\/xml\/ns\/javaee http:\/\/java.sun.com\/xml\/ns\/javaee\/web-app_3_0.xsd'&gt;\r\n &lt;display-name&gt;JSFCrudApp&lt;\/display-name&gt;\r\n &lt;servlet&gt;\r\n  &lt;servlet-name&gt;Faces Servlet&lt;\/servlet-name&gt;\r\n  &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;\/servlet-class&gt;\r\n  &lt;load-on-startup&gt;1&lt;\/load-on-startup&gt;\r\n &lt;\/servlet&gt;\r\n &lt;servlet-mapping&gt;\r\n  &lt;servlet-name&gt;Faces Servlet&lt;\/servlet-name&gt;\r\n  &lt;url-pattern&gt;*.xhtml&lt;\/url-pattern&gt;\r\n &lt;\/servlet-mapping&gt;\r\n &lt;welcome-file-list&gt;\r\n  &lt;welcome-file&gt;\/pages\/protected\/index.xhtml&lt;\/welcome-file&gt;\r\n &lt;\/welcome-file-list&gt;\r\n &lt;context-param&gt;\r\n  &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;\/param-name&gt;\r\n  &lt;param-value&gt;Development&lt;\/param-value&gt;\r\n &lt;\/context-param&gt;\r\n\r\n &lt;filter&gt;\r\n  &lt;filter-name&gt;LoginCheckFilter&lt;\/filter-name&gt;\r\n  &lt;filter-class&gt;com.filter.LoginCheckFilter&lt;\/filter-class&gt;\r\n  &lt;init-param&gt;\r\n   &lt;param-name&gt;loginActionURI&lt;\/param-name&gt;\r\n   &lt;param-value&gt;\/JSFCrudApp\/pages\/public\/login.xhtml&lt;\/param-value&gt;\r\n  &lt;\/init-param&gt;\r\n &lt;\/filter&gt;\r\n &lt;filter-mapping&gt;\r\n  &lt;filter-name&gt;LoginCheckFilter&lt;\/filter-name&gt;\r\n  &lt;url-pattern&gt;\/*&lt;\/url-pattern&gt;\r\n &lt;\/filter-mapping&gt;\r\n\r\n &lt;filter&gt;\r\n  &lt;filter-name&gt;AdminPagesFilter&lt;\/filter-name&gt;\r\n  &lt;filter-class&gt;com.filter.AdminPagesFilter&lt;\/filter-class&gt;\r\n &lt;\/filter&gt;\r\n &lt;filter-mapping&gt;\r\n  &lt;filter-name&gt;AdminPagesFilter&lt;\/filter-name&gt;\r\n  &lt;url-pattern&gt;\/pages\/protected\/admin\/*&lt;\/url-pattern&gt;\r\n &lt;\/filter-mapping&gt;\r\n\r\n &lt;filter&gt;\r\n  &lt;filter-name&gt;DefaultUserPagesFilter&lt;\/filter-name&gt;\r\n  &lt;filter-class&gt;com.filter.DefaultUserPagesFilter&lt;\/filter-class&gt;\r\n &lt;\/filter&gt;\r\n &lt;filter-mapping&gt;\r\n  &lt;filter-name&gt;DefaultUserPagesFilter&lt;\/filter-name&gt;\r\n  &lt;url-pattern&gt;\/pages\/protected\/defaultUser\/*&lt;\/url-pattern&gt;\r\n &lt;\/filter-mapping&gt; \r\n&lt;\/web-app&gt;<\/pre>\n<p>\u201c<em>faces-config.xml<\/em>\u201d            <\/p>\n<pre class=\"brush:java\">&lt;?xml version='1.0' encoding='UTF-8'?&gt;\r\n\r\n&lt;faces-config xmlns='http:\/\/java.sun.com\/xml\/ns\/javaee'\r\n xmlns:xsi='http:\/\/www.w3.org\/2001\/XMLSchema-instance'\r\n xsi:schemaLocation='http:\/\/java.sun.com\/xml\/ns\/javaee http:\/\/java.sun.com\/xml\/ns\/javaee\/web-facesconfig_2_0.xsd'\r\n version='2.0'&gt;\r\n &lt;application&gt;\r\n  &lt;resource-bundle&gt;\r\n   &lt;base-name&gt;messages&lt;\/base-name&gt;\r\n   &lt;var&gt;bundle&lt;\/var&gt;\r\n  &lt;\/resource-bundle&gt;\r\n  &lt;message-bundle&gt;messages&lt;\/message-bundle&gt;\r\n &lt;\/application&gt;\r\n&lt;\/faces-config&gt;<\/pre>\n<p>About the above code:            <\/p>\n<ul>\n<li>All security filters you will find mapped in the web.xml file. You could also use the @Filter annotations that would work the same.<\/li>\n<li>The property \u201c<em>javax.faces.PROJECT_STAGE<\/em>\u201d has the value DEVELOPMENT. One of the advantages of this configurations is that the JSF will append a \u201ch:message\u201d if none is found in the screen. If some exception happens and there is no component to display it the JSF will append a h:message component in the page.<\/li>\n<li>Inside the \u201cfaces-config\u201d exist a tag named \u201cmessage-bundle\u201d. This tag allows the developer to override the JSF default messages, the value of this tag will point to a file with the default JSF messages key. In the \u201cmessage.properties\u201d file (page 08) has the key \u201c<em>javax.faces.component.UIInput.REQUIRED<\/em>\u201d, any value you write in this key will affect all the \u201crequired field\u201d messages displayed in the application.<\/li>\n<\/ul>\n<h2>Increasing the security of your application<\/h2>\n<h3>Do not concatenate the queries<\/h3>\n<p>Do not use the usual <em>\u201cwhere id =\u201d + id<\/em> sql code. This kind of code allows the \u201c<em>SQL Injection<\/em>\u201d hacker attack. A developer that works with ORM is also vulnerable to this kind of attack but with different name: \u201cHQL Injection\u201d. The best way of doing a query you may find in the Person and User class:<\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/2.bp.blogspot.com\/-E2Hu5yem5l0\/T_M0hEzFEAI\/AAAAAAAAA5I\/L3wJ1B66KsQ\/s1600\/09.png\"><img decoding=\"async\" border=\"0\" height=\"10\" src=\"http:\/\/2.bp.blogspot.com\/-E2Hu5yem5l0\/T_M0hEzFEAI\/AAAAAAAAA5I\/L3wJ1B66KsQ\/s320\/09.png\" width=\"320\" \/><\/a><\/div>\n<p>It does not matter if you use JPA or not, never concatenate your query with strings.            <\/p>\n<p>The developer must be aware that \u201c<em>SQL Injection may happen in any query of your application<\/em>\u201d, and not only in the login query. If a user has a valid login to your application, this user is able to do \u201c<em>SQL Injection<\/em>\u201d in all your queries.            <\/p>\n<h3>AutoComplete Off<\/h3>\n<p>In the page \u201c<em>login.xhtml<\/em>\u201d there is the following code:            <\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/2.bp.blogspot.com\/-i1at1Vh-OZI\/T_M01Vy9moI\/AAAAAAAAA5Q\/aaOR8w3TQFY\/s1600\/10.png\"><img decoding=\"async\" border=\"0\" height=\"21\" src=\"http:\/\/2.bp.blogspot.com\/-i1at1Vh-OZI\/T_M01Vy9moI\/AAAAAAAAA5Q\/aaOR8w3TQFY\/s320\/10.png\" width=\"320\" \/><\/a><\/div>\n<p>The tag \u201cautocomplete\u201d off tells to the browser that this field should not be saved. The great browsers (Firefox, Chrome, IE) respect this tag and it helps to protect your application.            <\/p>\n<p>If you allow the browser to keep the password the browser must keep this password stored somewhere. If a hacker finds out where this key is stored he may try to crack it.            <\/p>\n<h3>Validate all incoming requests<\/h3>\n<p>If the application was required just to validate if the user is or is not logged the user class would not need the role Enum.            <\/p>\n<p>If there was no role validation a regular user could access any area of the system, like the admin pages. Notice that this application has filters that always validate the user role for all requests. \u201c<em>Hiding a link is not a protection measure. The developer should always validate all incoming requests<\/em>\u201d. A developer may hide a URL or a button, but a user could access any screen of your application if he types the URL in the browser or simulating get\/post calls.            <\/p>\n<h3>Always use the h:outputText component<\/h3>\n<p>An easy way to avoid the Cross-Site Scripting is using the h:outputText component to display data from the database. Notice that in this post that all the values displayed to de user that comes from the database are using the h:outputText component. A situation that the h:outputText component can be avoided is when the application will display system messages from a file like \u201cmessage.properties\u201d.<\/p>\n<h2>Running the application<\/h2>\n<p>Start the Tomcat and check the database; notice that there is no table inside the database yet.            <\/p>\n<p>Type the following URL in the browser: <a href=\"http:\/\/localhost\/JSFCrudApp\/\">http:\/\/localhost\/JSFCrudApp\/<\/a> .            <\/p>\n<p>The following screen will be displayed:            <\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/1.bp.blogspot.com\/-Pi6jlJIgX10\/T_M1Xp44hhI\/AAAAAAAAA5Y\/7Ei-7UDyTpI\/s1600\/11.png\"><img decoding=\"async\" border=\"0\" height=\"216\" src=\"http:\/\/1.bp.blogspot.com\/-Pi6jlJIgX10\/T_M1Xp44hhI\/AAAAAAAAA5Y\/7Ei-7UDyTpI\/s320\/11.png\" width=\"320\" \/><\/a><\/div>\n<p>Type any value that you want and press the login button, do not bother if there is no user or tables. Just click on it. You will see an error message like this:            <\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/4.bp.blogspot.com\/-YkXi0536g8w\/T_M1fzry5GI\/AAAAAAAAA5g\/Ws9Ck_Dv5mk\/s1600\/12.png\"><img decoding=\"async\" border=\"0\" height=\"216\" src=\"http:\/\/4.bp.blogspot.com\/-YkXi0536g8w\/T_M1fzry5GI\/AAAAAAAAA5g\/Ws9Ck_Dv5mk\/s320\/12.png\" width=\"320\" \/><\/a><\/div>\n<p>Check your database again and you will see that all tables were created. The applications is controlling all transaction manually that is the reason for the JPA\/Hibernate just create the table when is first invoked.            <\/p>\n<p>You need to create a user with the role ADMIN (I named this user Real Madrid) and another user with the USER role (I named it Barcelona). The ADMIN user will have access to all system under all folders but the user with the USER role will have access to the pages under the folder defaultUser.            <\/p>\n<p>If you log in with the ADMIN user you will see:            <\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/1.bp.blogspot.com\/-ziucSIl4kec\/T_M1pQozn4I\/AAAAAAAAA5o\/ua2veKTaXTs\/s1600\/13.png\"><img decoding=\"async\" border=\"0\" height=\"265\" src=\"http:\/\/1.bp.blogspot.com\/-ziucSIl4kec\/T_M1pQozn4I\/AAAAAAAAA5o\/ua2veKTaXTs\/s320\/13.png\" width=\"320\" \/><\/a><\/div>\n<p>Log in now with the user that has the USER role:            <\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/4.bp.blogspot.com\/-UBKW4d6fFMI\/T_M1x1kGdSI\/AAAAAAAAA5w\/N6xb4xfnOHI\/s1600\/14.png\"><img decoding=\"async\" border=\"0\" height=\"265\" src=\"http:\/\/4.bp.blogspot.com\/-UBKW4d6fFMI\/T_M1x1kGdSI\/AAAAAAAAA5w\/N6xb4xfnOHI\/s320\/14.png\" width=\"320\" \/><\/a><\/div>\n<p>The Dogs button were hidden. Even without the button a user could access the URL of the Dogs and the Dogs screen should be allowed only to ADMIN roles.            <\/p>\n<p>To see how the application would behave with and illegal access, keep logged in with the USER role and try to access the following link: <a href=\"http:\/\/localhost\/JSFCrudApp\/pages\/protected\/admin\/adminIndex.xhtml\">http:\/\/localhost\/JSFCrudApp\/pages\/protected\/admin\/adminIndex.xhtml<\/a>           <\/p>\n<p>The next screen will be displayed:            <\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/4.bp.blogspot.com\/-a0fFRueeWIg\/T_M2Dp_pRCI\/AAAAAAAAA54\/Lupd0LX0Vsw\/s1600\/15.png\"><img decoding=\"async\" border=\"0\" height=\"265\" src=\"http:\/\/4.bp.blogspot.com\/-a0fFRueeWIg\/T_M2Dp_pRCI\/AAAAAAAAA54\/Lupd0LX0Vsw\/s320\/15.png\" width=\"320\" \/><\/a><\/div>\n<p>This screen will be displayed because the AdminPagesFilter check if the request comes from a ADMIN user. I the user is not in the ADMIN role our Ninja Cat will get it! [=                                          <\/p>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/uaihebert.com\/?p=1440&amp;page=10\">Full Web Application with Tomcat JSF Primefaces JPA Hibernate<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Hebert Coelho at the <a href=\"http:\/\/uaihebert.com\/\">uaiHebert<\/a> blog.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Primefaces AutoComplete, JSF Converter This post continues from part 1 and part 2. The JSF has the Converter tool that helps us get some data from the user view and transform into an object loaded from the database or a cache. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; In the \u201ccom.converter\u201d package create the following class: package &hellip;<\/p>\n","protected":false},"author":154,"featured_media":217,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[32,31,33,293,453],"class_list":["post-1582","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-apache-tomcat","tag-jboss-hibernate","tag-jpa","tag-jsf","tag-primefaces"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Full Web Application Tomcat JSF Primefaces JPA Hibernate - Part 3 - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Primefaces AutoComplete, JSF Converter This post continues from part 1 and part 2. The JSF has the Converter tool that helps us get some data from the\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Full Web Application Tomcat JSF Primefaces JPA Hibernate - Part 3 - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Primefaces AutoComplete, JSF Converter This post continues from part 1 and part 2. The JSF has the Converter tool that helps us get some data from the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2012-07-04T16:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-04-29T08:49:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/primefaces-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Hebert Coelho\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/uaiHebert\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Hebert Coelho\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/full-web-application-tomcat-jsf_4954.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/full-web-application-tomcat-jsf_4954.html\"},\"author\":{\"name\":\"Hebert Coelho\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/997b72fad4d637a8d56a44ea7938ddf5\"},\"headline\":\"Full Web Application Tomcat JSF Primefaces JPA Hibernate &#8211; Part 3\",\"datePublished\":\"2012-07-04T16:00:00+00:00\",\"dateModified\":\"2014-04-29T08:49:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/full-web-application-tomcat-jsf_4954.html\"},\"wordCount\":1213,\"commentCount\":9,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/full-web-application-tomcat-jsf_4954.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/primefaces-logo.jpg\",\"keywords\":[\"Apache Tomcat\",\"JBoss Hibernate\",\"JPA\",\"JSF\",\"PrimeFaces\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/full-web-application-tomcat-jsf_4954.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/full-web-application-tomcat-jsf_4954.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/full-web-application-tomcat-jsf_4954.html\",\"name\":\"Full Web Application Tomcat JSF Primefaces JPA Hibernate - Part 3 - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/full-web-application-tomcat-jsf_4954.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/full-web-application-tomcat-jsf_4954.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/primefaces-logo.jpg\",\"datePublished\":\"2012-07-04T16:00:00+00:00\",\"dateModified\":\"2014-04-29T08:49:09+00:00\",\"description\":\"Primefaces AutoComplete, JSF Converter This post continues from part 1 and part 2. The JSF has the Converter tool that helps us get some data from the\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/full-web-application-tomcat-jsf_4954.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/full-web-application-tomcat-jsf_4954.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/full-web-application-tomcat-jsf_4954.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/primefaces-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/primefaces-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/07\\\/full-web-application-tomcat-jsf_4954.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Full Web Application Tomcat JSF Primefaces JPA Hibernate &#8211; Part 3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/997b72fad4d637a8d56a44ea7938ddf5\",\"name\":\"Hebert Coelho\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/afcc9fe43ded824615eb04ed102590ff0c8601a47624b2a681103f05da1bddfb?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/afcc9fe43ded824615eb04ed102590ff0c8601a47624b2a681103f05da1bddfb?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/afcc9fe43ded824615eb04ed102590ff0c8601a47624b2a681103f05da1bddfb?s=96&d=mm&r=g\",\"caption\":\"Hebert Coelho\"},\"description\":\"Senior Java Development, with 4 certifications and a published book about JSF (portuguese only). Founder of the blog uaiHebert.com visited from more than 170 different countries.\",\"sameAs\":[\"http:\\\/\\\/uaihebert.com\\\/\",\"http:\\\/\\\/www.linkedin.com\\\/pub\\\/h%C3%A9bert-coelho-de-oliveira\\\/46\\\/ba8\\\/5bb\",\"https:\\\/\\\/x.com\\\/http:\\\/\\\/twitter.com\\\/uaiHebert\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Hebert-Coelho\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Full Web Application Tomcat JSF Primefaces JPA Hibernate - Part 3 - Java Code Geeks","description":"Primefaces AutoComplete, JSF Converter This post continues from part 1 and part 2. The JSF has the Converter tool that helps us get some data from the","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html","og_locale":"en_US","og_type":"article","og_title":"Full Web Application Tomcat JSF Primefaces JPA Hibernate - Part 3 - Java Code Geeks","og_description":"Primefaces AutoComplete, JSF Converter This post continues from part 1 and part 2. The JSF has the Converter tool that helps us get some data from the","og_url":"https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-07-04T16:00:00+00:00","article_modified_time":"2014-04-29T08:49:09+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/primefaces-logo.jpg","type":"image\/jpeg"}],"author":"Hebert Coelho","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/uaiHebert","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Hebert Coelho","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html"},"author":{"name":"Hebert Coelho","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/997b72fad4d637a8d56a44ea7938ddf5"},"headline":"Full Web Application Tomcat JSF Primefaces JPA Hibernate &#8211; Part 3","datePublished":"2012-07-04T16:00:00+00:00","dateModified":"2014-04-29T08:49:09+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html"},"wordCount":1213,"commentCount":9,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/primefaces-logo.jpg","keywords":["Apache Tomcat","JBoss Hibernate","JPA","JSF","PrimeFaces"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html","url":"https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html","name":"Full Web Application Tomcat JSF Primefaces JPA Hibernate - Part 3 - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/primefaces-logo.jpg","datePublished":"2012-07-04T16:00:00+00:00","dateModified":"2014-04-29T08:49:09+00:00","description":"Primefaces AutoComplete, JSF Converter This post continues from part 1 and part 2. The JSF has the Converter tool that helps us get some data from the","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/primefaces-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/primefaces-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2012\/07\/full-web-application-tomcat-jsf_4954.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Full Web Application Tomcat JSF Primefaces JPA Hibernate &#8211; Part 3"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/997b72fad4d637a8d56a44ea7938ddf5","name":"Hebert Coelho","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/afcc9fe43ded824615eb04ed102590ff0c8601a47624b2a681103f05da1bddfb?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/afcc9fe43ded824615eb04ed102590ff0c8601a47624b2a681103f05da1bddfb?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/afcc9fe43ded824615eb04ed102590ff0c8601a47624b2a681103f05da1bddfb?s=96&d=mm&r=g","caption":"Hebert Coelho"},"description":"Senior Java Development, with 4 certifications and a published book about JSF (portuguese only). Founder of the blog uaiHebert.com visited from more than 170 different countries.","sameAs":["http:\/\/uaihebert.com\/","http:\/\/www.linkedin.com\/pub\/h%C3%A9bert-coelho-de-oliveira\/46\/ba8\/5bb","https:\/\/x.com\/http:\/\/twitter.com\/uaiHebert"],"url":"https:\/\/www.javacodegeeks.com\/author\/Hebert-Coelho"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1582","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/154"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=1582"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1582\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/217"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=1582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=1582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=1582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}