powered by Jive Software

Xhtml from PacketRejectedException

Hello all,

I see there is a Smack PacketExtension that allows xhtml formatted messages but is there a means to accomplish this from a plugin?

I have a plugin that has a PacketInterceptor and if a certain condition exists, I return a message to the user in the PacketRejectedException that is thrown. I have a need to format this message in a table or something similar.

Any Ideas?

Thanks in advance.

IMHO your best bet is to copy XHTMLText.java from the smack sources into your plugin in order to create properly escaped XHTML text.

Maybe in the feature this file should be shared between smack, openfire e.g. via tinder.


The problem I have is that I am not returning a Message but rather a PacketRejectedException thus I cannot see a way of calling XHTMLManager.addBody(Message message, String body) on an Exception.

public void interceptPacket(Packet packet, Session session, boolean incoming, boolean processed) throws PacketRejectedException {
     PacketRejectedException pre = new PacketRejectedException();
     if {//check for something
               pre.setRejectionMessage("my message");      }
     else {
               pre.setRejectionMessage("my other message");
     throw pre;

Any ideas are much appreciated.