What is the default scope of xp:dominoDocument data source?
Sven Hasselbach posted an answer to another question, where he says that you have to set the scope of the data source to request scope and his answer solves the problem:
How can I refresh the XPages File Download Control and have it display updated attachments without full page refresh?
My experience with the default scope of the xp:dominoDocument data source is, that the default scope is the request scope. I am working with managed beans and managed properties. When I inject a xp:dominoDocument data source as a managed property in a managed bean then I have to set the scope of this managed bean to request scope.
Otherwise (e.g. managed bean scope is set to view) I get the following error:
27.05.2015 13:04:55 HTTP JVM: Managedbean fileUploadHandler could not be created The scope of the referenced object:
'#{currentDocument}' is shorter than the referring object. For more
detailed information, please consult error-log-0.xml located in
d:/Lotus/Domino/d
Yes, dominoDocument and dominoView are scoped to request, as Mark Leusink's Debug Toolbar from OpenNTF confirms.
If you want to use a datasource, it may be easier to avoid using a managed property. You can still add the datasource to the page, but access it via ExtLibUtil.resolveVariable(ExtLibUtil.getXspContext().getFacesContext(), "document1"); or navigate down to it from its container. Alternatively, you may be able to use managed properties for the document UNID, form etc, and instantiate a com.ibm.xsp.model.domino.DominoDocumentData in the bean's constructor or after a check for null in the getter.
A data source object will always sit in the request scope. What you are changing is the behaviour of the data container of the datasource, which is in the view scope by default.
When using the Debug Toolbar, you can see the behaviour: Even if you set the data source's scope to application scope, you still find the data source in the request scope. But also you will find a DominoDocumentDataContainer instance in the application scope.
If you are set the scope to request, the data container is also in the request scope. That's why the "file upload trick" works.
Related
When I am injecting a RxHttpClient in micronaut, I have an url with a token that I want to get from an environment variable to avoid hardcoding a secret.
In my service, I have injected the client like this:
#Client('${System.getenv(\'BOT_URL\')}')
#Inject
RxHttpClient httpClient
Being BOT_URL my url that's stored in an environment variable.
The project build but it fails while trying to use the client with this error:
2021-03-20 20:05:14.37 Could not resolve placeholder ${System.getenv('BOT_KEY')}
My variable is correctly defined in the server, how can I access to it when injecting the client?
Micronaut ships with pre-made PropertySourceLoaders that will resolve PropertySources from different sources. You can read more on externalized configuration through the docs.
Besides these PropertySourceLoaders, PropertySources are resolved from environment variables and are automatically injected and available for use within the ApplicationContext following the property source key syntax:
i.e. SOME_ENVIRONMENT_VARIABLE translates to some.environment.variable
Hence you can simply inject your HttpClient declaratively with the environment variable key translated to dot-separated-property-key syntax:
#Client('${bot.url}')
#Inject
RxHttpClient httpClient
You should be able to access environment variables just using ${BOT_URL}. I know for a fact that this works in the application.yml file. If it doesn't work in the annotation you can always create a property in application.yml with the value of the environment variable and use the property in your annotation.
For the docs on this, try the "Property value binding" section of the micronaut docs.
To be very specific: If I get the managed object context from the app delegate and do not set any parameters on it, what happens when running inserts, updates followed by save()?
Does the app block on save() until done?
Yes, the save method blocks. It's not even a default-- that's how it is, always. Does't matter if the context came from the app delegate or somewhere else, save is a synchronous method.
This what it came down to:
Normally, when I create an object, I only set the main key (properties that don't change through the lifecycle of the object) on creation. I then use an update method to complete the creation. In this particular case, I changed one property on the server from 'creational' property to 'updateable' property, but I missed it in the app. So the app was deleting the objects only to have the server create them again a bit later...
Is there is a way to invoke onExit() Life cycle hook manually?
If you´re talking about the onExit function of your controller you can! However, you should consider the View Lifecycle. According to this Lifecycle the framework will automatically call the onExit hook for you:
onExit(): Called when the view is destroyed; used to free resources and finalize activities
Source: SAPUI5 Documentation
Since it is a function which belongs to your controller you are able to call it manually by this.onExit() (in your controller).
However, this shouldn´t be necessary. To act according to the lifecycle you can call .destroy() of your view which destroys the view, the controller and all associated children.
destroy(): Cleans up the resources associated with this element and all its children.
Source: SAPUI5 Documentation
I am trying to set a session variable in an action method in MVC5, but it is giving compile-time error as shown above.
My Question: How can i correctly set a session variable in this case? Session is enabled in web config.
Controller name is OrdersController and action method is GetOrders.
I just found that this is too simple and I was missing it.
All that is needed to set a session variable in an action method is code like below.
Session["ColumnFilters"] = "somevalue";
I'm working on Spring MVC with richfaces.
Is there a way to call a method in a managed bean Controller from URL?
e.g: website.com/somecontroller/somemethod?x=1
I tried #RequestMapping but didn't work.
Thanks in advance
When the browser client want to access to an URL, the managed beans declared in the page will be created, the constructor and #PostConstruct methods will be invoked server side.
You can recover the parameters using #ManagedProperty as proposed by BalusC (as he says, the JSF-ish way):
Parameters in URL JSF 2
If that answer doesn't fit for your needs, you can recover the request object and get the parameters one by one, as stated in the question:
HttpServletRequest request = (HttpServletRequest)FacesContext.
getCurrentInstance().getExternalContext().getRequest();
String clipId = request.getParameter("x");