{"id":66431,"date":"2021-07-19T04:10:05","date_gmt":"2021-07-19T08:10:05","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/jsf-lesson-5-converting-data-java-short-notes\/"},"modified":"2021-07-19T04:10:05","modified_gmt":"2021-07-19T08:10:05","slug":"jsf-lesson-5-converting-data-java-short-notes","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=66431","title":{"rendered":"JSF: Lesson &#8211; 5: Converting Data #Java Short Notes"},"content":{"rendered":"<ul>\n<li> <a href='codes\/jsf\/converter.rar'>Sample application for JSF Data Type Converter<\/a>           <\/li>\n<li> <a href='http:\/\/www.justetc.net\/knowledge\/multimedia_training\/displayArticle.php?table=TrainingVideos&amp;articleID=10'>Video Tutorial for JSF Data Type Converter<\/a>      <\/li>\n<li> Pre-requisite:  JSF Lesson 1, 2, 3, 4     <\/li>\n<li> JSF provides two different types of built-in data type converters such as: String and Date Conversion, Number and String Conversion.     <\/li>\n<li> Related tags: f:convertDateTime, f:convertNumber, f:converter      <\/li>\n<li> In our previous examples, we could accept departing and returning dates to be date\/time types rather than string types [as expected]    <\/li>\n<li> How to achieve: \n<pre>  <\/pre>\n<\/li>\n<li> For other types of conversions, you have to use custom converters. <\/li>\n<li> To make use of the strategy, you have to write a class that will do the conversion work.<\/li>\n<li> Your class should implement: javax.faces.convert.Converter interface that has two methods that you must implement. One method takes input as String and returns an Object. Another method, takes an Object as the input and returns String.<\/li>\n<li> Methods \n<pre>Object getAsObject(javax.faces.context.FacesContext context,   javax.faces.component.UIComponent component, java.lang.String value)String getAsString(javax.faces.context.FacesContext context,   javax.faces.component.UIComponent component, java.lang.Object value)<\/pre>\n<\/li>\n<li> getAsObject: Returns an object<\/li>\n<li> getAsString: Returns String<\/li>\n<li> As you have access to the JSF context, and the corresponding user interface component in these methods- you will be able to greatly customize your converter<\/li>\n<li> How to use the custome converter:\n<ul>\n<li> Define a converter in the configuration file (faces-config.xml) as follows where TerminalConverter is your custom converter class:\n<pre>terminal.converter  net.justetc.jsf.TerminalConverter<\/pre>\n<\/li>\n<li> From JSPs refer to a converter-id as defined in the configuration file. See example below:<\/li>\n<li>\n<pre>\t\t  \tor\t<\/pre>\n<\/li>\n<li> You can also, define\/use the converter for all properties of a class such as Terminal as follows:\n<pre>  net.justetc.jsf.Terminal  net.justetc.jsf.TerminalConverter<\/pre>\n<\/li>\n<li> In this last scenario, whenever JSF identifies a Terminal type data it converts the data using the TerminalConverter class.\n<pre>   <\/pre>\n<p>In this example, as it encounters bus.origin to be of Terminal type, it will convert the origin to be a Terminal object though the user will just enter a String.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p> From: http:\/\/sitestree.com\/?p=4996<br \/> Categories:Java Short Notes<br \/>Tags:<br \/> Post Data:2011-05-14 09:49:51<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sample application for JSF Data Type Converter Video Tutorial for JSF Data Type Converter Pre-requisite: JSF Lesson 1, 2, 3, 4 JSF provides two different types of built-in data type converters such as: String and Date Conversion, Number and String Conversion. Related tags: f:convertDateTime, f:convertNumber, f:converter In our previous examples, we could accept departing and &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=66431\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-66431","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":74778,"url":"http:\/\/bangla.sitestree.com\/?p=74778","url_meta":{"origin":66431,"position":0},"title":"JSF: Java Server Faces Short Notes from the past","author":"Sayed","date":"May 31, 2022","format":false,"excerpt":"JSF: Java Server Faces Short Notes from the past http:\/\/bangla.salearningschool.com\/recent-posts?s=jsf Data conversion in jsf applications 2022\/04\/15 at 10:01 am 0 views Select internationalization in jsf #AngularJS #By Sayed Ahmed internationalization in jsf #AngularJS #By Sayed Ahmed 2021\/08\/02 at 4:10 am 0 views Select data conversion in jsf applications #AngularJS #By\u2026","rel":"","context":"In &quot;\u09ac\u09cd\u09b2\u0997 \u0964 Blog&quot;","block_context":{"text":"\u09ac\u09cd\u09b2\u0997 \u0964 Blog","link":"http:\/\/bangla.sitestree.com\/?cat=182"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":66433,"url":"http:\/\/bangla.sitestree.com\/?p=66433","url_meta":{"origin":66431,"position":1},"title":"JSF: Lesson &#8211; 6: Validating User Input in JSF #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 19, 2021","format":false,"excerpt":"Target: Intermediate level web-developers. Sample application for this article Video Tutorial for this article In web-application development, validating user inputs takes much efforts. JSF has made validations much easier than usual JSF Built-in Validators: validateDoubleRange: Checks that the value provided is a double value. You can also set a minimum\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":74158,"url":"http:\/\/bangla.sitestree.com\/?p=74158","url_meta":{"origin":66431,"position":2},"title":"data conversion in jsf applications","author":"Sayed","date":"April 15, 2022","format":false,"excerpt":"https:\/\/youtu.be\/xz6a_bamTMs","rel":"","context":"In &quot;From Youtube Channel&quot;","block_context":{"text":"From Youtube Channel","link":"http:\/\/bangla.sitestree.com\/?cat=1952"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/img.youtube.com\/vi\/xz6a_bamTMs\/0.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":66425,"url":"http:\/\/bangla.sitestree.com\/?p=66425","url_meta":{"origin":66431,"position":3},"title":"JSF: Lesson &#8211; 2: JSF Managed Beans #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 19, 2021","format":false,"excerpt":"Codes for this article Video Demonstration for this article Target: Intermediate level programmers and web-developers. Any programmer\/web-developer can take a look. Pre-requisite: HTML, JSP, Servlet, Tomcat, J2EE, MVC, and JSF Introduction. Check the corresponding sections of this web-site, to have an idea on the required technology knowledge Pre-requisite: Download this\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":66423,"url":"http:\/\/bangla.sitestree.com\/?p=66423","url_meta":{"origin":66431,"position":4},"title":"JSF: Lesson &#8211; 1: JSF Specifications #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 19, 2021","format":false,"excerpt":"Video Demonstration of a sample JSF application create: Read the article first JSF Specifications JSF is not standalone technology, you have to use it in conjunction with JSPs, Servlets, EJBs How to use JSF with Servlets and EJBs: In Servlet or EJB, explicitly create instances of UI components and use\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":66429,"url":"http:\/\/bangla.sitestree.com\/?p=66429","url_meta":{"origin":66431,"position":5},"title":"JSF: Lesson &#8211; 4: Accessing Context Data from Beans #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 19, 2021","format":false,"excerpt":"In some cases, from the beans used in JSF applications, you will need to access the request parameters. For example, in the BusSearch.java, we accessed, the request parameters [Please check the previous JSF lesson]. How to access: FacesContext context = FacesContext.getCurrentInstance(); Some methods of FacesContext: Map getApplicationMap() String getInitParameter(java.lang.String name)\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/66431","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=66431"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/66431\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=66431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=66431"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=66431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}