×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    21

    widget.setPreferenceForKey doesn't work

    Hello,
    I get stuck in widget.setPreferenceForKey!

    I would like to store a key using widget.setPreferenceForKey("123","rec");

    When I put this in an example downloaded from the web, it works well.
    However, when I put this statement in my file, it doesn't work, anything I need to preset?

    I just do a simple test in the web sample
    alert("before");
    widget.setPreferenceForKey("123","rec");
    alert("after");

    "before" and "after" can be shown. However, when I do the same in my javascript, I can only see "before" but NO "after"

    Pls help
    Alex

  2. #2
    Registered User
    Join Date
    Sep 2008
    Posts
    3

    Re: widget.setPreferenceForKey doesn't work

    Hi alex,

    me too, i wasnt able to use the widget.setpreferenceforkey to work. its always giving me a value of undefined after setting. Is there something we must specify before using this command. Something like
    <embed type="application/x-systeminfo-widget" hidden="yes"></embed> to access the sysinfo of the phone. I tried it on n95 which has the developer platform of S60 3rd Edition, Feature Pack 1. The documentation for widget is on Feature Pack 2 though. Would anyone be able to help us clarify this issue on the preferenceKey?

  3. #3
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Singapore
    Posts
    101

    Re: widget.setPreferenceForKey doesn't work

    Hihi,

    I tried your code, works fine for me, could be some other syntax error somewhere along the way?

    Incidentally, people quite often use the setPreferenceForKey specifying:
    setPreferenceForKey(key,value);
    instead of
    setPreferenceForKey(value,key);

    You might want to check that.

    Cheers,
    Valerie / Forum Nokia

  4. #4
    Registered User
    Join Date
    Mar 2008
    Posts
    21

    Re: widget.setPreferenceForKey doesn't work

    Hello,
    It is strange. The situation is like this.
    I have 1 page and there is a button there. When I press the button, I call the js and want to run

    alert("hi");
    window.widget.setPreferenceForKey("Goodbye, World!","worldString");
    alert("after new");

    it shows "hi" -> "after new" and so it meanssetPreferenceForKey works well.


    Now I have 2 pages., say A and B
    from A I click a button which then go to page B. and in Page B, I do the same thing and call the js

    the result is
    "hi" and then stop. It means setPreferenceForKey cannot be executed.

    So any ideas why this happen??
    Alex




    Quote Originally Posted by taiwerns View Post
    Hihi,

    I tried your code, works fine for me, could be some other syntax error somewhere along the way?

    Incidentally, people quite often use the setPreferenceForKey specifying:
    setPreferenceForKey(key,value);
    instead of
    setPreferenceForKey(value,key);

    You might want to check that.

    Cheers,
    Valerie / Forum Nokia

  5. #5
    Registered User
    Join Date
    Mar 2008
    Posts
    21

    Re: widget.setPreferenceForKey doesn't work

    More information:
    main.html

    <a href="pageB.html">jump</a>

    pageB.html
    <SCRIPT LANGUAGE=JavaScript>
    function writenow() {

    alert("hi");
    window.widget.setPreferenceForKey("Goodbye, World!","worldString");
    alert("after new");

    }
    </SCRIPT>
    <body>

    <img src="graphics/test.png" width="240" height="249">
    <input name="submit" type="submit" class="submit" value="submit2" onClick="javascript:writenow();"/>

    </body>

    main.html is the first page then go to pageB.html and do the writenow()

    and widget.setPreferenceForKey doesn't work
    it only works when the start page is pageB.html

    any idea?

  6. #6
    Nokia Developer Expert
    Join Date
    Feb 2008
    Posts
    29

    Re: widget.setPreferenceForKey doesn't work

    Pls do put your code in one html page and try, I dont think widget officially supports multiple pages.

    Quote Originally Posted by alex@gorex.com.hk View Post
    More information:
    main.html

    <a href="pageB.html">jump</a>

    pageB.html
    <SCRIPT LANGUAGE=JavaScript>
    function writenow() {

    alert("hi");
    window.widget.setPreferenceForKey("Goodbye, World!","worldString");
    alert("after new");

    }
    </SCRIPT>
    <body>

    <img src="graphics/test.png" width="240" height="249">
    <input name="submit" type="submit" class="submit" value="submit2" onClick="javascript:writenow();"/>

    </body>

    main.html is the first page then go to pageB.html and do the writenow()

    and widget.setPreferenceForKey doesn't work
    it only works when the start page is pageB.html

    any idea?

  7. #7
    Registered User
    Join Date
    Mar 2008
    Posts
    21

    Re: widget.setPreferenceForKey doesn't work

    Hi thanks for your reply.
    However, I would like to have several pages in which each page has its own content.
    So what you mean if we cannot have multiple pages in widget?

    Quote Originally Posted by widsets View Post
    Pls do put your code in one html page and try, I dont think widget officially supports multiple pages.

  8. #8
    Registered User
    Join Date
    Nov 2004
    Location
    china
    Posts
    21

    Re: widget.setPreferenceForKey doesn't work

    Quote Originally Posted by alex@gorex.com.hk View Post
    More information:
    main.html

    <a href="pageB.html">jump</a>

    pageB.html
    <SCRIPT LANGUAGE=JavaScript>
    function writenow() {

    alert("hi");
    window.widget.setPreferenceForKey("Goodbye, World!","worldString");
    alert("after new");

    }
    </SCRIPT>
    <body>

    <img src="graphics/test.png" width="240" height="249">
    <input name="submit" type="submit" class="submit" value="submit2" onClick="javascript:writenow();"/>

    </body>

    main.html is the first page then go to pageB.html and do the writenow()

    and widget.setPreferenceForKey doesn't work
    it only works when the start page is pageB.html

    any idea?
    do the follow:

    window.widget.setPreferenceForKey("worldString","Goodbye, World!");


    Everything will be ok. Good luck.

  9. #9
    Registered User
    Join Date
    Mar 2008
    Posts
    21

    Re: widget.setPreferenceForKey doesn't work

    Hi,
    Did you run my code and test?
    Let me have a trial run and I will get back to you
    thanks

    Quote Originally Posted by mawei1981 View Post
    do the follow:

    window.widget.setPreferenceForKey("worldString","Goodbye, World!");


    Everything will be ok. Good luck.

  10. #10
    Registered User
    Join Date
    Mar 2008
    Posts
    21

    Re: widget.setPreferenceForKey doesn't work

    HI,
    Just do a test.
    If I don't jump to another page, it works.

    However, when I jump to next page, it didn't work.

    Thanks

    Quote Originally Posted by mawei1981 View Post
    do the follow:

    window.widget.setPreferenceForKey("worldString","Goodbye, World!");


    Everything will be ok. Good luck.

  11. #11
    Registered User
    Join Date
    Nov 2004
    Location
    china
    Posts
    21

    Re: widget.setPreferenceForKey doesn't work

    the trouble on "could not jump page"

    it doesn't as the topic of this thread"widget.setPreferenceForKey"

    well, I thought you need to learn the API of nokia WRT.

    you could not use "<a href" these achor to link.
    because as a widget it need a stable page,and the page should be main window as the client software as you know.

    so, I thought you can use javascript to write some content by <div> and innerHTML .

    Good Luck On your widget way.

  12. #12
    Registered User
    Join Date
    Mar 2008
    Posts
    21

    Re: widget.setPreferenceForKey doesn't work

    Hi,
    I use
    document.location.href ="main.html";

    anyway, it is the same.
    So it means setPreference can only stick in the first page. And if we want to "jump", use layer

    Quote Originally Posted by mawei1981 View Post
    the trouble on "could not jump page"

    it doesn't as the topic of this thread"widget.setPreferenceForKey"

    well, I thought you need to learn the API of nokia WRT.

    you could not use "<a href" these achor to link.
    because as a widget it need a stable page,and the page should be main window as the client software as you know.

    so, I thought you can use javascript to write some content by <div> and innerHTML .

    Good Luck On your widget way.

  13. #13
    Registered User
    Join Date
    Nov 2004
    Location
    china
    Posts
    21

    Re: widget.setPreferenceForKey doesn't work

    you can use multi div, and then change the display to take the effect as you want.

    one of the best practice with widget developement is one page.

  14. #14
    Registered User
    Join Date
    Mar 2008
    Posts
    21

    Re: widget.setPreferenceForKey doesn't work

    Hi,
    Alright. So always use 1 main page and use multi div (different layers).

    Thanks a lots.

    Quote Originally Posted by mawei1981 View Post
    you can use multi div, and then change the display to take the effect as you want.

    one of the best practice with widget developement is one page.

Similar Threads

  1. Replies: 2
    Last Post: 2004-04-27, 10:36
  2. CommConnection does not work with Series 60 SDK, but works in JWT
    By jackiechan2001 in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2004-02-04, 09:07
  3. Does SDK v2.0 work on Series60 V6.1?
    By liying in forum Symbian Tools & SDKs
    Replies: 3
    Last Post: 2004-02-02, 08:57
  4. does irda function work with the emulator ?
    By IGhost in forum Symbian
    Replies: 0
    Last Post: 2002-12-07, 17:43

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •