通过openfire插件开发之HelloWorld一文,我们已经知道了开发openfire插件的基本知识。我们这次来一起学习一下如何开发一个可以集成到openfire的amdin管理后台的插件。
新建我们需要的jsp文件,在插件src目录下面增加web文件夹,在web文件夹中添加一个welcome.jsp文件,这个文件需要自己编写。 可以参考其他案例插件。截图如下:
选择新建jsp文件,截图如下:
在welcome.jsp中随便输入写内容,我的如下:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>helwo world welcome</title> <meta name="pageID" content="welcome" /> </head> <body> <h1>hello world</h1> <input type="text"/> <input type="submit" value="提交"> </body> </html>
修改helloWorld控制台插件的plugin.xml文件,内容如下:
<?xml version="1.0" encoding="UTF-8"?> <plugin> <class>com.helloworld.HelloWorldPlugin</class> <name>helloWorld</name> <description>First Openfire Custom Plugin.</description> <author>xieyuan</author> <version>1.0.0</version> <date>14/07/2014</date> <minServerVersion>3.9.0</minServerVersion> <adminconsole> <tab id="tab-server"> <sidebar id="sidebar-server-settings"> <item id="welcome" name="welcome" url="welcome.jsp" description="hello world" /> </sidebar> </tab> </adminconsole> </plugin>
现在,我们来看看效果,刷新openfire admin页面我们看到:
现在解释一下上面各个选项的含义:
welcome.jsp中,content对应的是plugin.xml中item中的id。
plugin.xml中tab对应的是页面的顶部tab,比如服务器对应的是id为tab-server,用户/组对应的是tab-users,反正都有一个对应,然后sidebar对应每一个tab下面的子项,比如服务器下面有两个子项分别为服务器管理器,服务器设置,对应id为sidebar-server-manager,sidebar-server-settings,最后的item节点中,id前面说了,name指页面超链接的文本。这样呢就能将插件中的页面放到自己想要的地方去。当然不一定要放到现有的tab下面,也可以新建一个tab,来存放。具体可以参考Fastpath Service这个插件的plugin.xml,照着他的例子写就行了。
版权声明:部分文章、图片等内容为用户发布或互联网整理而来,仅供学习参考。如有侵犯您的版权,请联系我们,将立刻删除。