Trace:
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
applications:user:dynamic_objects [2019/12/20 15:21] admin |
applications:user:dynamic_objects [2020/07/01 17:19] (current) cduncan Edited for English grammar (capitalization, punctuation, correct verb conjugation) |
||
---|---|---|---|
Line 1: | Line 1: | ||
~~NOTRANS~~ | ~~NOTRANS~~ | ||
- | ~~Title: Using dynamic/user objects~~ | + | ~~Title: Using Dynamic/User Objects~~ |
- | As dynamic object we think of a dynamic created object which is available in the application without changing the application. Sometimes, it's useful to "inject" objects into your application and use such objects in your business logic. This use-case is already supported via [[jvx:server:lco:inject_objects|]]. The missing part is that it's not automatically possible to access such objects in your application. Sure, if you put an [[jvx:server:lco:actions|action]] in your LCO and a [[jvx:communication:calling_server_action|simple remote call]] in your [[vaadin:customize_application|custom application]], it'll be easy. But it's not guaranteed that you have a custom application. It's some work to extend the standard ProjX application. So this is not a thing for one minute. | + | With a dynamic object, we think of a dynamically created object that is available in the application without changing the application. Sometimes, it's useful to "inject" objects into your application and use such objects in your business logic. This use-case is already supported via [[jvx:server:lco:inject_objects|]]. The missing part is that it's not automatically possible to access such objects in your application. Sure, if you put an [[jvx:server:lco:actions|action]] in your LCO and a [[jvx:communication:calling_server_action|simple remote call]] in your [[vaadin:customize_application|custom application]], it'll be easy. But it's not guaranteed that you have a custom application. It's some work to extend the standard ProjX application. So this is not something to be done last minute. |
- | To support this use-case we have dynamic objects, available via standard ProjX API. And here is it: | + | To support this use-case, we have dynamic objects available via standard ProjX API. And here is it: |
<file java> | <file java> | ||
Line 11: | Line 11: | ||
The name is the important thing. By default, no dynamic objects exist, so the method will return null. | The name is the important thing. By default, no dynamic objects exist, so the method will return null. | ||
- | If want to use a custom dynamic object, write one e.g.: | + | If want to use a custom dynamic object, write one, e.g.: |
<file java> | <file java> | ||
Line 38: | Line 38: | ||
</file> | </file> | ||
- | This object must be [[jvx:server:lco:inject_objects|injected]] in your Session LCO e.g. via ServiceLoader. If it's injected, the API call | + | This object must be [[jvx:server:lco:inject_objects|injected]] in your session LCO, for example via ServiceLoader. If it's injected, the API call |
- | <file> | + | <file java> |
((ProjX)getApplication()).getDynamicContent("userDetails"); | ((ProjX)getApplication()).getDynamicContent("userDetails"); | ||
</file> | </file> | ||
Line 46: | Line 46: | ||
will return the Bean instance of your DynamicUserContent. | will return the Bean instance of your DynamicUserContent. | ||
- | So, it's super easy to inject objects and make it accessible in your application without changing your application code. | + | As you can see, it's super easy to inject an object and make it accessible in your application without changing your application code. |