Wiki source code of Java Client - Model-Defined FetchSpecifications
Last modified by David Avendasora on 2008/01/14 15:46
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | Client code: | ||
2 | |||
3 | {{code}} | ||
4 | |||
5 | private static final EODistributedObjectStore dos = (EODistributedObjectStore)(EOEditingContext.defaultParentObjectStore()); | ||
6 | |||
7 | /** | ||
8 | * Invokes the remote method on session to get a named fetch specification. Needed because | ||
9 | * the whole eoaccess package is excluded from the client side frameworks. | ||
10 | * | ||
11 | @param spec Fetch specification name. | ||
12 | @param entity Name of the entity for which the fetch specification is for. | ||
13 | @return The fetch specification, or null if it is not in the model, or an error occured | ||
14 | */ | ||
15 | public static EOFetchSpecification getFetchSpecification( | ||
16 | String spec, | ||
17 | String entity){ | ||
18 | |||
19 | //invoke! | ||
20 | return (EOFetchSpecification) dos.invokeStatelessRemoteMethodWithKeyPath( | ||
21 | "session", | ||
22 | "clientSideRequestGetFetchSpecification", | ||
23 | new Class[]{String.class, String.class}, | ||
24 | new String[]{spec, entity}); | ||
25 | } | ||
26 | |||
27 | {{/code}} | ||
28 | |||
29 | Server code, in the Session class: | ||
30 | |||
31 | {{code}} | ||
32 | |||
33 | /** | ||
34 | * Loads and returns an <tt>EOFetchSpecification</tt> objects for the given | ||
35 | * specification and entity name. | ||
36 | * | ||
37 | @param spec Name of the specification | ||
38 | @param entity Name of the entitiy | ||
39 | @return A fetch specification, or <tt>null</tt> if it is not found, or an | ||
40 | error occurs | ||
41 | */ | ||
42 | public EOFetchSpecification getFetchSpecification(String spec, String entity){ | ||
43 | try{ | ||
44 | return EOFetchSpecification.fetchSpecificationNamed(spec, entity); | ||
45 | }catch(Exception ex){ | ||
46 | return null; | ||
47 | } | ||
48 | } | ||
49 | |||
50 | {{/code}} | ||
51 | |||
52 | //courtesy Florijan Stamenkovic// |