0

KONtx.application.previousView() malfunctions when the previous vew is the same as the current view

I have an application which lets a user browse through nested menus. Each menu is presented using the same view.

A KONtx.application.loadView("view-Menu", { menu: x}); does not work because the current view is also "view-Menu", so I have to use reloadView({menu: x});

The problem comes in when my code calls KONtx.application.previousView(); I get the following error:

CODE
WM 00:20:14:110: [T:13383] ** Keys.handleKey() @key code 13 @target sb @current sb @phase 2
WM 00:20:14:111: [T:13383] ******** Utils.Doggy.poke()
WM 00:20:14:111: [T:13383] ** main._updateScreensaver() @do poke true @doggy 1 alive true @doggy 1 asleep false @doggy 2 alive true @doggy 2 asleep false
WM 00:20:14:111: [T:13383] ******** Utils.Doggy.poke()
WM 00:20:14:111: [T:13383] ******** Utils.Doggy.poke()
WM 00:20:14:112: [T:13383] Refusing to [forward] load the same view! (view-Menu)


I get the same error when the user presses the Previous key (F10 on the simulator).

I am inclined to consider this a bug. I'm not sure how to work around it.

by
10 Replies
  • Based on your limited description of what you are doing, I am inclined to think you are probably going with the wrong approach. There is no reason why multiple view IDs all can't use the same view class. From the sounds of it, these are different menus with a similar look and feel. This would be handled by having a view config like the following:

    id: view-Main, viewClass: MyMenuViewClass,
    id: view-SubMenuX, viewClass: MyMenuViewClass, data: { menu: X },
    id: view-SubMenuY, viewClass: MyMenuViewClass, data: { menu: Y },
    id: view-SubMenuZ, viewClass: MyMenuViewClass, data: { menu: Z },

    I apologize this isn't better explained in the documentation, but rest assured with the WDK now being public, a blog with useful tips / design patterns like this will be available soon.

    -Jeremy
    0
  • QUOTE (Jeremy Johnstone @ Jan 8 2010, 03:19 PM) <{POST_SNAPBACK}>
    Based on your limited description of what you are doing, I am inclined to think you are probably going with the wrong approach. There is no reason why multiple view IDs all can't use the same view class. From the sounds of it, these are different menus with a similar look and feel. This would be handled by having a view config like the following:


    No, that's not it. The code used to present the view is identical. The only difference is which URL the data came from. You don't use a different code base to render http://www.yahoo.com/ and http://finance.yahoo.com/ . You have one HTML rendering library and load into it whatever URL the user selects.

    For an example of the data, compare

    http://www.purplefrog.com/~thoth/bobtv/mit/menu.xml
    http://www.purplefrog.com/~thoth/bobtv/tf2.xml
    http://www.purplefrog.com/~thoth/bobtv/trailers-menu.xml
    http://www.purplefrog.com/~thoth/bobtv/nerd-tv/menu.xml
    http://www.purplefrog.com/~thoth/bobtv/bob-collection.xml

    I can't possibly create a different view for each menu. The entire point is that people will create their own menus. The heirarchy of menus will change as quickly as the internet changes.
    0
  • QUOTE (mutantbob @ Jan 11 2010, 07:54 AM) <{POST_SNAPBACK}>
    You don't use a different code base to render http://www.yahoo.com/ and http://finance.yahoo.com/ . You have one HTML rendering library and load into it whatever URL the user selects.


    Actually, you would be _very_ wrong. About the only similarity between the two is they are served up both by Apache. Outside that, the code, system architecture, platforms, etc are all very different. Anyway, that's beside the point.


    QUOTE
    I can't possibly create a different view for each menu. The entire point is that people will create their own menus. The heirarchy of menus will change as quickly as the internet changes.


    You missed my point entirely. Please go back and re-read it again. I didn't suggest a different codebase, I suggested a different ID for each menu all using the same view code. To steal your analogy a bit, you are basically asking for every menu to use the same URL but with different cookies to toggle. What I am suggesting is to use a different URL which would get mapped onto identical code.
    0
  • QUOTE (Jeremy Johnstone @ Jan 11 2010, 08:18 AM) <{POST_SNAPBACK}>
    it again. I didn't suggest a different codebase, I suggested a different ID for each menu all using the same view code. To steal your analogy a bit, you are basically asking for every menu to use the same URL but with different cookies to toggle. What I am suggesting is to use a different URL which would get mapped onto identical code.


    OK. So how many million entries can I fit into the views field of the KONtx.application.init parameter? How do I add more to that views array since new URLs will be created long after the widget has been installed on the TV? I really don't want to have to deploy a new multi-million-line init.js every day as people add XML documents to the internet.
    0
  • QUOTE (mutantbob @ Jan 11 2010, 12:52 PM) <{POST_SNAPBACK}>
    OK. So how many million entries can I fit into the views field of the KONtx.application.init parameter? How do I add more to that views array since new URLs will be created long after the widget has been installed on the TV? I really don't want to have to deploy a new multi-million-line init.js every day as people add XML documents to the internet.


    Hey Bob,

    I think you are being beyond ridiculous. If you want to discuss issues in a professional manor without extreme hyperbole and angst, I am happy to help you, but otherwise I've got far better things to do with my time.

    I wish you luck!

    -Jeremy
    0
  • QUOTE (mutantbob @ Jan 11 2010, 12:52 PM) <{POST_SNAPBACK}>
    OK. So how many million entries can I fit into the views field of the KONtx.application.init parameter? How do I add more to that views array since new URLs will be created long after the widget has been installed on the TV? I really don't want to have to deploy a new multi-million-line init.js every day as people add XML documents to the internet.

    I realize what your trying to do, but realize that nothing is preventing you from creating your own component to do what you want. It's not that difficult. I'm sure Yahoo is short staffed just like every other company these days, and there are higher priorities than to create a framework that handles all use cases especially when they deviate from the typical use cases. I either deal with various limitations of existing components, or extend/create my own when necessary. Or why not dig into the framework code yourself, and send along a patch? That might be constructive.
    0
  • QUOTE (Jeremy Johnstone @ Jan 11 2010, 06:11 PM) <{POST_SNAPBACK}>
    I think you are being beyond ridiculous. If you want to discuss issues in a professional manor without extreme hyperbole and angst, I am happy to help you, but otherwise I've got far better things to do with my time.


    My previous attempts to express how dynamic my application was failed miserably. You suggested that I add lines to the views array for each menu. This is not possible because I can not enumerate all the menus that people will create on the internet. I apologize for doing a bad job of explaining why I think your suggestion won't work in my case.

    I'm just going to break down and write out a few paragraphs that explain why what you suggested seems not to match my application's functionality and that I failed to convey to you what I am attempting.


    The com.purplefrog.bobtv.ytvw widget which I have uploaded to yahoo fetches XML from the internet and interprets it as a list of offerings and submenus, presented in a 1-column grid. Each XML document has the ability to refer to other XML documents containing menus. Theoretically there is no upper bound to the number of URLs in this interconnected web of menus. If 1% of facebook users were to have one menu, that would be 3.5 million menus. The menus could change from minute to minute, although the vast majority would change less often than once a day (some would be abandoned, like stale facebook pages).

    In the suggestion you made to me: each view would use the same class to present the menu from a single URL. I think this means I would have to have an array entry for each URL that contains XML for a menu. Since my vision is that people would be able to create these XML documents and edit them and include pointers to other XML menus, it seems like I would have to update my init.js every time somebody created a new XML document.

    Firefox does not have a statically compiled-in list of URLs. When you click on a link, the same code fetches the URL and figures out what to do with it, whether it's http://yahoo.com or http://google.com or http://developer.yahoo.net/forum/index.php?showtopic=4090 . My code needs to be able to handle any URL that a user's XML refers to.

    If a large but static init.js is NOT what you suggested, then I just don't understand what you WERE suggesting.
    0
  • QUOTE (mutantbob @ Jan 12 2010, 11:20 AM) <{POST_SNAPBACK}>
    If a large but static init.js is NOT what you suggested, then I just don't understand what you WERE suggesting.


    Absolutely not what I suggested if you have a dynamic list of views like that. The only thing which should be in the init.js is what's "always present". Nothing stops you from adding additional views after the widget has started. In fact not only is this documented, but there are even examples of doing this in the sample widgets (it's dynamically adding snippet views, but same concept applies, a "view" is a "view").

    Here's the basic gist of what you would do to add a new view and then switch to it:

    CODE
    KONtx.application.addViewConfig({ id: 'SubMenu-XX', viewClass: MyMenuViewClass, data: { menu: XX }});
    KONtx.application.loadView('SubMenu-XX');


    While I would advice not adding a new view which you have already added previously, the system will detect a new view being added with the same ID and replace the old config with the new one.

    -Jeremy
    0
  • It sounds like what you want to be done can be done with a single view - but you're not going to be able to do this with loadView and reloadView.

    Instead what would work is just dynamically updating the grid dataset when people select something that takes them from category to sub-category. You can simply change the dataset or even recall the updateView function (or some other method you create).

    This will of course kill the back button. You'll likely have to maintain your own history stack and override the default back button behavior to allow people to go back within the categories.
    0
  • QUOTE (Mike R. @ Jan 12 2010, 01:09 PM) <{POST_SNAPBACK}>
    This will of course kill the back button. You'll likely have to maintain your own history stack and override the default back button behavior to allow people to go back within the categories.


    That is what my old code did, but I decided that overriding the Back button was dangerous business and I'd rather let the framework take care of persistence and the history stack.
    0

Recent Posts

in General - Yahoo! TV Widgets