XUL persist annoyances
Tags:
.in-english,
firefox,
javascript,
programming,
xul
XUL Elements have a persist attribute, that is documented as
A space separated list of attributes that are maintained when the window is closed. When the window is re-opened, the values of persistent attributes are restored. In Mozilla, persistent attributes are stored in the per-profile file localstore.rdf. Persistence can also be stored using the document.persist function. In order for persistence to work, the element must also have an id.I've learned some things about it today:
- It does not seem to work for the "value" attribute of "textarea" elements
- It is stored as RDF
- It asks for some quite verbose code if you need to access to it
var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].
getService(Components.interfaces.nsIRDFService);
var rdfLocalStoreDS = Components.classes["@mozilla.org/rdf/datasource;1?name=local-store"].
getService(Components.interfaces.nsIRDFDataSource);
var rdfRes = rdfService.GetResource("uri of interest after about in localstore.rdf");
var screenXRes = rdfService.GetResource("screenX");
var screenYRes = rdfService.GetResource("screenY");
if (rdfLocalStoreDS.hasArcOut(rdfRes, screenXRes) &&
rdfLocalStoreDS.hasArcOut(rdfRes, screenYRes)) {
var screenX = rdfLocalStoreDS.GetTarget(rdfRes, screenXRes, true).
QueryInterface(Components.interfaces.nsIRDFLiteral)
var screenY = rdfLocalStoreDS.GetTarget(rdfRes, screenYRes, true).
QueryInterface(Components.interfaces.nsIRDFLiteral)
window.moveTo(screenX.Value, screenY.Value);
QueryInterface(Components.interfaces.nsIRDFLiteral)
for quite a while of wasted time. In another piece of code that I wrote, this was magically called for me by checking if (target instanceof Components.interfaces.nsIRDFLiteral);
I need to get a better understanding of Mozilla's component model mechanisms... I also failed to use "Value" with a capital letter, to add up to the waste. :-(
No hay comentarios:
Publicar un comentario