Hi Folks - I’ve been researching the threads relating to hyper links - but none seem to relate to this requirement.
A Client needs to link back to specific documents they have on their server - held in a http://xyz.serevername/EFGDirectory/abc.pdf etc format. I can add this text to a TEXT_FIELD or an HTML_AREA on a form - but obviously isn’t in hyper link format - which he needs to keep in style with other local apps.
I’ll eventually have the user locate the file in an open file dialogue and insert that path as an http:// string, but also I need the ability to copy and paste the link into the form if he is currently looking at the link in a browser for example.
Currently, if I copy a hyper link from another source (an email for example) and paste it into my HTML_AREA I (sometimes) get the link surrounded by ‘Start Fragment’ and ‘End Fragment’ blocks?? Other times I cant paste anything in there and the area appears empty (currently not completely sure what the differences are about when I can paste and when I cant?). I’m unsure about the following points:
Q. Should this text (the link) be held in a Text or HTML field type (for testing this is a form variable though eventually they will be in a column of links for a particular related record)?
About the Start Fragment I would say it comes from the way you do the copy (or application) and not an issue from Servoy. If you paste the thing in another application you get a different result (in some text editor, for example) ?
About the Start Fragment I would say it comes from the way you do the copy (or application) and not an issue from Servoy. If you paste the thing in another application you get a different result (in some text editor, for example) ?
Thanks Laurian
I dont get that fragment issue in any other application (notepad etc.) so not sure where it’s coming from?
About the Start Fragment I would say it comes from the way you do the copy (or application) and not an issue from Servoy. If you paste the thing in another application you get a different result (in some text editor, for example) ?
Thanks Laurian
I dont get that fragment issue in any other application (notepad etc.) so not sure where it’s coming from?
Not sure either, haven’t seen it before. If you have a reproduceable scenario you can open a case.
When you paste an URL in the HTML_AREA field then it creates the appropriate HTML for you but it won’t make it a clickable link.
When you paste an URL in a TEXT_AREA then it won’t create any proper HTML but it will show the same text in a HTML_AREA. Again, no clickable link.
When you paste an URL in the HTML_AREA field then it creates the appropriate HTML for you but it won’t make it a clickable link.
When you paste an URL in a TEXT_AREA then it won’t create any proper HTML but it will show the same text in a HTML_AREA. Again, no clickable link.
How do you put the URL in there ?
Thanks Robert - at the moment I’m just doing a cur and paste (ctrl-C / ctrl-v) and I’d like the Client to have that ability too - but also we’ll probably mainly use the open file dialog to allow him to select the file to hyperlink too.
My thoughts are - on paste (on DataChange) of an HTML area I would wrap the http:// string in the necessary html code to become a click-able link. Similarly when using the open dialog I’ll take the Dir/Filename text and wrap it in HTML to create a link. Does this make them clickable ? or do I still need to do a showURL() on the field content?
Is this a sensible solution Robert, or is there an easier route in Servoy? These links I’ve shown are actual links the client is using currently - so if they have something wacky in there then I need some way to address it in code or their document handling system will break. The links are actually links through to their internal server so they don’t work outside their network - but I cant see anything wron with them in html terms? (posted below)
I don’t see anything wrong on that HTML either other then it has a whole load of unnesserary styling in there.
As for a pasting URL’s. You could use an text field to paste/type the URL in and use an onDataChange or a button to process this into a proper formatted clickable link to be shown in another (HTML_AREA field).
Also I noticed that in the webclient you can’t type/paste into an editable HTML_AREA field (which makes sense). This only works in rich-client.
I don’t see anything wrong on that HTML either other then it has a whole load of unnesserary styling in there.
As for a pasting URL’s. You could use an text field to paste/type the URL in and use an onDataChange or a button to process this into a proper formatted clickable link to be shown in another (HTML_AREA field).
Also I noticed that in the webclient you can’t type/paste into an editable HTML_AREA field (which makes sense). This only works in rich-client.
Hi Folks - after the above discussion regarding adding a hyperlink to a form, perhaps I have missed the point!
My original objective was to allow a Client to take a current Hyperlink (to a document or web page) and paste it into a space on the form, in such a way that it was
a) easily identifiable as a link, and b) he could click on it, as he would in any other application, to open the link.
It seems its not a simple process to do that in Servoy.
By wrapping a string (i.e. ‘http://xyz.com/test.html’ etc) in an ‘<a href=’ format it is definitely shown as a hyperlink in an HTML_Area. However that link is not click-able as a typical hyperlink should be. Instead it needs to be parsed, to strip off the previously added <a href= and fired using application.showURL().
A simpler route is to save the string in a TEXT_FIELD (though that does not show the link in a Hyperlink format) then fire that string in an application.showURL() method.
I guess I’m asking the same question as originally posed again - is there an easier way to display a string as a link and make it click-able???
I feel I must have missed something in this regard considering Servoy is so Web Compliant and yet the most basic requirement in html (the hyperlink) is not easily supported. I’m confused
I did some testing and found the following technique working in both Web- and Rich Client.
I created 2 form variables:
var _sHTML = "";
var _sText = "";
Then I placed 2 fields on a form, one as TEXT_AREA with _sText as dataprovider and one HTML_AREA (non-editable) with _sHTML as dataprovider.
Then I placed a button on the form to process the pasted URL in the TEXT_AREA field. This button has the following method attached:
This method produces the HTML for the (uneditable) HTML_AREA field. Once you click the hyperlink it will trigger the following method:
function doOpenURL(_sURL) {
application.showURL(encodeURI(_sURL), "_self");
// change '_self' to '_blank' if you want a new window to be opened.
// using encodeURI to make sure any spaces and such are properly encoded for the web.
}
This will open the URL in the same window on Web Client and will open the browser on the Rich client.
NOTE: in Developer’s (Rich) debug client it won’t open a browser but gives a statustext message. Just test it in a real Rich client.