Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to override markPrevious and markNext methods on rich:suggestionBox javascript
    primarykey
    data
    text
    <p>I have a requirement where users should be able to navigate from the first to the last item in a rich:suggestionBox's list by pressing the key, and vice versa by pressing the .</p> <p>I need to get this working on richfaces 3.3.x</p> <p>The quest to get this done has led me to the javascript that is behind the rich:suggestionBox. You can find it at <a href="http://anonsvn.jboss.org/repos/richfaces/tags/3.3.3.Final/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js" rel="nofollow noreferrer">JBoss anon svn</a>. The methods in question are <em>markPrevious()</em> and <em>markNext()</em>.</p> <p>This is how they are defined on the <em>Suggestion.Base.prototype</em> :</p> <pre><code>markPrevious: function() { if (this.index &gt; 0) this.index--; //else this.index = this.entryCount - 1; }, markNext: function() { if (this.index &lt; this.entryCount - 1) this.index++; //else this.index = 0; }, </code></pre> <p>As you can see, the functionality that I need is there, but for some reason they placed it in comment. So I tried to override the methods by placing the following bit of javascript in my template file that is used by all my pages:</p> <pre><code>&lt;script type="text/javascript"&gt; //&lt;![CDATA[ if(Suggestion) { function newMarkPrevious() { if (this.index &gt; 0) this.index--; else this.index = this.entryCount - 1; } function newMarkNext() { if (this.index &lt; this.entryCount - 1) this.index++; else this.index = 0; } Suggestion.Base.prototype.markPrevious = newMarkPrevious; Suggestion.Base.prototype.markNext = newMarkNext; } //]]&gt; &lt;/script&gt; </code></pre> <p>Now, if I inspect the <em>Suggestion</em> object with firebug, I can see that the methods indeed get overridden. However, all rich:suggestionBoxes on my pages still use the old implementation. So, I'm thinking that somehow, the objects behind the rich:suggestionBoxes get created <strong>before</strong> I override the prototype. And this is where I'm stuck. I don't know how I could get my version in there <strong>before</strong> any of those suggestionBoxes get created.</p> <p>Has anyone got an idea on how to solve this?</p> <p>Thanks,</p> <p>Kim.</p> <p>P.S. I realise that there is also the option of just adjusting the code directly in the richfaces-ui.jar, but I don't want to have a custom built jar.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload