Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tommy Albinsson 121 posts 254 karma points
    Apr 16, 2012 @ 13:25
    Tommy Albinsson
    0

    Hookup DictionaryItem.Saving event not working

    Hi,

    I am trying to hookup the event when saving a dictionary items is beeing saved. Though it seems like it does not work. Hooking up the Deleting and New works like a charm. But not Saving. Some example code. New and Deleting does work, but not the Saving. Why?

    public class DictionaryEventHandler : umbraco.BusinessLogic.ApplicationBase
    {
        public DictionaryEventHandler()
        {
            Dictionary.DictionaryItem.Saving += new Dictionary.DictionaryItem.SaveEventHandler(DictionaryItem_Saving);
            Dictionary.DictionaryItem.New += new Dictionary.DictionaryItem.NewEventHandler(DictionaryItem_New);
            Dictionary.DictionaryItem.Deleting += new Dictionary.DictionaryItem.DeleteEventHandler(DictionaryItem_Deleting);
        }
    
        private void DictionaryItem_Deleting(Dictionary.DictionaryItem sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        private void DictionaryItem_New(Dictionary.DictionaryItem sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    
        public void DictionaryItem_Saving(Dictionary.DictionaryItem sender, EventArgs e)
        {
            throw new NotImplementedException();
        }
    }
  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 16, 2012 @ 14:31
    Tom Fulton
    0

    Hi,

    Unfortunately it looks like a bug to me.  The EditDictionaryItem.aspx page doesn't seem to fire the Saving event because it just calls the setValue method itself for each textbox.  It looks like it can be easily fixed by simply adding currentItem.Save() in the save_click method.  The DictionaryItem.Save() method looks like it's just a stub for calling the OnSaving event.  Might be best to create a workitem on codeplex and/or submit a pull request.

    Also not sure what you are trying to do but perhaps this package might help or give you some inspiraton for a workaround.  Dictionary Translator for Umbraco adds a new button to the toolbar of the Dictionary page, that fills each textbox with an auto-translated value.

    HTH,
    Tom

  • Tommy Albinsson 121 posts 254 karma points
    Apr 16, 2012 @ 15:08
    Tommy Albinsson
    0

    Well that sucks :)

    We are using resourcefiles to set text values in Javascript. What I would want to do is when a dictionaryitem is saved, I would like to "touch" every js files that contains the resource strings (to let go of the web cache). But since I cannot hookup to the Saving event I do not know how to do this.

  • Tommy Albinsson 121 posts 254 karma points
    Apr 17, 2012 @ 09:49
    Tommy Albinsson
    0

    Tom: We wan't to use dictionaryitems to translate parts of our webgui, example text strings in javascript. Together with a localization framework it works very good. Tough the web cached the files so when we update a item it does not change the text on the web. This is the reason why we wan't to touch our *.js files when a dictionaryitem is saved.

     

    Any idea on how we can do this when a dictionaryitem is saved? Is there any other way of performing this?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 23, 2012 @ 22:49
    Tom Fulton
    0

    Hi Tommy,

    Sorry for the delay - did you get any closer to a solution?

    I took a quick look but can't think of a good way to hook into the event, other than using the patch shown above.  Only other thought I have is to inject a control onto the page and use it's save/postback event as a trigger that the page was saved.  I did something similar in Structure Extensions (source + 2).

    Maybe we can try to get a pull request in for v4.8...

    -Tom

Please Sign in or register to post replies

Write your reply to:

Draft