blob: 81d509da8621b9d18d7729953c038b3b7bd81c57 [file] [log] [blame]
<?xml version="1.0" encoding="utf-8"?>
<!--Arbortext, Inc., 1988-2005, v.4002-->
<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN"
"..\dtd\concept.dtd">
<concept id="csrcedt006" xml:lang="en-us">
<title>Content assist</title>
<shortdesc>Content assist helps you insert or finish a tag or function or
finish a line of code in a structured text editor. The placement of the cursor
in the source file provides the context for the content assist to offer suggestions
for completion.</shortdesc>
<prolog><metadata>
<keywords><indexterm>content assist<indexterm>overview</indexterm></indexterm><indexterm>structured text editors<indexterm>content assist</indexterm></indexterm>
</keywords>
</metadata></prolog>
<conbody>
<p>Most of the structured text editors have content assist. For a list of
editors that have content assist, see <xref href="csrcedt004.dita" type="concept">Structured
text editors for markup languages</xref>. For information on how to get content
assistance, see <xref href="tsrcedt005.dita" type="task">Getting content assistance
in structured text editors</xref></p>
<p>The sections below describe specifics of HTML content assist, <tm tmclass="special"
tmowner="Sun Microsystems, Inc." tmtype="tm" trademark="JavaScript">JavaScript</tm> content
assist, and JSP content assist.</p>
<section><title>HTML content assist</title><p>HTML is flexible in that some
HTML elements allow end tags to be optionally omitted, such as <codeph>P</codeph>, <codeph>DT</codeph>, <codeph>DD</codeph>, <codeph>LI</codeph>, <codeph
>THEAD</codeph>, <codeph>TR</codeph>, <codeph>TD</codeph>, <codeph>TH</codeph>,
and so on. Other HTML elements that are defined to have no content may require
the end tag always be omitted, such as <codeph>BR</codeph>, <codeph>HR</codeph>, <codeph>LINK</codeph>, <codeph>META</codeph>,
and <codeph>IMG</codeph>. This flexibility makes the content assist function
within the HTML source page editor less precise than it might be with a more
rigidly constrained markup language.</p><p>HTML content assist is most beneficial
when you need to complete a tag name, add an attribute name-value pair within
a start tag, or select from an enumerated list of attribute values.</p><p>Although
content assist only shows attribute names that have not already been specified
in a start tag, it does not take into account grammar constraints for tags.
For example, the <codeph>HEAD</codeph> element in HTML only permits zero or
one occurrences of a <codeph>TITLE</codeph> tag in its content. If you prompt
for content assist within a <codeph>HEAD</codeph> content that already contains
a <codeph>TITLE</codeph> tag, content assist will still show <codeph>TITLE</codeph> in
its proposal list.</p><p>However, if an attribute is required according to
the DTD/Schema, that attribute will show up at the top of the list, with a
yellow circle indicator on its icon.</p><p>If your cursor is in a position
where content assist is available, a pop-up list of available choices is displayed.
The list is based on the context. For example, if you use content assist directly
after an opening paragraph tag (<codeph>&lt;p></codeph>) , the first item
in the content assist list will be the corresponding closing paragraph (<codeph>&lt;/p></codeph>)
tag.</p><p>The content assist list displays all available tags for the current
cursor position, including templates. The picture below shows the default
content assist list for a paragraph tag example:<image alt="HTML Content assist"
href="../images/ncontass.gif" placement="break"></image></p><p>Tag proposals
are listed alphabetically. If you type a <codeph>&lt;</codeph> (to begin a
new tag) before prompting for content assist, and begin typing the first one
or two letters of the tag that you want to add, the proposal list automatically
refreshes to reflect proposals that match the pattern you have typed. If you
do not type a <codeph>&lt;</codeph> before prompting for content assist, you
can click within the proposal list and then type the letter that the tag begins
with, to reduce (somewhat) the amount of scrolling to locate the desired tag.</p><p>As
you type the first one or two letters of the attribute names or enumerated
attribute values that you want to add to a tag, the list automatically refreshes
to reflect proposals that match the pattern you have typed.</p><note type="restriction"><image
alt="For Linux." href="../images/nlinux.gif"></image> When using Linux (Motif
or GTK) and a DBCS locale, double-clicking on the content assist list can
sometimes cause the <tm tmclass="special" tmowner="Sun Microsystems, Inc."
tmtype="tm" trademark="Java">Java</tm> VM to terminate. Instead of double-clicking
on the list, use the arrows and Enter keys to make the selection from the
list.</note></section>
<section><title><tm tmclass="special" tmowner="Sun Microsystems, Inc." tmtype="tm"
trademark="JavaScript">JavaScript</tm> content assist</title><p>Items in the <tm
tmclass="special" tmowner="Sun Microsystems, Inc." tmtype="tm" trademark="JavaScript">JavaScript</tm> content
assist list are preceded by an Internet Explorer icon, a Netscape icon, or
both, to indicate whether specific <tm tmclass="special" tmowner="Sun Microsystems, Inc."
tmtype="tm" trademark="JavaScript">JavaScript</tm> objects, methods, or functions
are supported by one or both browsers. If the Internet Explorer icon is present,
it indicates that the object, method, or function is supported by Internet
Explorer Version 5.0 or higher. If the Netscape icon is present, it indicates
that the object, method, or function is supported by Netscape Navigator Version
4.7 or higher. A question mark icon (<image alt="Question mark icon" href="../images/nquest.gif"
placement="inline"></image>) in place of one of the browser icons indicates
that it is unknown whether the browser supports the object, method, or function.</p><p>The
picture below shows the default content assist list within a <tm tmclass="special"
tmowner="Sun Microsystems, Inc." tmtype="tm" trademark="JavaScript">JavaScript</tm> file:<image
alt="JavaScript content assist" href="../images/njscdast.gif" placement="break">
</image></p><p>Code proposals are listed alphabetically. If you type a <codeph>. </codeph> (include
the space) before prompting for content assist, and begin typing the first
one or two letters of the code that you want to add, the proposal list automatically
refreshes to reflect proposals that match the pattern you have typed, to reduce
(somewhat) the amount of scrolling to locate the desired code.</p></section>
<section><title>JSP content assist</title><p>You have many options for embedding <tm
tmclass="special" tmowner="Sun Microsystems, Inc." tmtype="tm" trademark="Java">Java</tm> and
HTML code in your JSP pages by using content assist.</p><p>All of the JSP
tags are included both in the template list and in XML format (for example, <codeph>&lt;jsp:expression></codeph>).
To add JSP scriptlet tags, for example, move the cursor to the appropriate
position in the file and press Ctrl+Space to use content assist. Select <image
alt="JSP scriptlet content assist" href="../images/nmacscrp.gif" placement="inline">
</image> from the proposal list to insert <codeph>&lt;% %></codeph> in the
document.</p><p>Scriptlets are inserted in a tag <codeph>&lt;% %></codeph>.
For example: <codeblock>&lt;% System.currentTimeMillis() %></codeblock></p><p>This
example will evaluate the <tm tmclass="special" tmowner="Sun Microsystems, Inc."
tmtype="tm" trademark="Java">Java</tm> statement to get the current time in
milliseconds.</p><p>To have the result of the statement inserted in the file,
put an equals sign (=) in the front of the statement. For example: <codeblock>&lt;b>This is the time : &lt;%= System.currentTimeMillis()%>&lt;/b></codeblock
></p><p>When you are within a scriptlet you are writing pure <tm tmclass="special"
tmowner="Sun Microsystems, Inc." tmtype="tm" trademark="Java">Java</tm> code.
Therefore, content assist works exactly the same as it does for the <tm tmclass="special"
tmowner="Sun Microsystems, Inc." tmtype="tm" trademark="Java">Java</tm> editor.
For example, if you request content assist after <codeph>System</codeph>,
content assist displays a list of methods. <note><tm tmclass="special" tmowner="Sun Microsystems, Inc."
tmtype="tm" trademark="Java">Java</tm> content assist works only in a Web
project, because it requires a buildpath to find the appropriate <tm tmclass="special"
tmowner="Sun Microsystems, Inc." tmtype="tm" trademark="Java">Java</tm> classes.</note></p><p>There
are also special tags such as useBean. For example: <codeblock>&lt;jsp:useBean id="useBean" class="java.lang.String"/></codeblock></p><p>The
useBean tag enables you to create a bean called <codeph>aString</codeph> of
type <codeph>String</codeph>. Then when you use content assist, this is recognized
as a declared variable. For example, if you use content assist after <codeph>aString</codeph>,
as follows:</p><p> <codeblock>&lt;% aString. %> </codeblock>the content assist
list shows available methods. This is because <codeph>aString</codeph> has
been declared as a bean of type String.</p><p>If you use content assist after
the <codeph>a</codeph>, as follows: <codeblock>&lt;% a %> </codeblock>content
assist knows that <codeph>aString</codeph> exists, and it is shown in the
content assist list.</p></section>
</conbody>
<related-links>
<linkpool type="concept">
<link href="csrcedt004.dita"><linktext>Structured text editors for markup
languages</linktext></link>
</linkpool>
<linkpool type="task">
<link href="tsrcedt005.dita"><linktext>Getting content assistance in structured
text editors</linktext></link>
<link href="tsrcedt024.dita"><linktext>Adding and removing HTML templates</linktext>
</link>
</linkpool>
</related-links>
</concept>