Difference between revisions of "Classes"
imported>Aeric |
imported>Aeric |
||
Line 5: | Line 5: | ||
''Learn more:'' [[Developer_Suite#Classes|Classes in the Developer Suite]] | ''Learn more:'' [[Developer_Suite#Classes|Classes in the Developer Suite]] | ||
==About | ==About Classes== | ||
You can make [[Java API]] calls in the Java code in a class, and you can create instances of classes in Java code. | You can make [[Java API]] calls in the Java code in a class, and you can create instances of classes in Java code. | ||
There are some restrictions on the things you can do in a Java class, as described in [[Governors#Governors on Java Code|Governors on Java Code]] . | There are some restrictions on the things you can do in a Java class, as described in [[Governors#Governors on Java Code|Governors on Java Code]] . | ||
{{ # | In most cases, a [[Pages|page]] communicates with a class through a controller class. (You can instantiate a class directly in a page, but that is considered a bad practice.) | ||
| | :''Learn more:'' [[Working with Pages and Classes]] | ||
{{ #if: {{ShowIsvInfo}} | | |||
[[ISV]]s licensing the platform may write class libraries that use frameworks like Spring. | ==Access to Frameworks== | ||
[[ISV]]s licensing the platform may write class libraries that use frameworks like Spring, once they are initialized. | |||
:''Learn more: [[Service_Provider_Settings#Custom_Context_Listener|Context Listener]]''}} | :''Learn more: [[Service_Provider_Settings#Custom_Context_Listener|Context Listener]]'' | ||
}} | |||
==Manage Classes== | ==Manage Classes== | ||
From the Classes page, a number of features are provided to view, create and manage classes. | From the Classes page, a number of features are provided to view, create and manage classes. |
Revision as of 19:53, 28 July 2011
Designer > Logic > Classes
A class is a standard Java class. Consider writing classes to create business logic that is not provided by the basic building blocks of the platform.
Learn more: Classes in the Developer Suite
About Classes
You can make Java API calls in the Java code in a class, and you can create instances of classes in Java code.
There are some restrictions on the things you can do in a Java class, as described in Governors on Java Code .
In most cases, a page communicates with a class through a controller class. (You can instantiate a class directly in a page, but that is considered a bad practice.)
- Learn more: Working with Pages and Classes
Access to Frameworks
ISVs licensing the platform may write class libraries that use frameworks like Spring, once they are initialized.
- Learn more: Context Listener
Manage Classes
From the Classes page, a number of features are provided to view, create and manage classes.
To view Classes:
- Click Designer > Logic > Classes
- Optionally, choose a View; In addition to the All Records view, the following views are available:
- Use the action buttons:
- [New Class] - Add a Class
- [Run All Tests] - Run all Unit Tests defined in the classes
Add a Class
Prerequisite Before you create a class, you need to decide what package to put it in. Here are a few notes to help you make that decision:
- Packages let you organize classes into different directories according to their functionality, their usability, or any other category that makes sense. (The only rule is that classes in one package have a qualitatively different kind of functionality compared with those in another package.)
- Packages help to avoid class name collision. (The same class name can be used in different packages.)
- Classes in the same package can access each others package-protected fields and methods, as well as their public members, without doing an import. So classes that cooperate with each other extensively generally belong in the same package.
- Classes that are part of a different package can be accessed with an import declaration.
To add a class:
- Click Designer > Classes
- Click [New Class]
- Fill in the class properties.
- Click [Next]
A class template appears. - Provide the code for the class.
- Click [Save]
Class properties
- Package
- The package name
- The platform supplies this part: com.platform.{namespace},
where {namespace} is defined in the Developer Configuration settings of the current tenancy. - You supply this part: {packagename}
- The result is the fully-qualified package path for the class: com.platform.{namespace}.{packagename}
- The platform supplies this part: com.platform.{namespace},
- Class Name
- The name of the class. Must consist of alphanumeric characters (a-z,A-Z,0-9) or underscores (_). Must start with an alphabetic character (a-z,A-Z) or underscore (_).
- Global Class
- Checkbox
- If checked, this class is a Global Class
- If unchecked, this class is available to users in the current tenancy, only
- Java code
- Enter Java code in the text area.
Edit a Class
To edit a class:
- Click Designer > Logic > Classes
- Click the name of the class to edit
- Click [Edit]
- Edit the Java code in the text area
- When done, click [Save]
Delete a Class
To delete a class:
- Click Designer > Logic > Classes
- Click the name of the class to delete
- Click [Delete]
Editing Classes in Eclipse
Use the Eclipse Plug-In to add, edit or delete classes.