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

Java Development

Reply
New Contributor
Posts: 3
Registered: ‎07-21-2010
My Device: Not Specified

Emailing Troubles

I'm trying to use information inputted from one program and use it as the body of my email. I used the persistent store demo and modified it so that it is called StudentRecord, StudentRecordScreen, etc. I am now trying to integrate the Blackberry email demo and have hit a snag on the ComposeScreen.

 

 

/**
     * Gets a message for sending or saving
     * @return A new message
     */
    Message getMessage()
    {
        // Find an outbox folder and use it to construct a new message      
        Folder outbox = _store.findFolder("Outbox")[ FIRST ];
        Message message = new Message(outbox);

        // Add all the current headers
        for( int keyNo = 0; keyNo < HEADER_KEYS.length; keyNo++ )
        {
            Vector fieldsByType = (Vector) _fieldTable.get(HEADER_KEYS[ keyNo ]);

            if( fieldsByType != null )
            {
                // Build a vector of all the addresses
                Vector addressVector = new Vector();
                int size = fieldsByType.size();
                for( int fieldNo = 0; fieldNo < size; fieldNo++ )
                {
                    TextField addressField = (TextField) fieldsByType.elementAt(fieldNo);

                    // Try to create a new address object wrapping the email
                    // address and add it to the address vector.
                    try
                    {
                        addressVector.addElement(new Address(addressField.getText(), ""));
                    }
                    catch( AddressException e ) // Invalid address
                    {
                        Dialog.alert("Address(String, String) threw " + e.toString());
                    }
                }

                // Dump the vector of addresses into an array to send the message
                Address[] addresses = new Address[ addressVector.size() ];
                addressVector.copyInto(addresses);

                // Try to add the addresses to the message's list of recipients
                try
                {
                    message.addRecipients(HEADER_KEYS[ keyNo ], addresses);
                }
                catch( MessagingException e )
                {                    
                    Dialog.alert("Message#addRecipients(int, Address[]) threw " + e.toString());
                }
            }
        }

        // Add the subject
        Vector subjectFields = (Vector) _fieldTable.get(SUBJECT);
        TextField subjectField = (TextField) subjectFields.elementAt(FIRST);

        if( subjectFields != null && subjectFields.size() > 0 )
        {
            message.setSubject(subjectField.getText());
        }

        // Add the body by adding all the body fields into one multipart
        Vector bodyFields = (Vector) _fieldTable.get(BODY);
        //StudentRecord _uiApp = new StudentRecord();
        if( bodyFields != null )
        {
            int size = bodyFields.size();
            Multipart content = new Multipart();
            for( int fieldNo = 0; fieldNo < size; fieldNo++ )
            {
                TextField body = (TextField) bodyFields.elementAt(fieldNo);
                content.addBodyPart(new TextBodyPart(content, body.getText()));
            }
            
            try
            {
                
                Database database = new Database();
                DatabaseScreen databaseScreen = new DatabaseScreen(database,-1,true);
                _uiApp.pushScreen(databaseScreen);
                
                
                message.setContent(databaseScreen.getContent());
            }
            catch( MessagingException e )
            {                
                Dialog.alert("Message#setContent(Object) threw " + e.toString());
            }
        }
        else
        {
            Dialog.alert("Error: no body field available");
            return null;
        }

        // Set the date
        message.setSentDate(Calendar.getInstance().getTime());

        return message;
    }

 

 

The error is at : 

_uiApp.pushScreen(databaseScreen);

 

Error:
ComposeScreen.java:245: cannot find symbol symbol : method getStudentRecord() location: class StudentRecord.ComposeScreen StudentRecord _ui = getStudentRecord();

 

I changed StudentRecord (was PersistentDemo) _uiApp from StudentRecordScreen (was PersistentDemoScreen) into public so why cant I use it here?

 

 

I've been trying to solve this for two days! Please help!

 

Thanks in advance.