|
<< Click to Display Table of Contents >> Navigation: Telegram > 2021 > 06 > 03 > Telegram_2021-06-03T17 |
2021-06-03T17:25:29
Execute method from the content handler
2021-06-03T17:25:44
when you create a new content handler you override the Execute method
2021-06-03T17:26:03
from there you have access to all parameters
2021-06-03T17:26:29
Could you provide an example? I am not sure I understand how to override the execute method.
2021-06-03T17:27:03
what type of content handler do you have?
2021-06-03T17:27:44
with THandlers.Add('/reset/', '', TContentForm.Create(TfrmReset)) do...
2021-06-03T17:34:15
Example
2021-06-03T17:35:49
Another option
2021-06-03T17:38:25
Does it need to be class(TContentForm) or can I use my existing class(TIWAppForm)?
2021-06-03T17:38:41
the content handler is not a form
2021-06-03T17:38:53
it must inherit from TContentForm (or TContentBase)
2021-06-03T17:39:20
a TContentForm instance is a class that uses a TIWForm to handle the request. But it is not a form
2021-06-03T17:40:23
it would be good if you could create a content handler like this (you need to change your registration as well).
And then you can put a breakpoint inside the Execute method and see if you are receiving the parameters from the Request
2021-06-03T17:41:19
So how would then display the form I want in the execute method? Sorry, I am missing something here.
2021-06-03T17:44:08
The Execute method of TContentForm (the inherited call) will take care of the form creation/execution. That's how it works
2021-06-03T17:44:43
ok, so just change class(TIWAppForm) to be class(TContentForm)?
2021-06-03T17:44:50
nope
2021-06-03T17:45:42
Add this unit as it to your project
2021-06-03T17:46:39
then add it to the uses clause to the unit that you are registering the content handler.
Then change it into:
with THandlers.Add('/reset/', '', TMyContentForm.Create(TfrmReset)) do...
2021-06-03T17:46:54
instead of a TContentForm you will create a TMyContentForm
2021-06-03T17:47:26
then you can put a breakpoint inside Execute method of that unit and see what parameters you are receiving
2021-06-03T17:53:47
I can't seem to call webapplication from the execute method. Says it's undeclared?
2021-06-03T17:54:39
You have the Session parameter which is exactly the IWApplication instance
2021-06-03T17:54:41
Looks like I need to use aSession
2021-06-03T17:54:45
yes
2021-06-03T17:54:55
always make sure that it is assigned
2021-06-03T17:56:59
How would I access the user session? TIWUserSession(aSession.Data).GIDParamStr := aSession.RunParams.Values['gid'];