powered by Jive Software

Xhtml sample


I’‘ve copy and pasted the sample XHTML code. Using Gaim - which supports XHTML, I don’'t get the xhtml. Why is this?

I notice that the form example has an additional message.addExtension(…) methodcall. Can this be related.



When you say you pasted the XHTML code, where did you paste it. Because you do in fact need to add it as an extension and there is an XHTMLExtension class that you use #addBody(messageBody) on and then the Message#addExtension(XHTMLExtension).

Thanks. I’‘m sorry for my ambiguous posting. I’‘ll show you the code to eliminate any chance of ambiguity. This code doesn’‘t give me the xhtml in gaim. But as you may recognise I pretty much copied it from the doco and then added some code based on your previous suggestion. I’‘m not sure I absolutely need to use the XHTMLExtension class as you recommended, because now I’'ve got two PacketExtensions sitting in Message… in any case, what is wrong with this?

Message msg = c.createMessage();

msg.setSubject(“Any subject you want”);

msg.setBody(“Hey John, this is my new green!!!”);

// Create an XHTMLText to send with the message

XHTMLText xhtmlText = new XHTMLText(null, null);


xhtmlText.append("Hey John, this is my new ");








// Add the XHTML text to the message

XHTMLManager.addBody(msg, xhtmlText.toString());

XHTMLExtension xhtmlExtension = new XHTMLExtension();




you have two because i think:




XHTMLManager.addBody(msg, xhtmlText.toString());


both add it. You can check the code to make sure but thats the impression i have from just looking at the method signatures

Ok, in that case, It looks like I’‘ve got the extension in my message object, yet my message object isn’'t rendering the packetExtension. Dare I say it, is this an issue?

What do you mean by “rendering” is the xhtml there or isn’'t it?

What I mean is that I don’‘t see the xhtml. I see only the text body. I see that the message has a xhtmlExtension during debugging, but it doesn’'t render green in gaim.

can you post the debugger output?

It turns out that I’‘ve found out my problem. It’‘s gaim. Gaim reports xhtml capability, but doesn’'t actually render the xhtml. When I tested it in trillianPro, et voila, it worked.

To fix this issue, I think the sample code needs to be fixed. The msg.setBody() method should set a different text string than the xhtml text string. That way it’'s obvious which one is actually coming out. I used “this is not xhtml text” to differentiate the outputs. Once I did that it was clear that Gaim was the problem, not the smack api.

thanks for your time.

The point of having them both be the same message is so that clients that do not support XHTML can still display the message.