edbuescher Posted January 25, 2022 Posted January 25, 2022 I have a TUniHTMLFrame where I've placed some links like <a href="../DataPage">Click Here</a> I can capture the link in the ServerModule's OnHTTPCommand or in the Main Form OnShow or OnActivate methods. The problem is that the link is spawning a new session. How do I achieve putting a link on a TUniHTMLFrame, but have it come back in the same session? I assume this would be done with something like an Ajax call, but I don't know how to do this. I've looked at various forum posts for REST calls and OnHTTPCommand processing, but I'm still at a loss. Thanks for any help Quote
Sherzod Posted January 26, 2022 Posted January 26, 2022 Hello, What do you want to achieve? Can you please explain in more detail? Quote
edbuescher Posted January 26, 2022 Author Posted January 26, 2022 I have these html links on a TUniHTMLFrame which is on a TUniForm. These links are simply html text on the frame, not part of a grid/table. I want to be able to click on one of the links and have it open a new form within the current application, not launch a new instance of the application, which is what it is doing now. I have another form with a TUniDBGrid and one of the columns has widget buttons, and I have the button click coded to open a new form within the application. I want to achieve similar functionality with a <a href=...> link displayed on an HTMLFrame. Let's say you had a form that had an "About Us" or "Contacts" link (formatted as an html <a href..> link) in the footer at the bottom of pages, and if a user clicked on the link you would want to open another form within the application. How would you do this? Quote
edbuescher Posted January 26, 2022 Author Posted January 26, 2022 2 hours ago, Sherzod said: Can you use UniHTMLMemo? I just tested by replacing the TUniHTMLFrame with a TUnitHTMLMemo. The <a href...> links display properly (as HTML Links), but don't act like links, that is the mouse doesn't change when you hover over the link text, and nothing happens if you click it. Am I missing something here? Quote
Sherzod Posted January 26, 2022 Posted January 26, 2022 Set it to read only, and search the forum, there is a solution to your question. Quote
Ron Posted January 26, 2022 Posted January 26, 2022 It is very easy to generate an Ajax call from an Anchor element, by using the onclick event: <a onclick="ajaxRequest(MainForm.HTMLFrame, ['linkclicked'], { link: 'test'});">A link</a> In the MainForm you respond to the call, and open whichever form you wish: procedure TMainForm.HTMLFrameAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if sameText(eventname,'linkclicked') then begin showMessage('Link clicked: '+Params.Values['link']); end; end; A test project is attached. ajaxtest.zip Quote
edbuescher Posted January 27, 2022 Author Posted January 27, 2022 21 hours ago, Ron said: It is very easy to generate an Ajax call from an Anchor element, by using the onclick event: <a onclick="ajaxRequest(MainForm.HTMLFrame, ['linkclicked'], { link: 'test'});">A link</a> In the MainForm you respond to the call, and open whichever form you wish: procedure TMainForm.HTMLFrameAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if sameText(eventname,'linkclicked') then begin showMessage('Link clicked: '+Params.Values['link']); end; end; A test project is attached. ajaxtest.zip 54.42 kB · 2 downloads Ron, Thank you so much for the sample code and project. I tested it and it indeed works. I'll end up using something with an <a href= tag as it shows the link text as a link and the mouse cursor changes when you hover over the link, but your code will work great in other situations where I don't need that, such as clicking on a picture. Quote
edbuescher Posted January 27, 2022 Author Posted January 27, 2022 On 1/26/2022 at 12:21 PM, Sherzod said: Set it to read only, and search the forum, there is a solution to your question. Here is the link I found and used with success I am able to grab and process the ajax callback but now I have another issue to deal with. The link is embedded in a UniHTMLMemo. How do I resolve the issue of the UniHTMLMemo only showing "true" after the click on the link: Before Click: Then after I click a link the form clears and the UniHTMLMemo shows "true" This happens BEFORE I capture the Ajax call which looks like this on the client javascript:window.parent.ajaxRequest(window.parent.O3B7, 'hrefClickAvg', ['hrefId=80106090(TX)']) Thanks for any help Quote
Ron Posted January 28, 2022 Posted January 28, 2022 Of course you can add an href tag for identification, but that is not necessary as you have the ability to identify the link through the ajax call using a parameter, as in the example. As you have to use a parameter anyway, you might as well use the parameter itself as the identifier, rather than using the href and then passing the href as a parameter, if you understand what I mean. Keep it simple. You will probably generate the html code automatically, so you can do this the way you like. Regarding your issue with the memo, you need to attach a test project for us to be able to analyze what happens. Quote
edbuescher Posted February 4, 2022 Author Posted February 4, 2022 Here's a test project that shows a UniHTMLMemo with 3 href links. When you click on a link it opens another form, and the text in the UniHTMLMemo, where the links are, now shows "True" until you close the form that was launched, then the links reappear. Ultimately I'd like to give the user the ability to open several of the links, but they can't because they disappear after you click the 1st link. TestLink.zip Quote
edbuescher Posted February 9, 2022 Author Posted February 9, 2022 On 1/26/2022 at 12:21 PM, Sherzod said: Set it to read only, and search the forum, there is a solution to your question. Sherzod, could you take a look at the test app I wrote to see if you can tell why it's acting the way it is. I'd really appreciate it as I'm stumped. Thanks, Eric Quote
Sherzod Posted February 10, 2022 Posted February 10, 2022 6 hours ago, edbuescher said: Sherzod, could you take a look at the test app I wrote to see if you can tell why it's acting the way it is. I'd really appreciate it as I'm stumped. Hello, I will try to check. Quote
Sherzod Posted February 10, 2022 Posted February 10, 2022 On 2/5/2022 at 2:53 AM, edbuescher said: Here's a test project that shows a UniHTMLMemo with 3 href links. When you click on a link it opens another form, and the text in the UniHTMLMemo, where the links are, now shows "True" until you close the form that was launched, then the links reappear. Ultimately I'd like to give the user the ability to open several of the links, but they can't because they disappear after you click the 1st link. Hello, Sorry, I don't really understand what you want. Quote
edbuescher Posted February 10, 2022 Author Posted February 10, 2022 On my system when you click on one of the <a href> links, the text in the UniHTMLMemo, where the links are, gets cleared and replaced with "True". Does it not do that on your system? If you look at my post from January 27, you will see some screenshots. Quote
edbuescher Posted March 21, 2022 Author Posted March 21, 2022 On 2/10/2022 at 3:14 PM, edbuescher said: On my system when you click on one of the <a href> links, the text in the UniHTMLMemo, where the links are, gets cleared and replaced with "True". Does it not do that on your system? If you look at my post from January 27, you will see some screenshots. Sherzod, I'm getting desperate here. I've sent support emails and have messaged you and Farshad, but haven't received any response in weeks, yet I can see UniGui has put out a new release and you are responding to other forum threads. I could really use some help. If you are stumped with my situation, could you have someone reply to my support email on this (FSD-4426). I'd really appreciate it. Thanks Quote
Sherzod Posted March 21, 2022 Posted March 21, 2022 Hello @edbuescher On 2/11/2022 at 12:27 AM, Sherzod said: Sorry, I don't really understand what you want. Quote
edbuescher Posted March 21, 2022 Author Posted March 21, 2022 Thank you for responding. Were you able to run the test app I sent on January 4th? It shows a UniHTMLMemo with embedded html links in the syntax of <a href>...</a>. Let's say that UniHTMLMemo is on Form A. The Ajax event captures the click on the link and opens Form B, but before it does so, Form A (or the UniHTMLMemo) is blanked and only shows the text "true". I have screen shots in my post from January 27. In my Test App, as soon as I close Form B, then Form A refreshes automatically and shows the original content, but in my production app, Form A continues to show "true". So If you have any idea on how to fix this, I'd love to know. If not, could you have someone respond to my support email (FS-4426). I also need to renew my annual license, but was unwilling to do so since nobody was responding to my emails regarding this. I was wondering if you all were still around, so THANK YOU for responding. Eric Quote
edbuescher Posted March 21, 2022 Author Posted March 21, 2022 1 hour ago, edbuescher said: Thank you for responding. Were you able to run the test app I sent on January 4th? It shows a UniHTMLMemo with embedded html links in the syntax of <a href>...</a>. Let's say that UniHTMLMemo is on Form A. The Ajax event captures the click on the link and opens Form B, but before it does so, Form A (or the UniHTMLMemo) is blanked and only shows the text "true". I have screen shots in my post from January 27. In my Test App, as soon as I close Form B, then Form A refreshes automatically and shows the original content, but in my production app, Form A continues to show "true". So If you have any idea on how to fix this, I'd love to know. If not, could you have someone respond to my support email (FS-4426). I also need to renew my annual license, but was unwilling to do so since nobody was responding to my emails regarding this. I was wondering if you all were still around, so THANK YOU for responding. Eric Sherzod, Also, here is what the links look like The link code in a uniHTMLMemo : <a href="javascript:window.parent.ajaxRequest(window.parent.O3C0, ''hrefClickAvg'', [''hrefId=80076078(TX)''])">80076078</a> and when you hover over the link it renders as: javascript:window.parent.ajaxRequest(window.parent.O3C0, 'hrefClickAvg', ['hrefId=80076078(TX)']) when you click on the link, the entire form (or maybe it's just the uniHTMLMemo) is blanked then renders the text "true", and then I can capture the AjaxEvent to handle the link request, so I'm fairly sure the issue is on the client side. Maybe there's a better way to render html links, or dynamically create widget type buttons instead of using links, although I'd still like to know how to get this working if possible. Quote
edbuescher Posted March 21 Author Posted March 21 The Issue I have with the UniHTMLMemo clearing it's text and then displaying "TRUE" after you click on a displayed Link in the UniHTMLMemo, is being caused by an issue with my Firebird browser. This doesn't seem to be an issue with an HtmlFrame. To get around the issue do this: 1) In the Ajax Event method of the UniHTMLMemo save the text of the Memo into a Stringlist 2)Execute your code in the Ajax method 3)Before you exit the Ajax Event method, restore the UniHTMLMemo text with the saved text stored in the Stringlist Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.