HTML and source codes display

I am currently working on displaying HTML and it’s source code on the screen.

I’ve got 2 questions regarding this:

  1. Is there a way of displaying HTML preview and HTML codes in 2 different types of text area?
    I tried using TEXT_AREA to display the HTML source codes but HTML tags were not displayed.

  2. When using HTML_AREA to display HTML source codes, can I also embed images? If this is allowed, where should these images reside?

Thanks!

Hi Erik,

erikd:

  1. Is there a way of displaying HTML preview and HTML codes in 2 different types of text area?
    I tried using TEXT_AREA to display the HTML source codes but HTML tags were not displayed.

You should be able to show the same dataprovider in different fields at the same time. So a field with display type HTML_AREA and a field with display type TEXT_AREA.
I do this all the time.

erikd:
2. When using HTML_AREA to display HTML source codes, can I also embed images? If this is allowed, where should these images reside?

You can reference images in your HTML by way of the tag, like you do in webpages. These images can reside anywhere that the servoy client can access using the different protocol handlers (http://, https://. file://, media:///, etc.).
What are you trying to do ? Send emails with embedded images ? Or something else ?

Thanks for this. Yes, I am using it to send emails.

I am figuring out now how to have a tool bar for it.

Hi Erik,

When you send HTML email with embedded (attached) images you can simply reference them by name in the HTML like so:

<img src="attachedfilename.jpg">

Of course the image will only render for you when opened up in the (receiving) email client.
If you want to see the images in your solution before you send it out then you need to reference them differently (depends on what you want to do exactly) and then just before you send the email you automatically replace the references with the correct one.

Hope this helps.

Ok, Thanks! I will test what I got from your post.

One more question, is there a way to get the display values only from an HTML tag?

For example, if I have “< html >< p > Hello world < / p >< / html >”, is there an easy way to get “Hello World” only and store it in a variable?

erikd:
For example, if I have “< html >< p > Hello world < / p >< / html >”, is there an easy way to get “Hello World” only and store it in a variable?

If you name the html area field, an extra function becomes available that will convert html to text for you. elements.element_name.htmlToText() or something close (going off the top of my head).

I used getAsPlainText(). It worked ok.

Thanks for the reply.

erikd:
I used getAsPlainText(). It worked ok.

For most html it works ok, I’ve seen a couple of really advanced html strings which returned ‘null’ after getAsPlainText().
So I ended up stripping tags.

You’re right. Manual removal of tags is better.