Compare Revisions

How to implement a custom autocomplete search component

Revision 37908:

Revision 37908 by roel on

Revision 37909:

Revision 37909 by Mozdevuser22 on

Title:
How to implement a custom autocomplete search component
How to implement a custom autocomplete search component
Slug:
How_to_implement_custom_autocomplete_search_component
How_to_implement_custom_autocomplete_search_component
Content:

Revision 37908
Revision 37909
nn287    <div class="geckoVersionNote">
288      <span style="font-size: x-large;"><strong>Introduced in Gec
 >ko 2 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)</strong></span
 >>
289    </div>
290    <div class="geckoVersionNote">
291      The components registration was changed (see &nbsp;more inf
 >o here:&nbsp;<a href="/en/XPCOM/XPCOM_changes_in_Gecko_2.0" title
 >="https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2
 >.0">https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko
 >_2.0</a>),
292    </div>
293    <div class="geckoVersionNote">
294      So you need to make the following 2 additional changes:
295    </div>
296    <div class="geckoVersionNote">
297      <u><strong>Change 1 - Add "<em>NSGetFactory</em>", after "<
 >em>NSGetModule</em>", in the end of JS file, as follows:</strong>
 ></u>
298    </div>
299    <div class="geckoVersionNote">
300      <code>function NSGetFactory(cid) {</code>
301    </div>
302    <div class="geckoVersionNote">
303      <code>&nbsp;&nbsp;if (cid.toString().toUpperCase() != CLASS
 >_ID.toString().toUpperCase())</code>
304    </div>
305    <div class="geckoVersionNote">
306      <code>&nbsp;&nbsp; &nbsp; &nbsp;throw Components.results.NS
 >_ERROR_FACTORY_NOT_REGISTERED;</code>
307    </div>
308    <div class="geckoVersionNote">
309      <code><br></code>
310    </div>
311    <div class="geckoVersionNote">
312      <code>&nbsp;&nbsp;return SimpleAutoCompleteSearch;</code>
313    </div>
314    <div class="geckoVersionNote">
315      <code>}</code>
316    </div>
317    <div class="geckoVersionNote">
318      <u><strong>Change 2 - explictly register the compienent by 
 >adding the following 2 lines in the "chrome.manifest":</strong></
 >u>
319    </div>
320    <div class="geckoVersionNote">
321      <div>
322        <code>component {<span class="Apple-style-span" style="fo
 >nt-family: 'Courier New', 'Andale Mono', monospace; line-height: 
 >normal; white-space: pre;">6224daa1-71a2-4d1a-ad90-01ca1c08e323</
 >span>7} components/[YourFileName].js</code>
323      </div>
324      <div>
325        <code>contract @mozilla.org/autocomplete/search;1?name=<s
 >pan class="Apple-style-span" style="font-family: 'Courier New', '
 >Andale Mono', monospace; line-height: normal; white-space: pre;">
 >simple-autocomplete</span> {<span class="Apple-style-span" style=
 >"font-family: 'Courier New', 'Andale Mono', monospace; line-heigh
 >t: normal; white-space: pre;">6224daa1-71a2-4d1a-ad90-01ca1c08e32
 >3</span>}</code>
326      </div>
327    </div>
328    <p>
329      &nbsp;
330    </p>
tt332      <strong>Deleting Cache file, in order that changes in .JS f
 >ile will be reflected:</strong><br>
288      &nbsp;&nbsp;&nbsp;&nbsp; For Microsoft Xp users: If you are333      For Microsoft Xp users: If you are using xulrunner, be sure
> using xulrunner, be sure to delete the following files :<br>> to delete the following files, after making changes in your JS f
 >ile :<br>

Back to History