Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Developer
UserNeo
Posts: 74
Registered: ‎10-23-2008
My Device: 9000
Accepted Solution

Two questions to blackberry.pim

Hi,

 

i have two short question to blackberry.pim functions. I export all my memos from device to xml file. Thats works fine. But i have a problem with memo import, all linebreaks are lost :smileysad: .

 

function importMEMO(pathImport) {

    // Open Memo Export File (xml)
    if (blackberry.io.file.exists(pathImport + 'memo.export')) {
        blackberry.io.file.readFile(pathImport + 'memo.export', handleOpenedMemoFile);
    }
    else {
        return false;
    }
}

// Open File Handler
function handleOpenedMemoFile(fullPath, blobData) {
    
    var xmlString = blackberry.utils.blobToString(blobData, 'UTF-8');
    var parser = new DOMParser();
    var xmlobject = parser.parseFromString(xmlString, 'text/xml');
    
    var root = xmlobject.getElementsByTagName('memo')[0];
    var items = root.getElementsByTagName('item');
    
    // Import Memos
    for (var i = 0; i < items.length; i++) {
    
        var memo = new blackberry.pim.Memo();

        // category check
        if (items[i].getAttribute('categories') != '') {

            var tmp = items[i].getAttribute('categories');
            var categories = tmp.split(',');

            memo.categories = categories;
        }        
        
        // Put Data & save
        memo.title = items[i].getAttribute('title');
        memo.note = items[i].getAttribute('note');
        memo.save();
    }
}

 

 

My second question is, why doen't work getCategories() ? The widget stops the script when comes this code:

 

 

function addCATEGORY() {
    blackberry.pim.addCategory("testC");
}

 

The config.xml File

 

<?xml version="1.0" encoding="utf-8"?>
<widget xmlns:rim="http://www.blackberry.com/ns/widgets" version="1.0.0" rim:header="RIM-Widget:rim/widget" xmlns="http://www.w3.org/ns/widgets">
  <name>MyWidget</name>
  <description>later</description>
  <author href="" rim:copyright="" email="">Me</author>
  <icon src="app_icon.png" />
  <content src="index.htm" />
  <feature id="blackberry.find" required="true" version="1.0.0.0" />
  <feature id="blackberry.invoke" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Contact" required="true" version="1.0.0.0" />
  <feature id="blackberry.identity" required="true" version="1.0.0.0" />
  <feature id="blackberry.app" required="true" version="1.0.0.0" />
  <feature id="blackberry.app.event" required="true" version="1.0.0.0" />
  <feature id="blackberry.io.dir" required="true" version="1.0.0.0" />
  <feature id="blackberry.io.file" required="true" version="1.0.0.0" />
  <feature id="blackberry.message" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Address" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Appointment" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Attendee" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.category" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Memo" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Recurrence" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Reminder" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Task" required="true" version="1.0.0.0" />
  <feature id="blackberry.system" required="true" version="1.0.0.0" />
  <feature id="blackberry.system.event" required="true" version="1.0.0.0" />
  <feature id="blackberry.ui.dialog" required="true" version="1.0.0.0" />
  <feature id="blackberry.ui.menu" required="true" version="1.0.0.0" />
  <feature id="blackberry.utils" required="true" version="1.0.0.0" />
  <rim:loadingScreen backgroundColor="#F1EBDD" onRemotePageLoad="true" onLocalPageLoad="true" onFirstLaunch="true" />
  <license href="" />
</widget>

 

 

How can linebreaks into memo content and why doesn't work addCategory() or getCategories() ?

 

cu

UserNeo

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Two questions to blackberry.pim

Hi UserNeo,

 

Can you confirm that after your export of the Memo to XML that the line breaks are there?  I just want to make sure that we are addressing the correct problem.. the export or the import.

 

As far as the categories go.. can you try the following code:

 

 

function addCATEGORY() {
    blackberry.pim.category.addCategory("testC");
}

 

I'm wondering if there is a typo in the category example.

 

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
New Developer
UserNeo
Posts: 74
Registered: ‎10-23-2008
My Device: 9000

Re: Two questions to blackberry.pim

Hi,

 

@category

Thx its works :smileyhappy: but in a wigdet api example is a little error :

http://www.blackberry.com/developers/docs/widgetapi/blackberry.pim.category.html

 

@memo import

 

Memo Example before export to XML:

2841iEBF112A9AF1599F2

 

Memo XML File

 

<?xml version="1.0"?>
<memo date="Wed Aug 11 2010" count="1">
	<item uid="-267974" title="BlackBerry Secret Codes" note="Enterprise Activation:
ALT+CNFG – Settings WEA

Address Book:
ALT+VALD – Validate the data structure
ALT+RBLD – data structure rebuild

Browser:
ALT+RBVS – View web page source code

Calendar:
ALT+VIEW Inside any Calendar item Show extra info for a Calendar event" categories="" />
</memo>

 

 Memo after import

2842i63C65DA1DDABFA2E

 

The widget import javascript code, please see first message.

 

cu

UserNeo

 

 

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Two questions to blackberry.pim

I've notified the development team and they will be changing the example in the categories section of the API documentation.  Thank you for pointing that one out :smileyhappy:

 

For the line breaks.... I'm wondering if it is because you are putting the note information with the line breaks in an XML attribute instead of contents in an XML element.

 

The DOMParser may be parsing the XML and removing the line breaks from the attribute.  Try structuring your XML like the following and see if loading it from file now receives the line breaks

 

 

<?xml version="1.0"?>
<memo date="Wed Aug 11 2010" count="1">
	<item uid="-267974" title="BlackBerry Secret Codes" categories="">
Enterprise Activation:
ALT+CNFG – Settings WEA

Address Book:
ALT+VALD – Validate the data structure
ALT+RBLD – data structure rebuild

Browser:
ALT+RBVS – View web page source code

Calendar:
ALT+VIEW Inside any Calendar item Show extra info for a Calendar event
</item>
</memo>

 

 

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
New Developer
UserNeo
Posts: 74
Registered: ‎10-23-2008
My Device: 9000

Re: Two questions to blackberry.pim

thanks, its now works perfect :smileyvery-happy: .
Please use plain text.