• Waimana31
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

Hi there,

 

I'm relatively new to Apex coding and have been looking for ways to do dynamic class instantiation.

 

In java I can write something like

 

String classToInstantiate = dao.getClassName();

AnInterface obj = (AnInterface) Class.forName(classToInstantiate).newInstance();

 

Is anyone aware of how I can do this or something similar in Apex? 

 

thanks in advance for any help you might be able to provide

Mark

 


 

Hello all,

 

I have recently installed the Force plugin to my Eclipse instance and have been playing with the tutorial code.

 

The IDE is giving me an "unexpected token" error for TODAY in the following code. This error also repeats for any other Apex class which contains TODAY

 

public class MileageUtil {
   
    static final Integer MAX_MILES_PER_DAY = 500;
   
    public static void areMilesAllowed(Mileage__c[] miles) {
        Double totalMiles = 0;
        String createdbyId = UserInfo.getUserId();
        /* Adds the miles created in previous requests for today */
        for(Mileage__c mq:[select miles__c from Mileage__c
        WHERE Date__c = TODAY AND Mileage__c.createdById = :createdbyId
        AND miles__c != null]) {
            totalMiles += mq.miles__c;
        }
        /* Totals the miles in the request */
        for (Mileage__c m:miles) {
            totalMiles += m.miles__c;
            if(totalMiles > MAX_MILES_PER_DAY)
                m.addError('Mileage request exceeds daily limit: ' + MAX_MILES_PER_DAY);
        }
    }
}

 

 

Eclipse details: 

Eclipse Platform Version: 3.4.1 Build id: M20080911-1700

 

OS Windows XP Professional, service pack 3

 

The code is fine if entered via the Web UI.

 

Any ideas?

 

thanks in advance for your response

Mark

 

Hello all,

 

I have recently installed the Force plugin to my Eclipse instance and have been playing with the tutorial code.

 

The IDE is giving me an "unexpected token" error for TODAY in the following code. This error also repeats for any other Apex class which contains TODAY

 

public class MileageUtil {
   
    static final Integer MAX_MILES_PER_DAY = 500;
   
    public static void areMilesAllowed(Mileage__c[] miles) {
        Double totalMiles = 0;
        String createdbyId = UserInfo.getUserId();
        /* Adds the miles created in previous requests for today */
        for(Mileage__c mq:[select miles__c from Mileage__c
        WHERE Date__c = TODAY AND Mileage__c.createdById = :createdbyId
        AND miles__c != null]) {
            totalMiles += mq.miles__c;
        }
        /* Totals the miles in the request */
        for (Mileage__c m:miles) {
            totalMiles += m.miles__c;
            if(totalMiles > MAX_MILES_PER_DAY)
                m.addError('Mileage request exceeds daily limit: ' + MAX_MILES_PER_DAY);
        }
    }
}

 

 

Eclipse details: 

Eclipse Platform Version: 3.4.1 Build id: M20080911-1700

 

OS Windows XP Professional, service pack 3

 

The code is fine if entered via the Web UI.

 

Any ideas?

 

thanks in advance for your response

Mark

 

I'm not sure if this is the right place to post this, so apologies if I am in the wrong area...
I have an idea for an application, and the sf platform makes total sense as a market/environment.  However, this application involves some extremely intensive business logic such as Monte Carlo simulation and optimization algorithms.  Is this a realistic and appropriate application to build using Apex?  I don't want to have to host an environment that supports the logic, and I like the idea of not having to maintain the application from version to version.  I don't want to get 90% done and find out that there is some reason that I can't host this on Force.com...
Thanks in advance