| <?xml version="1.0" encoding="UTF-8"?> |
| <!DOCTYPE html |
| PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html> |
| <head> |
| <link rel="stylesheet" type="text/css" href="../org.eclipse.wst.doc.user/common.css" /> |
| <title>Content assist</title> |
| </head> |
| <body id="csrcedt006"><a name="csrcedt006"><!-- --></a> |
| |
| <h1 class="topictitle1">Content assist</h1> |
| <div><p>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.</p><p>Most of the structured text editors have content assist. For a list of |
| editors that have content assist, see <a href="csrcedt004.html">Structured |
| text editors for markup languages</a>. For information on how to get content |
| assistance, see <a href="tsrcedt005.html">Getting content assistance |
| in structured text editors</a></p> |
| <p>The sections below describe specifics of HTML content assist, JavaScript™ content |
| assist, and JSP content assist.</p> |
| <div class="skipspace"><h4 class="sectiontitle">HTML content assist</h4><p>HTML is flexible in that some |
| HTML elements allow end tags to be optionally omitted, such as <samp class="codeph">P</samp>, <samp class="codeph">DT</samp>, <samp class="codeph">DD</samp>, <samp class="codeph">LI</samp>, <samp class="codeph">THEAD</samp>, <samp class="codeph">TR</samp>, <samp class="codeph">TD</samp>, <samp class="codeph">TH</samp>, |
| and so on. Other HTML elements that are defined to have no content may require |
| the end tag always be omitted, such as <samp class="codeph">BR</samp>, <samp class="codeph">HR</samp>, <samp class="codeph">LINK</samp>, <samp class="codeph">META</samp>, |
| and <samp class="codeph">IMG</samp>. 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 <samp class="codeph">HEAD</samp> element in HTML only permits zero or |
| one occurrences of a <samp class="codeph">TITLE</samp> tag in its content. If you prompt |
| for content assist within a <samp class="codeph">HEAD</samp> content that already contains |
| a <samp class="codeph">TITLE</samp> tag, content assist will still show <samp class="codeph">TITLE</samp> 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 (<samp class="codeph"><p></samp>) , the first item |
| in the content assist list will be the corresponding closing paragraph (<samp class="codeph"></p></samp>) |
| 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:<br /><img src="../images/ncontass.gif" alt="HTML Content assist" /><br /></p> |
| <p>Tag proposals are listed |
| alphabetically. If you type a <samp class="codeph"><</samp> (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 <samp class="codeph"><</samp> 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> |
| <div class="restriction"><span class="restrictiontitle">Restriction: </span><img src="../images/nlinux.gif" alt="For Linux." /> When using Linux (Motif or |
| GTK) and a DBCS locale, double-clicking on the content assist list can sometimes |
| cause the Java™ VM to terminate. Instead of double-clicking on |
| the list, use the arrows and Enter keys to make the selection from the list.</div> |
| </div> |
| <div class="skipspace"><h4 class="sectiontitle">JavaScript content assist</h4><p>Items |
| in the JavaScript content assist list are preceded by an Internet |
| Explorer icon, a Netscape icon, or both, to indicate whether specific JavaScript 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 (<img src="../images/nquest.gif" alt="Question mark icon" />) |
| 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 JavaScript file:<br /><img src="../images/njscdast.gif" alt="JavaScript content assist" /><br /></p> |
| <p>Code |
| proposals are listed alphabetically. If you type a <samp class="codeph">. </samp> (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> |
| </div> |
| <div class="skipspace"><h4 class="sectiontitle">JSP content assist</h4><p>You have many options for embedding Java 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, <samp class="codeph"><jsp:expression></samp>). |
| 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 <img src="../images/nmacscrp.gif" alt="JSP scriptlet content assist" /> from |
| the proposal list to insert <samp class="codeph"><% %></samp> in the document.</p> |
| <div class="p">Scriptlets |
| are inserted in a tag <samp class="codeph"><% %></samp>. For example: <pre><% System.currentTimeMillis() %></pre> |
| </div> |
| <p>This |
| example will evaluate the Java statement to get the current time |
| in milliseconds.</p> |
| <div class="p">To have the result of the statement inserted in the |
| file, put an equals sign (=) in the front of the statement. For example: <pre><b>This is the time : <%= System.currentTimeMillis()%></b></pre> |
| </div> |
| <div class="p">When you are within a scriptlet you are writing pure Java code. |
| Therefore, content assist works exactly the same as it does for the Java editor. |
| For example, if you request content assist after <samp class="codeph">System</samp>, |
| content assist displays a list of methods. <div class="note"><span class="notetitle">Note: </span>Java content assist works only in a Web |
| project, because it requires a buildpath to find the appropriate Java classes.</div> |
| </div> |
| <div class="p">There |
| are also special tags such as useBean. For example: <pre><jsp:useBean id="useBean" class="java.lang.String"/></pre> |
| </div> |
| <p>The |
| useBean tag enables you to create a bean called <samp class="codeph">aString</samp> of |
| type <samp class="codeph">String</samp>. Then when you use content assist, this is recognized |
| as a declared variable. For example, if you use content assist after <samp class="codeph">aString</samp>, |
| as follows:</p> |
| <div class="p"> <pre><% aString. %> </pre> |
| the content assist |
| list shows available methods. This is because <samp class="codeph">aString</samp> has |
| been declared as a bean of type String.</div> |
| <div class="p">If you use content assist after |
| the <samp class="codeph">a</samp>, as follows: <pre><% a %> </pre> |
| content |
| assist knows that <samp class="codeph">aString</samp> exists, and it is shown in the |
| content assist list.</div> |
| </div> |
| </div> |
| <div><p><b class="relconceptshd">Related concepts</b><br /> |
| <a href="csrcedt004.html" title="Structured text editor is any of several text editors that you can use to edit various markup languages such as HTML, JavaScript, or XML.">Structured text editors for markup |
| languages</a><br /> |
| </p> |
| <p><b class="reltaskshd">Related tasks</b><br /> |
| <a href="tsrcedt005.html" title="To get help in adding markup to a file, you can use content assist in a structured text editor. Content assist helps you insert or finish a tag or function or finish a line of code in a structured text editor.">Getting content assistance in structured |
| text editors</a><br /> |
| <a href="tsrcedt024.html" title="HTML content assist provides several templates, or chunks of predefined code, that you can insert into a file. You can use the default templates as provided, customize the default templates, or create your own templates.">Adding and removing HTML templates</a><br /> |
| </p> |
| </div><p> |
| (C) Copyright IBM Corporation 2000, 2005. All Rights Reserved. |
| </p> |
| </body> |
| </html> |