uibinder - GWT, CssStyle being injected multiple times -
i have been using clientbundle , cssresources quite time have noticed styles getting injected many times. 1 thing can point finger use quite few <ui:with field='resources' type='com.vf.client.resources.resources' />
in templates , suspicion creating multiple copies of clientbundle. 1 thing may cause use ray ryan's concept of caching views in clientfactory of views created before ever being attached dom. in base view use provided=true on resources not let uibinder generate new 1 me. may not working though, suspecting , ui:with creating new copy , ignoring provided=true. have used developer tools in chrome , firebug see , in both cases style getting injected many times. not sure on how resolve problem without removing resources class uibinder templates , make quite bit of work. ideas appreciated.
/** * * @author chris */ public abstract class viewimpl extends composite implements iview, requiresresize { @uifield(provided = true) public final resources resources; } public interface resources extends clientbundle, celltable.resources, celllist.resources, datagrid.resources { /** * these obfuscated styles. * * @return */ @source({ "default.css", "default-external.css"}) public style style(); }
update
i have been using factory/singleton make sure creates one. create resources clientbundle in clientfactory implementation when application starts. in application start call ensureenjected on style , on ensureinjected never called in code.
this factory gets singleon request factory. used have static initializer inside interface moved while clean multiple styles problem.
import com.google.gwt.core.client.gwt; public class resourcesfactory { private static resources instance = null; private resourcesfactory() { } public static final resources getresources() { if (instance == null) { instance = gwt.create(resources.class); } return instance; } }
my client bundle gets initialized , injected here only.
@override public void onmoduleload() { if (window.location.getparametermap().containskey("debug")) { window.alert("remote debugging enabled, see server log debug information"); remotedebugservice.enable(); } try { clientfactory = clientfactory.instance; masterlayoutpanel = clientfactory.getmasterlayoutpanel(); } catch (exception e) { logger.log(level.severe, "unable instantiate clientfactory", e); window.alert("somebody broke build, add ?debug url enable remote debugging" + e.getmessage()); } rootlayoutpanel.get().add(masterlayoutpanel); styleinjector.inject(clientfactory.getresources().style().gettext()); placehistoryhandler historyhandler = new placehistoryhandler(clientfactory.getplacehistorymapper()); placecontroller placecontroller = clientfactory.getplacecontroller(); // start placehistoryhandler our placehistorymapper historyhandler.register(placecontroller, clientfactory.geteventbus(), defaultplace); startapplication(clientfactory, historyhandler); }
what mean injected multiple times?
clientbundle's singleton's (see thread will referring single clientbundle class multiple uibinders cost anything?).
shouldn't matter if use provided=true
or not.
but if want avoid clientbundle proxy can use gin
or factory
instantiate (gwt.create
or magically via @inject
) clientbundle
once , inject views
guess in compiled code won't make of difference.
Comments
Post a Comment