0

Accessing the "params" Object in the next view

How do we access the "params" Object passed by the loadView() method, in the next view?

Ref: Pg. 145 of the YWE_Developer_Guide.pdf
void loadView(string viewId, object params, Boolean noSaveCurrentViewInHistory);

TIA

by
12 Replies
  • QUOTE (prasannaw.2006 @ Apr 19 2010, 08:11 AM) <{POST_SNAPBACK}>
    How do we access the "params" Object passed by the loadView() method, in the next view?

    Ref: Pg. 145 of the YWE_Developer_Guide.pdf
    void loadView(string viewId, object params, Boolean noSaveCurrentViewInHistory);

    TIA


    It is stored in the view's persist property: "this.persist - persistant storage for anything you want to persist when this view gets reloaded after possible garbage collection."

    Kelly
    0
  • QUOTE (TVWidgetDocs @ Apr 19 2010, 08:25 AM) <{POST_SNAPBACK}>
    It is stored in the view's persist property: "this.persist - persistant storage for anything you want to persist when this view gets reloaded after possible garbage collection."

    Kelly


    Thanks for responding Kelly.

    However, I want to access the "params" object in the "next" view file i.e. a different view file; not a reloaded view file.

    e.g. There are two view files: X.js and Y.js. Depending on the selected value in the X.js view, content should be displayed in the Y.js view. So, I want to pass the selected value as a "params" object to Y.js view so that the content can be displayed accordingly. How do I access the "params" object in Y.js view file?
    0
  • QUOTE (prasannaw.2006 @ Apr 19 2010, 10:53 AM) <{POST_SNAPBACK}>
    Thanks for responding Kelly.

    However, I want to access the "params" object in the "next" view file i.e. a different view file; not a reloaded view file.

    e.g. There are two view files: X.js and Y.js. Depending on the selected value in the X.js view, content should be displayed in the Y.js view. So, I want to pass the selected value as a "params" object to Y.js view so that the content can be displayed accordingly. How do I access the "params" object in Y.js view file?

    Hi,

    First, you'd persist your values by passing them in an object literal:
    CODE
    KONtx.application.loadView("view-MyTestView", {
    id: o.id,
    title: o.title,
    datetime: o.datetime,
    src: o.src
    });

    Then, in the view that's loaded, you can access the properties you passed in the object literal like this:
    CODE
    this.persist.id;
    this.persist.title;
    this.persist.datetime;
    this.persist.src;

    - Ben
    0
  • Thanks Ben!

    It worked perfectly fine. Appreciate your help.
    0
  • QUOTE (prasannaw.2006 @ Apr 20 2010, 01:38 AM) <{POST_SNAPBACK}>
    Thanks Ben!

    It worked perfectly fine. Appreciate your help.


    Hey!!!!
    I have to say that it also worked for me... but just the first time... I mean, I have a grid of cells, and depending on the cell selected, I want to show a view with a different title. The first time I choose a cell, it works great, however, if I come back to the previous view (the one of the grid), and I select other cell, the parameter keeps storing the previous value.

    I dont know if I am explaining myself well... Lets assume a list of contacts, John, Jason and Mike, who are displayed in a grid. If I hit the Enter key in Jason the first time, I load a view with the name of Jason, which actually is great. But if I come back to the list of contacts, and I move myself down in the grid, and I choose Mike, I load again the view with the name of Jason. I dont know how to refresh the content of the params, and where to do it!!!!!

    Thank you very much!!!!!
    0
  • I too faced a similar situation, but figured out a way to get past it.

    We need to define the screen layout in the createView function. The keyword here is "define". Do not set labels, images etc. in that function. For setting data, use the updateView function.

    QUOTE
    I dont know how to refresh the content of the params, and where to do it!!!!!


    The content of the params do get refreshed automatically. Setting data in the updateView function ensures that the screen gets populated with the refreshed data.

    HTH
    0
  • QUOTE (prasannaw.2006 @ Apr 22 2010, 01:50 AM) <{POST_SNAPBACK}>
    I too faced a similar situation, but figured out a way to get past it.

    We need to define the screen layout in the createView function. The keyword here is "define". Do not set labels, images etc. in that function. For setting data, use the updateView function.



    The content of the params do get refreshed automatically. Setting data in the updateView function ensures that the screen gets populated with the refreshed data.

    HTH


    But actually I'm not setting anything, as u can see...

    CODEBOX
    onSelect: function (event){
    KONtx.application.loadView("view-DetalleRestaurantesView",{
    name_rest : nombres[this.getCellDataIndex()]});
    }


    where nombres is an array I have defined at the beginning of the file...
    0
  • You will need to implement the createView and updateView functions in the "view-DetalleRestaurantesView" file.

    As I mentioned earlier, use createView to define the screen layout, and use updateView to set labels, images, etc.
    0
  • QUOTE (prasannaw.2006 @ Apr 22 2010, 08:07 AM) <{POST_SNAPBACK}>
    You will need to implement the createView and updateView functions in the "view-DetalleRestaurantesView" file.

    As I mentioned earlier, use createView to define the screen layout, and use updateView to set labels, images, etc.


    ok ok, I got it now, I thought u were referring to the previous view... U HAVE SAVED MY LIFE, PRANNASAW, U ARE MI IDOL!!!!! :)
    0
  • I'm having the same problem as Alvaro but it seems i didn't understand on how to resolve it, the problem i'm facing is, how do i change the label in the updateView function?
    If i don't define it when i create the button in the createView it stays blank, if i define it with the this.persist it's dinamically labeled but only the first time the view is invoked, then it's fixed, and i can't seems to find a way to change it in the updateView, i've tried the setText method but it's not working it seems.
    0
  • Here's how I do it in one of my views...

    CODE
        createView: function () {
    // ...
    this.controls.backbutton = new KONtx.control.BackButton({
    guid: TVL4.guid("faqdetailview.controls.backbutton"),
    label: $_("faq-detail-title"),
    }).appendTo(this);
    // ...
    },
    updateView: function () {
    // ...
    this.controls.backbutton.setText(
    this.persist.title || $_("faq-detail-title"));
    // ...
    }
    0
  • QUOTE (prasannaw.2006 @ Apr 22 2010, 08:07 AM) <{POST_SNAPBACK}>
    You will need to implement the createView and updateView functions in the "view-DetalleRestaurantesView" file.

    As I mentioned earlier, use createView to define the screen layout, and use updateView to set labels, images, etc.


    Hi prasana,
    I do face the same issue. I pass the parameter via "onSelect" event with different Id which show the proper data in Terminal Log. But My grid cell is not getting updated with the same. (I have createView and UpdateView defined in the New view which is loaded.)
    0

Recent Posts

in Getting Started / Beginners - Yahoo! TV Widgets