{"id":67,"date":"2005-01-21T15:47:03","date_gmt":"2005-01-21T15:47:03","guid":{"rendered":"http:\/\/coding.mu\/index.php\/archives\/2005\/01\/21\/how-to-set-up-netbeans-40-for-java-server-faces-development\/"},"modified":"2025-10-17T23:28:22","modified_gmt":"2025-10-17T22:28:22","slug":"how-to-set-up-netbeans-40-for-java-server-faces-development","status":"publish","type":"post","link":"https:\/\/priscimon.net\/coding\/2005\/01\/21\/how-to-set-up-netbeans-40-for-java-server-faces-development\/","title":{"rendered":"How to Develop JSF Applications in NetBeans"},"content":{"rendered":"\n<p>This post is a step-by-step guide to setting up NetBeans for JSF (Java Server Faces) web development. It shows how to configure NetBeans for auto-completion of JSF tags and the meta-data in <em>faces-config.xml<\/em>.<\/p>\n\n\n\n<p>The following will be required.<\/p>\n\n\n\n<p>A DTD for <em>faces-config.xml<\/em><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A JSF implementation<\/li>\n\n\n\n<li>NetBeans 4.0<\/li>\n<\/ul>\n\n\n\n<p><strong>Setting Up the Project<\/strong><br \/> Create a new web project by selecting <em>File<\/em> > <em>New Project<\/em> > <em>Web<\/em> > <em>Web Application<\/em>.<br \/> <img decoding=\"async\" src=\"http:\/\/coding.moris.org\/wp-content\/newproject.png\" alt=\"New project\"\/><br \/> <strong>Creating a JSF Library<\/strong><br \/> Create a library to contain JSF classes, tag libraries, etc. by selecting <em>Tools<\/em> > <em>Library Manager<\/em>\u00e2\u20ac\u00a6 In the Library Manager, click on <em>New Library<\/em>, specify a name, and select <em>Class Libraries<\/em> as the type.<br \/> <img decoding=\"async\" src=\"http:\/\/coding.moris.org\/wp-content\/newlibrary.png\" alt=\"New library\"\/><br \/> Select the library that you just created from the list and click on <em>Add Jar\/Folder<\/em>; add the JAR files for the JSF implementation and required tag libraries.<br \/> <img decoding=\"async\" src=\"http:\/\/coding.moris.org\/wp-content\/addingjarfiles.png\" alt=\"Adding JAR files to a library\"\/><br \/> <strong>Registering the Library in the Project<\/strong><br \/> Right-click on the project and select <em>Properties<\/em>; select <em>Compiling Sources<\/em>; click on <em>Add Library<\/em>; and select the library that has just been created.<br \/> <img decoding=\"async\" src=\"http:\/\/coding.moris.org\/wp-content\/registeringlibrary.png\" alt=\"Registering a library\"\/><br \/> You also need to register JSTL in the project.<br \/> In order to include the files required for JSF in the final package, click on <em>Packaging Project<\/em> and add the libraries as in the previous step.<br \/> <img decoding=\"async\" src=\"http:\/\/coding.moris.org\/wp-content\/packaginglibraries.png\" alt=\"Packaging libraries\"\/><br \/> The JAR and other required files are now registered on the classpath for this project.<br \/> <strong>Creating <em>faces-config.xml<\/em><\/strong><br \/> Create a new folder <em>dtds<\/em> under <em>WEB-INF<\/em> by right-clicking on it, selecting <em>New<\/em> > <em>Folder<\/em>, and typing \u00e2\u20ac\u0153dtds\u00e2\u20ac\u009d.<br \/> <img decoding=\"async\" src=\"http:\/\/coding.moris.org\/wp-content\/createdtds.png\" alt=\"Creating the dtds folder\"\/><br \/> Download the DTD file for Sun\u00e2\u20ac\u2122s reference implementation of JSF and extract it in the <em>dtds<\/em> folder.<br \/> <img decoding=\"async\" src=\"http:\/\/coding.moris.org\/wp-content\/copydtds.png\" alt=\"Copying the DTD into the dtds folder\"\/><br \/> <em>Tip: Use a file manager to do this. Files cannot be pasted directly into NetBeans.<\/em><br \/> Once this is done, create <em>faces-config.xml<\/em> by right-clicking on <em>WEB-INF<\/em> and selecing <em>New <\/em> > <em>XML document<\/em>, and typing \u00e2\u20ac\u0153faces-config\u00e2\u20ac\u009d.<br \/> Replace the content of <em>faces-config.xml<\/em> with the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;!DOCTYPE faces-config PUBLIC\n     \"-\/\/Sun Microsystems, Inc.\/\/DTD JavaServer Faces Config 1.0\/\/EN\"\n     \"dtds\/web-facesconfig_1_1.dtd\"&gt;<\/code><\/pre>\n\n\n\n<p>Because we have copied the DTD for this XML file in the <em>dtds <\/em>folder, we specify this, as shown in the code extract.<br \/> The content can now be added, using the auto-completion if required.<br \/> <img decoding=\"async\" src=\"http:\/\/coding.moris.org\/wp-content\/autocompletion.png\" alt=\"Editing faces-config.xml with auto-completion\"\/><br \/> <strong>Writing JSP Files<\/strong><br \/> Right-click on <em>WEB-INF<\/em> and create a JSP file. Add the <strong>taglib <\/strong>directives at the beginning of the file. This will allow the editor to use auto-completion for JSF tags.<br \/> <img decoding=\"async\" src=\"http:\/\/coding.moris.org\/wp-content\/taglibautocompletion.png\" alt=\"Taglib auto-completion\"\/><br \/> <img decoding=\"async\" src=\"http:\/\/coding.moris.org\/wp-content\/jsfautocompletion.png\" alt=\"JSF auto-completion\"\/><br \/> <em>Note: The JSP editor says JSP completion instead of JSF completion.<\/em><br \/> <strong>Conclusion<\/strong><br \/> This tutorial shows how to work around the lack of native support for JSF in NetBeans.<br \/> Acknowledgements: <a href=\"http:\/\/www.netbeans.org\/community\/index.html\">NetBeans Community<\/a> for a great IDE. <a href=\"http:\/\/home.columbus.rr.com\/mcornell\">Mike Cornell<\/a> for that last yard.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post is a step-by-step guide to setting up NetBeans for JSF (Java Server Faces) web development. It shows how to configure NetBeans for auto-completion of JSF tags and the meta-data in faces-config.xml. The following will be required. A DTD for faces-config.xml Setting Up the Project Create a new web project by selecting File > [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-67","post","type-post","status-publish","format-standard","hentry","category-general"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3I4g9-15","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/posts\/67","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/comments?post=67"}],"version-history":[{"count":4,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/posts\/67\/revisions"}],"predecessor-version":[{"id":1972,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/posts\/67\/revisions\/1972"}],"wp:attachment":[{"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/media?parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/categories?post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/priscimon.net\/coding\/wp-json\/wp\/v2\/tags?post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}