HTML rendering

12 messages - 2125 views

Hey there !

 

I would like to know if there's a way to render html in a widget using Kuix. I think it hasn't been implemented yet but prefer asking instead of letting this passing by me.

Anyway, I need to render some simple html code (at least <u>, <b> and <li> tags) so I think I'll have to override Kuix's textarea ? Could anybody give me some hints ? Perhaps anybody knows such an already existing component ? I asked google but answers seems a bit complicated for my needs..

 

Hoping anybody could help me...

Thanks

If you only want to render simple HTML styling (<b>, <i>, <u>, <a href".."), the TextArea do that. Simply activate the styled property.

<textArea styled="true">

    <![CDATA[A simple sentence with <b>bold</b>, <i>italic</i>,<u>underlined</u> text and a <a href="www.kalmeo.org">link</a>.]]>

</textArea>

<a href="..."> create an Hyperlink widget that call by default a goUrl(...) action on the frames stack.

<img src="..."/> is implemented to, but only load embeded images.

Again, thanks very much Bo.

However it seems like it doesn't handles <ul> tags ? Would it be difficult for me to implement it ?

I hope the "styled" property also works with dynamix content comin from a DataProvider ? (I'll try it tomorrow)

Yes, it do not handles <ul> tags. At present it could be a bit difficult to you because some important methods like paintImpl are protected in 1.0.0RC2. I think I will switch them public in the next release to be able to completly derive widgets.

Ok...

It seems like it's the same for <p> or <br> tags, so I've to find a solution, 'cause I load html basic content from a cms platform, and when I display it in such a textarea, I loose all my carriage returns and unordered lists

 

Thank you very muck btw

At present, if a TextArea is styled, only valid XML input is alowed.

In this case, for example, <br> is not a valid XML tag, but <br/> is and is implemented.

I decided to implements only b, u, i, br, a, img because of performance reasons.

 

Great !

 

One more question (the last I hope ...) : what about the characters encoding ? "é" or "è" stored in the content I load in a textarea aren't loaded correctly, how am I supposed to do ?

You need to encode your code or xml file in UTF-8.

To be sure xml file is read as UTF-8 file you can add this on the top : <?xml version="1.0" encoding="UTF-8"?>

Bo said :

<img src="..."/> is implemented to, but only load embeded images.

 

What do you mean by embeded images ? It means that I have to manually retrieve my picture from server and disaply it "programmatically" in my midlet ? <img> tag can't manage to display a remote reference ?

Would you give me a hint please ?

 

Thanks

Hi,

Something is sure: <img> don't allow remote data. I don't think that remote data in XML is a good idea because most of the time (the emulator do): the user will be warned that a connection is opened. But I think this is fully possible programmatically (because you control the link with server in case of error).

mmmmm ok, I'll try to do that programmatically. I think I only need to parse the content I display, searching for the <img>, then retrieve the remote image and it'll be ok !

I'm also trying to find a way to avoid all those messages when I need to use the localization, the network and other stuff but it seems to be a bit complicated. It deals with permissions, granted by the level of security choosen while signing the midlet, but I first need to get a certificate... anyway, I hope google'll help me !

Thanks Luciole for you help ;)

also .. dir="rtl" is not working for text area. could anyone please tell me what to do?

 

Thanks