JsfEditorSupport
Editor Support in JSF Configuration Files and JSP Files
Contents |
Editor for JSF Configuration File
Code Completion
On top of the generic XML editing features, when user uses code completion for the JSF tags and their attributes, there is shown help in Javadoc popup window. Like for html tags.
In the XML Editor, declare the following JSF tag libraries in the JSF configuration files. Do this by adding the following code to the top of the file:
JSF 1.2:
<faces-config version="1.2"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
JSF 1.1:
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd"> <faces-config>
Available child elements under <faces-config> are:
| application | |
|---|---|
| component | |
| converter | |
| faces-config-extension | JSF 1.2 only |
| factory | |
| lifecycle | |
| managed-bean | |
| navigation-rule | |
| referenced-bean | |
| render-kit | |
| validator | |
Dynamic Javadoc for its child elements and attributes are also available for the bundled JSF 1.2. JSF 1.1 from the update center does not include the Dynamic Javadoc but can be added from the IDE.
Hyperlink
By using the Hyperlink inside the JSF configuration file, developers can fast navigate from one source to another reference. You can visualize the link by holding down the CTRL key and mouse over a hyperlink active area. After you see the text changed into a link, click on it by the left mouse button. An appropriate source should be open. The tables below briefly displays this feature in the JSF support.
| JSF Element | File to open |
|---|---|
| managed-bean-class component-class renderer-class property-class validator-class attribute-class message-bundle action-listener application-factory converter-class converter-for-class faces-context-factory key-class lifecycle-factory navigation-handler phase-listener property-resolver referenced-bean-class render-kit-class render-kit-factory value-class variable-resolver | the appropriate Java file |
| from-view-id to-view-id | the appropriate resource file |
| Example | File opened |
|---|---|
| <managed-bean-class>foo.ManagedBean</managed-bean-class> | the Java file ManagedBean.java under package foo |
| <to-view-id>/Page2.jsp</to-view-id> | the JSF page file Page2.jsp under the context root |
Editor for JSP File
Code Completion
In the JSP Editor, the IDE declares the following JSF tag libraries in the JSF page files. It adds the following code to the top of the file:
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %> <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
By default code completion offers the tags with default prefixes. Developers
can add extra namespace definition or modify the default prefix. The code
completion will adjust to include the new prefixes in the list.
The default prefixes are:
| Taglib URI | Prefix | Description |
|---|---|---|
| uri="http://java.sun.com/jsf/core" | "f" | JSF - core components |
| uri="http://java.sun.com/jsf/html" | "h" | JSF - html components |
| uri="http://java.sun.com/jsp/page" | "jsp" | JSP - page components |
More available prefixes are also available when drag-n-drop components from the Palette:
| Taglib URI | Prefix | Description |
|---|---|---|
| uri="http://java.sun.com/jsp/jstl/core" | "c" | JSP - JSTL core components |
| uri="http://java.sun.com/jsp/jstl/sql" | "sql" | JSP - JSTL SQL components |
Available tags for code completion under the JSP editor are (besides the html tags) listed below. Currently only JSTL core and SQL code clips are available from the Palette. Future plans for adding Palette/UI of others are in progress.
| http://java.sun.com/jsf/core | ||
|---|---|---|
| <f:actionListener/> | <f:attribute/> | <f:convertDateTime/> |
| <f:convertNumber/> | <f:converter/> | <f:facet/> |
| <f:loadBundle/> | <f:param/> | <f:phaseListener/> |
| <f:selectItem/> | <f:selectItems/> | <f:setPropertyActionListener/> |
| <f:subview/> | <f:validateDoubleRange/> | <f:validateLength/> |
| <f:validateLongRange/> | <f:validator/> | <f:valueChangeListener/> |
| <f:verbatim/> | <f:view/> | |
| http://java.sun.com/jsf/html | ||
| <h:column/> | <h:commandButton/> | <h:commandLink/> |
| <h:dataTable/> | <h:form/> | <h:graphicImage/> |
| <h:inputHidden/> | <h:inputText/> | <h:inputTextarea/> |
| <h:message/> | <h:outputFormat/> | <h:outputLabel/> |
| <h:outputLink/> | <h:outputText/> | <h:panelGrid/> |
| <h:panelGroup/> | <h:selectBooleanCheckbox/> | <h:selectManyCheckbox/> |
| <h:selectManyListbox/> | <h:selectManyMenu/> | <h:selectOneListbox/> |
| <h:selectOneMenu/> | <h:selectOneRadio/> | |
| http://java.sun.com/jsp/page | ||
| <%@ include ... %> | <%@ page ... %> | <%@ taglib ... %> |
| <jsp:attribute/> | <jsp:body/> | <jsp:element/> |
| <jsp:expression/> | <jsp:fallback/> | <jsp:forward/> |
| <jsp:getProperty/> | <jsp:include/> | <jsp:param/> |
| <jsp:params/> | <jsp:plugin/> | <jsp:setProperty/> |
| <jsp:text/> | <jsp:useBean/> | |
| http://java.sun.com/jsp/jstl/core | ||
| <c:catch/> | <c:choose/> | <c:forEach/> |
| <c:forTokens/> | <c:if/> | <c:import/> |
| <c:otherwise/> | <c:out/> | <c:param/> |
| <c:redirect/> | <c:remove/> | <c:set/> |
| <c:url/> | <c:when/> | |
| http://java.sun.com/jsp/jstl/sql | ||
| <sql:dataParam/> | <sql:param/> | <sql:query/> |
| <sql:setDataSource/> | <sql:transaction/> | <sql:update/> |
The namespace will automatically be imported into the root tag when you
drag-n-drop a component or by using the code completion to add one.
By default, the JSF tag code completion provides tag attributes for the following standard JSF/JSP libraries. Their associate dynamic help will also be provided.
- http://java.sun.com/jsf/core
- http://java.sun.com/jsf/html
- http://java.sun.com/jsp/page
- http://java.sun.com/jsp/jstl/core
You can make use of the IDE's built-in support for code completion. As you type, press Ctrl-Space to list suggestions based on the context. In this manner, code completion can help you add tag names and attributes, such as the URIs of the tab libraries.
On top of the generic JSP editing features, the JSP editor for the JSF page file provides additional code completion for
- managed beans
- resource bundles
| Example | Code Completion UI |
|---|---|
| Managed Beans |
|
| Resource Bundles |
|
Hyperlink
When user edits a jsp file and uses JSF tags, it's very useful to provide hyperlink for faster navigation between the jsp files and the JSF configuration file, application resources etc. You can visualize the link by holding down the CTRL key and mouse over a hyperlink active area. After you see the text changed into a link, click on it by the left mouse button. An appropriate source should be open. The tables below briefly displays this feature in the JSF support.
| Example | File opened |
|---|---|
</span><h:outputText value="#{ManagedBean.min}"/></h3> </tt> | the JSF configuration file on position where the managed bean been defined |
| <tt> <h3><h:outputText value="#{ManagedBean.min}"/></h3> </tt> | the appropriate Java file on position where the getter for the property been defined |
Refactoring Support
The refactoring support processes all files in the list of JSF configuration files. Bean and Java class/method usages are found in bean and alias elements and their subelements, as well as elements in the util namespace. The tables below displays the supported JSF elements.
| JSF Element | Refactoring Class |
|---|---|
| <tt> managed-bean </tt> | <tt> managed-bean-class </tt> |
| <tt> converter </tt> | <tt> converter-class </tt> <tt> converter-for-class </tt> |
| Example | Refactoring UI |
|---|---|
| Managed Beans |
|
| Folder / Package |
|
Move Support
Move support associate with the refactoring is also provided.
| Example | Move UI |
|---|---|
| Managed Beans |
|
Save Delete Support
Save Delete support associate with the refactoring is also provided which will search the usage with preview. If references to selected elements found, then the following warning dialog will be shown.
Otherwise the Save Delete refactoring preview will be displayed.
| Example | Safe Delete UI |
|---|---|
| Managed Beans |
|
Find usages
The JSF support will plug into the Java find usages to show JSF beans definitions which refer to Java elements (classes, methods, fields, properties). The Find Usages action will be available for bean definitions as well, to show beans used by other beans.
| Example | Usages UI |
|---|---|
| Managed Beans |
|








