Enterprise Java

NetBeans Java EE Tip #7: Overlooked Java Class and XHTML Editor Shortcuts

Sometimes the most helpful features of an IDE are the most overlooked.  In this post, I will outline five NetBeans Java and XHTML editor shortcuts that can be used when developing Java EE applications.

#1 – Easily Fix Namespaces and Classes

Perhaps you have added a new JSF tag to a view for which the namespace has not yet been declared, or maybe you removed a tag that is no longer required, and the namespace is no longer needed.  NetBeans provides the SHIFT+CMD+I (OS X) and CTRL+SHIFT+I (PC) shortcuts to fix namespaces in the current file.  Much in the same manner, the same shortcut can be used in a Java class to fix all imports.  This shortcut enables easier management of namespaces in XHTML and imports in Java classes.

Figure 1: Fix imports in Java Class

Figure 2: Fix namespaces in XHTML
Figure 2: Fix namespaces in XHTML

#2 – Autocompletion within XHTML and HTML

Sometimes it is easy to forget the name of that controller class when adding an EL expression to your XHTML view.  Other times we remember the name, but don’t want to type out the entire path to the controller and method or property.  NetBeans provides auto-completion for Expression Language within XHTML files to remedy these issues.  Just start typing within an EL expression to see the auto-completion for all of the JSF controllers and/or properties/methods for the current project.

Figure 3: Auto-completion in Expression Language
Figure 3: Auto-completion in Expression Language

#3 – Quick Navigation to controller class or backing bean method

To quickly navigate to a JSF controller or property/method declaration that is referenced within an EL expression, simply hold down the CMD (OS x) or CTRL (PC) button and mouse click on the name.

#4 – Quickly Navigate to JavaScript

To quickly navigate to a referenced JavaScript function, hold down the CMD (OS x) or CTRL (PC) button and mouse click on the reference.

Figure 4: CTRL or CMD + click on function name
Figure 4: CTRL or CMD + click on function name

#5 – Navigate Directly to Stylesheet

To quickly navigate to a CSS Style, hold down the CMD (OS x) or CTRL (PC) button and mouse click on the “id” or “class” attribute of the element that is referencing the style, and a drop-down list of all matches will be displayed

Figure 5: CTRL or CMD + click on "id", "class", or "styleClass" attribute
Figure 5: CTRL or CMD + click on “id”, “class”, or “styleClass” attribute

Josh Juneau

Josh is an application developer and technical writer. He has authored several books for Apress, primarily focusing on Java development. Most recently, he has authored Java EE 7 Recipes, Introducing Java EE 7, and Java 8 Recipes. Josh is a member of the JCP, and he is on the JSF 2.3 Expert Group.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button