Package net.rim.device.api.script

Examples of net.rim.device.api.script.ScriptableFunction


    }
   
    public void useNDEFMessage(int typeNameFormat, String record_type, String json_ndef_message) {
        log("Delivering to JavaScript",typeNameFormat,record_type,json_ndef_message);
        // send JSON object to JavaScript function provided as the call back function parameter to the register_ndef function
        ScriptableFunction ndef_callback = _registry.getNdefFunction(typeNameFormat,record_type);
        if (ndef_callback != null) {
            try {
                Object[] args = new Object[] { json_ndef_message };
                ndef_callback.invoke(null, args);
            } catch (Exception e) {
                log("Could not dispatch message",typeNameFormat,record_type,json_ndef_message,e);
            }
        } else {
            log("No listener registered for message", typeNameFormat,
View Full Code Here


        reportError(NDEFRecord.TNF_WELL_KNOWN, record_type, error_message);
    }
   
    public void reportError(int typeNameFormat, String record_type, String error_message) {
        log("Reporting error",typeNameFormat,record_type,error_message);
        ScriptableFunction on_error_function = _registry.getErrorFunction(record_type);
        if (on_error_function != null) {
            try {
                Object [] args = new Object[] { error_message };
                on_error_function.invoke(null, args);
            } catch(Exception e) {
                log("Could not dispatch error message",typeNameFormat, record_type, error_message,e);
            }
        } else {
            log("No error handler registered",typeNameFormat,record_type,error_message);
View Full Code Here

     */
    public Object invoke(Object obj, Object[] args) {
        boolean result = false;
        int typeNameFormat = NDEFRecord.TNF_WELL_KNOWN;
        String record_type = Constants.NDEF_SMART_POSTER_URI_TYPE;
        ScriptableFunction ndef_message_function = null;
        ScriptableFunction on_error_function = null;
        if (args.length < 2) {
            log("insufficient arguments received");
            return Boolean.FALSE;
        }
        if (args[0] instanceof ScriptableFunction) {
View Full Code Here

         
           //Check eventService exists in our service-callback vector
           if(_listenerHash.containsKey(eventService)){
             Vector vCBack = (Vector)_listenerHash.get(eventService);
              for(int i=0; i < vCBack.size(); i++){
                    ScriptableFunction sf = (ScriptableFunction)vCBack.elementAt(i);
                    if(sf == callback){
                      vCBack.removeElementAt(i);
                      break; // removing the first callback only
                    }
              }
View Full Code Here

              //problem
         }else{
               _vec = (Vector)_listenerHash.get(eService);
               for(int i=0; i < _vec.size(); i++){
                 final ScriptableFunction sf = (ScriptableFunction)_vec.elementAt(i);
                   _appObject.invokeLater(new Runnable() {
                       public void run() {
                             try {
                                
                                 sf.invoke(null, new Object[] { eService, msg });

                             } catch (Exception e) {
                                   System.out.println("Error invoking callback: " + e.getMessage());
                                   throw new RuntimeException("Error invoking callback: " + e.getMessage());
                             }
View Full Code Here

 
  public Object invoke(Object obj, Object[] args) throws Exception
  {
    if (args.length == 1) {
      // Now get the callback method to fire
      final ScriptableFunction _callback = (ScriptableFunction)args[0];

      UiApplication.getUiApplication().invokeLater(new Runnable()
      {
        public void run()
        {
          UiApplication.getUiApplication().pushScreen(new MapFieldSelectionScreen(_callback, null));
       
        }
      });
    }else if (args.length == 2){
      final ScriptableFunction _callback = (ScriptableFunction)args[0];
     
      //if they pass the optional parameter. The default location
      final Scriptable ops = (Scriptable) args[1];
     
      UiApplication.getUiApplication().invokeLater(new Runnable()
View Full Code Here

    public static final String NAME = "open";
  
    public Object invoke(Object thiz, Object[] args) throws Exception {
    if (args.length == 1) { 
      // Now get the callback method to fire
      final ScriptableFunction _callback = (ScriptableFunction)args[0];
     
      final UiApplication uiApp = UiApplication.getUiApplication()
      UiApplication.getUiApplication().invokeLater(new Runnable()
      {
        public void run()
View Full Code Here

            item.putField(MessageListItem.FIELD_DESCRIPTION, new String(getSubject()));
           
            Object[] result = new Object[] {item};
         
            // Pass the event back to the JavaScript callback
            ScriptableFunction onItemOpened = messageListNamespace.getOnItemOpened();
            onItemOpened.invoke(onItemOpened, result);
          }
          catch (Exception e) {
            throw new RuntimeException(e.getMessage());
          }
        }
View Full Code Here

            {
              //the event guid we are listening for will be the first param
                final String myKey = args[0].toString();
               
                //the second param will be the callback
                final ScriptableFunction callback = (ScriptableFunction)args[1];
               
                Application.getApplication().addGlobalEventListener(new MyGlobalEventListener(myKey, callback));
            }
            return UNDEFINED;
        }
View Full Code Here

           
            //Check emailService exists in our service-callback vector
            if(_listenerHash.containsKey(emailService)){
              Vector vCBack = (Vector)_listenerHash.get(emailService);
               for(int i=0; i < vCBack.size(); i++){
                     ScriptableFunction sf = (ScriptableFunction)vCBack.elementAt(i);
                     if(sf == callback){
                       vCBack.removeElementAt(i);
                       break; // removing the first callback only
                     }
               }
View Full Code Here

TOP

Related Classes of net.rim.device.api.script.ScriptableFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.