TWiki
>
WebXEO Web
>
XeoPrimer
>
XeoPrimerJavaAPI
(revision 10) (raw view)
Edit
Attach
Tags:
tag this topic
create new tag
,
view all tags
-- Main.PedroRio - 22 Dec 2010 ---+ XEO Java API The XEO Java API allows direct interaction with a XEO Application (instances of XEO Models and XEO Model definitions). It can be used in the following situations: * Custom Behavior definition (for XEO Model Events, Methods, Attribute Events and Attribute Logic (requirement, validation, etc...). * To create Schedules and Threads that perform background operations on instances of XEO Models. * Custom development around a XEO Application (ex. Java Server Pages, Servlets, Java Server Faces) * Creating XEO Modules * Applications sharing the same J2EE server as the XEO application who want to access information in XEO Model instances. ---++++ Basic Concepts A XEO application is all about creating instances of XEO Models, setting values for their attributes, processing lists of XEO Model instances, handling events generated for those instances and executing methods. Recall from the Object Behavior chapter the basics for the [[XeoPrimerObjectBehavior#apiIntro][Java API]]. A XEO application has an entry point which is an instance of the <em>boApplication </em>class. The <em>boApplication </em>instance provides access to most features of the XEO Java API. When implementing custom behavior for XEO Models, you (probably) won't need the <em>boApplication </em>instance as you'll have access to instances of XEO classes that'll allow you to implement your logic. ---++++ boApplication The <em>boApplication </em>class represents the point of entry in a XEO Application and has methods to reach most of the manager classes to deal with _boObjects_, _boObjectLists_, Lists of Values and XEO Model definition handlers. The list of relevant methods to retrieve the classes mentioned is the following: | *Method Signature* | *Description* | *Return Type* | *Note* | | getDefaultApplication() | Retrieves the default application instance | boApplication | (static) | | getObjectManager() | Retrieves an instance of the boManagerBean to load/create object instances | boManagerBean | | | getSecurityObjectManager() | Retrieves an instance of the boManagerBean to load/create object instances which respects permissions declared | boManagerBean | | | getObjectListManager() | Retrieve an instance of ObjectListManager to create boObject lists | ObjectListManager | | | getLovManager() | Retrieve the Lov Manager to load lov instances | LovManager | | | getModelDefinition(String name) | Retrieve the Model definition handler for a specific model | boDefHandler | | | getInterfaceDefinition(String name) | Retrieve the Interface definition handler for a specific model | boDefInterface | | | createContext(boSession session) | Create an EboContext from a session | EboContext | | When creating custom Java code to define behavior for a given XEO Mode, as seen in the [[XeoPrimerObjectBehavior][Object Behavior chapter]], most of the times you'll be given access to a _boObject_ instance and/or an <em>attributeHandler </em>instance. ---++++ boSession and EboContext Whenever a user successfully logs into a XEO Application, a <em>boSession </em>instance is created to represent the user session within the application and it's in that <em>boSession </em>instance that several information regarding the user is stored. Transactional control can also be done at the context level, so to read more about these classes go to [[XeoPrimerJavaAPISessionEboContext][boSession and EboContext API Page]] ---++++ boManagerLocal & boObject The _boObject_ represents an instance of a particular XEO Model and is the most important class in XEO's Java API as it allows access to an instance's attributes and its definition. To know more about the _boObject_ class, read the [[XeoPrimerJavaAPIboObject][boObject API page]]. The boManagerLocal interface represents the manager of _boObject_ instances, which allows to create and load those instances, read more in the [[XeoPrimerJavaAPIboManagerLocal][boManagerLocal API]] page. ---++++ ObjectListManager & boObjectList The ObjectListManager class allows to create instances of the _boObjectList_ class which represents a lists of _boObject_ (as the name implies). _boObjectList_ instances are created by issuing _BOQL_ queries against the datasource (typically a DBMS) and its results are paginated (default value: 50 results per page). <em>boObjectList </em>instances are much like (paged) iterators, to know more about the API check the [[XeoPrimerJavaAPIObjectListManager][ObjectListManager API]] page and the [[XeoPrimerJavaAPIBoObjectList][boObjectList API page]]. ---++++ AttributeHandler & BridgeHandler Interactions with XEO Model attributes can be done using the AttributeHandler (all but collection attributes) and BridgeHandler (collection attributes) classes. These classes allow to retrieve and set the value(s) of the attribute as well as reaching the attribute definition. Read more about [[XeoPrimerJavaAPIAttributeHandler][AttributeHandler]] and [[XeoPrimerJavaAPIBridgeHandler][BridgeHandler]]. ---++++ boDefHandler The <em>bodefHandler </em>class is a programmatic way to have access to a XEO Model definition. [[XeoPrimerJavaAPIboDefHandler][Read more about boDefHandler]]. ---+++ Relations between XEO Java Classes To help understand the relation between the most important Java classes of the XEO API and how to have access them, see the two following figures (separated due to their size) <img width="960" alt="JavaAPI - Part1" src="http://wiki.itds.pt/pub/WebITDS/XeoPrimerJavaAPI/JavaAPI-Part1.png" title="JavaAPI - Part1" height="720" /> __Figure JA.1 - Relations between__ <img width="960" alt="JavaAPI - Part2" src="http://wiki.itds.pt/pub/WebITDS/XeoPrimerJavaAPI/JavaAPI-Part2.png" title="JavaAPI - Part2" height="720" /> __Figure JA.2 - Relations between Java class__ _ ---+++ Sample Workflow Code - Creating an instance, set attribute values and save the instance The XEO Java API can be used arbitrarily to fit your needs, but to illustrate a situation where one needs to create an instance of XEO Model A, set the value of two attributes ( _att1_ and _att2_) and save the instance, see the following code: <verbatim>try{ //Get the application instance boApplication app = boApplication.getDefaultApplication(); //Login a user boSession session = app.boLogin("SYSUSER", "ABC"); //Create a context EboContext ctx = app.createContext(session); //Retrieve the Object Manager boManagerBean objectManager = (boManagerBean) app.getObjectManager(); //Create a new instance object for Class "A" boObject obj = objectManager.createObject(ctx, "A"); //Retrieve attributes and set their value obj.getAttribute("att1").setValueString("my Value"); obj.getAttribute("att2").setValueBoolean(true); //In the end, update the object obj.update(); //Close all resources ctx.close(); session.closeSession(); } catch (boLoginException e) { //Log login error } catch (boRuntimeException e) { //Write to log, or something }</verbatim> _
Attachments
Attachments
Topic attachments
I
Attachment
Action
Size
Date
Who
Comment
png
JavaAPI-Part1.png
manage
39.3 K
2010-12-29 - 16:45
PedroRio
XEO Java API Relations
png
JavaAPI-Part2.png
manage
30.9 K
2010-12-29 - 16:45
PedroRio
XEO Java API Relations Part2
Edit
|
Attach
|
P
rint version
|
H
istory
:
r14
|
r12
<
r11
<
r10
<
r9
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r10 - 2011-03-29
-
PedroRio
WebXEO
XEO Primer
-
Instalation
-
Introduction
-
Concepts
-
Architecture
-
XEO Library
-
Deploy to EAR
-
PreferenceStore
XEO - Core
-
XEO Model Reference
-
Security
-
Java API
-
BOL
-
XEOQL (BOQL)
-
Administrating
-
Background Tasks
-
boConfig.xml
-
Web.xml
-
Known Issues
-
XEO Flags
XEO - XWC
- Web Components
- Java Samples
- Custom Components
- Component Plugins
- Internationalization
- Viewer Events
- Value Change Listeners
- XUIServlet
- XeoLocalization
- XvwTemplates
Create New Topic
WebXEO Web
No permission to view
TWiki.WebTopBar
No permission to view
TWiki.WebBottomBar