Hey All,

I'm seeing a bug in our container with respect to positioning of a
gadget on the page.

Currently, the gadget.id is simply a numerically incremented value that
is assigned based on the ordering of the gadget on the page. Moving the
gadget to a different position causes the prefs to be lost if the
ordering of rendering changes. Since we have drag and drop positioning
this is a little annoying.

I'm going to be overriding the container's default addGadget function
with an implementation which allows setting the gadget.id distinctly
rather than relying on an incremented value. Looking through the code it
doesn't appear that it really matters if the id is numerical or a
string.

So, I'm tempted to do this


gadgets.Container.prototype.addGadget = function(gadget) {
  if (!gadget.id) {
    gadget.id = this.getNextGadgetInstanceId();
  }
  gadget.setUserPrefs(this.userPrefStore.getPrefs(gadget));
  this.gadgets_[this.getGadgetKey_(gadget.id)] = gadget;
};


This way I can set the gadget.id prior to passing it to
gadgets.container.addGadget(gadget).

Any reason why this shouldn't be done?


Raymond Augé
Software Engineer
Liferay, Inc.
Enterprise. Open Source. For Life.

Reply via email to