1. #1
    Ext User
    Join Date
    Apr 2008
    Posts
    6
    Vote Rating
    0
    methodinsane is on a distinguished road

      0  

    Default Registry usage

    Registry usage


    Hi all.

    I'm having some difficulty with the registry. In the description it says it's a local store for objects and I understand it's a Map.

    Are there limitation to what can be put in there? For example I hold the Client (logged in user) username for easy access. Here's some code:

    Code:
    rules = new RuleSetMap();
    tasks = new RuleSetTasks();
    editor = new RuleSetEditor();
    
    clientName = new String("svadmin");
    		
    Registry.register("rulesmap", rules);
    Registry.register("tasks", tasks);
    Registry.register("editor", editor);
    Registry.register("clientname", clientName);
    		
    Info.show("Client Name", "Something", (String)Registry.get("clientname"));
    Bear in mind RuleSetTasks/Editor are widgets I've created and RuleSetMap is a map. They hold references I can use from other Widgets. Any idea why the String is not being registered?

    What would be the correct usage for the Registry. I want to able to use it as a global (Yuck!!!) store for a rough demo I'm doing.

    Thanks,
    MI

  2. #2
    Ext User
    Join Date
    Apr 2008
    Posts
    18
    Vote Rating
    0
    baluba is on a distinguished road

      0  

    Default


    You can put any object in Registry, it's just a Map<String,Object>.
    But the Info.show method ultimately calls Util.Format which relies on {} placeholders to format the string. Try this,

    Code:
    Info.show("Client Name", "Username: {0}", (String)Registry.get("clientname"));

  3. #3
    Ext User
    Join Date
    Apr 2008
    Posts
    6
    Vote Rating
    0
    methodinsane is on a distinguished road

      0  

    Default


    Is the Registry completely global or is limited by package or something.

    That worked by the way but I was only doing that as a test. My main problem is I try to access the data elsewhere in the app and it returns null. The code below presents a problem cos the editor uses the client within its constructor.

    Code:
    editor = new RuleSetEditor();
    clientName = new String("svadmin");
    Registry.register("clientname", clientName);
    I corrected this by making sure the string is created and registered before the editor is created like so:

    Code:
    clientName = new String("svadmin");
    Registry.register("clientname", clientName);
    editor = new RuleSetEditor();
    Now when I debug and break at the RuleSetEditor constructor Registry.get("clientname") returns null. Any ideas?

    Thanks,
    MI

  4. #4
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572
    Vote Rating
    3
    gslender is on a distinguished road

      0  

    Default


    MI,

    The Registry map is static instance and availble globally to the JVM instance that is running your application (not sure what happens in JS but I'm guessing Google takes care of that).

    You access that static instance through static methods etc... all good.

    Can you describe in detail what you are doing (ie in hosted mode?) and how big is your app (meaning is it broken-up into parts, if so how etc). I'd doubt the Registry would survive history refreshes unless its tied into Google history state model - and it doesn't look like it is... but I'm not 100% on that.

  5. #5
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572
    Vote Rating
    3
    gslender is on a distinguished road

      0  

    Default


    MI - more to the point of what you are trying to do...

    Are you trying to store username/pwd stuff in state? If so, I've taken this approach.

    Stored a hash-token in a cookie that I interogate when needed, the hash-token is issued by the RPC Servlet when I authenticate - the token is only valid for a session (ie it eventually timesout) and I even refresh (replace) the token on every RPC call.

    I would suggest you DONT store the user/pwd in a cookie - but storing a temp auth-token is fine as after use, its useless anyways....

  6. #6
    Ext User
    Join Date
    Apr 2008
    Posts
    6
    Vote Rating
    0
    methodinsane is on a distinguished road

      0  

    Default


    Hi gs,

    Ok. It's a demo so I've not designed it to take care of history nor is it necessary to really handle thorough authentication. Secondly I don't intend on storing usename/passwd for authentication purpose but they will be available in a cookie if need be(my boss is creating a secure login jsp that then redirects to my app upon successful login).

    The basic idea is I provide an app for a user to edit rules in java that are run on the server usnig a tool my boss developed.
    There are two main tabs edit and view.
    Edit tab represents the the editor (a content panel with a richtextarea and some buttons) and the rules manager (another content panel with list box and some buttons).
    View tab I'll ignore for except to say when these rules are ran on the server the tool products jpeg data which I then load in dynamically every few mins (still attempting to load dynamic images but that's for another day another post).

    So upon appload the rules list is populated with an RPC call. Rules (and JPEG results) are stored in a folder on the server and this is where I use the client name to provide part of path to the store. I've a server config xml file that holds the paths to the various folders but the client name is the key. After I've the rules list RPC calls are used to load in the rule contents to the editor's richtextarea.

    It's a simple enough app and if we take it further then it'll be ripped apart anyway.

    You mentioned about using the static Registry store from static methods but I only use instance methods on the client side but I'm sure since it's static I can do that.

    Thanks for reply,
    JP

  7. #7
    Sencha User
    Join Date
    Apr 2013
    Posts
    28
    Vote Rating
    0
    kozla13 is on a distinguished road

      0  

    Default


    What happend to this future in ext gwt version 3 ??