Comment 4 for bug 512503

Revision history for this message
Thibaut (thibaut-blue) wrote :

That's why I'm using the clone function to make a clone?

Here is the list code:

I have to call

%{
s = s.removeHighlighted(key);
}%

to remove the keys again.

<div id="reduced_tagcloud">
      #{list items:normordered, as:'key'}
       #{if !s.isHighlighted(key)}
        <span class="tag${r.normout.getCount(key)+1}"><span class="type${r.normout.getCount(key)+1}"><a href="@{www.WebSearch.index(s.clone().addHighlighted(key).setPage(0))}">${key}<!--${r.freqout.getCount(key)}--></a></span></span>
        %{
         s = s.removeHighlighted(key);
        }%

       #{/if}
       #{else}
        <span class="tag${r.normout.getCount(key)+1} tag${r.normout.getCount(key)+1}selected"><span class="type${r.normout.getCount(key)+1}"><a href="@{www.WebSearch.index(s.clone().removeHighlighted(key).setPage(0))}">${key}<!--${r.freqout.getCount(key)}--></a></span></span>
       #{/else}
      #{/list}
</div>

 public SearchSettings addHighlighted(String tag) {
  if (sqh == null) {
   sqh = new HashSet<String>();
  }
  sqh.add(tag);
  return this;
 }

 public SearchSettings removeHighlighted(String tag) {
  if (sqh != null) {
   sqh.remove(tag);
  }
  return this;
 }

Would it be possible to create a function similar to @ that automatically creates clones of each variable passed, before evaluating .setPage(0) etc..?