欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
JSF (Java Server Faces) 開(kāi)發(fā)指南 step by step
Home
Tutorial

How To Create Your Own Java Server Faces Components



OK. We have created our own Java Server Faces component or, even have written a whole custom tag library. How do we make it reusable? How do we distribute it?

Of course, you can copy your classes and TLD file to the new project and add records to the faces-config.xml file. It will work. However, this would be inconvenient to do each time, especially if your library contains several dozen tags with double that number of class files all requiring filling in the faces-config.xml file with references to those classes. No, this is definitely not a good way. We will choice another one.

We will gather all of the information inside just one jar file and this will be the only one file we have to distribute.

To make a long story short, this is the structure of our taglib jar file:

The package ticker contains compiled classes for our ticker component. The top level META-INF folder contains the TLD file. It also contains the faces-config.xml file where the components, but nothing else are defined. Because the faces-config.xml file we have right now contains other information besides our component configuration information, let‘s clean it up by moving the other configuration data to a separate file we‘ll call faces-config-demo.xml.

Create the WEB-INF/faces-config-demo.xml file with the following content:

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"                              "http://java.sun.com/dtd/web-facesconfig_1_0.dtd"><faces-config> <managed-bean>  <managed-bean-name>BannerPageBean</managed-bean-name>  <managed-bean-class>demo.BannerPageBean</managed-bean-class>  <managed-bean-scope>request</managed-bean-scope>  <managed-property>   <property-name>rendered</property-name>   <property-class>java.lang.Boolean</property-class>   <value/>  </managed-property> </managed-bean> <application>  <locale-config/> </application> <factory/> <lifecycle/></faces-config>

Remove the information about the managed bean from the faces-config.xml file. The resulting content of this file will then be the following:

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"                              "http://java.sun.com/dtd/web-facesconfig_1_0.dtd"><faces-config> <component>  <component-type>ticker</component-type>  <component-class>ticker.UITicker</component-class> </component> <application>  <locale-config/> </application> <factory/> <lifecycle/></faces-config>

This cleaned-up file will be copied inside the META-INF folder in our mylib.jar file.

To have our current demo application working, we have to add the information about the new configuration file we just added into the web.xml. This will be the content of this file:

<?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd" version="2.4"> <context-param>  <param-name>javax.faces.STATE_SAVING_METHOD</param-name>  <param-value>server</param-value> </context-param> <context-param>  <param-name>javax.faces.CONFIG_FILES</param-name>  <param-value>/WEB-INF/faces-config.xml,/WEB-INF/faces-config-demo.xml</param-value> </context-param> <listener>  <listener-class>com.sun.faces.config.ConfigureListener</listener-class> </listener> <servlet>  <servlet-name>Faces Servlet</servlet-name>  <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>  <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping>  <servlet-name>Faces Servlet</servlet-name>  <url-pattern>*.jsf</url-pattern> </servlet-mapping></web-app>

To make assembling the resulting jar file archive easier, we need to add the following code into the build.xml file:

<property name="taglib.distname" value="mylib.jar"/><property name="taglibdeploy.dir" value="deploy"/><target name="createtaglib" depends="compile"description="Create deployable tag libraries file">	<delete dir="${build.dir}"/><mkdir dir="${build.dir}"/><mkdir dir="${build.dir}/META-INF"/>	<copy todir="${build.dir}/ticker">           <fileset dir="${webinf.dir}/classes/ticker"/>       </copy>       <copy file="${webinf.dir}/faces-config.xml" todir="${build.dir}/META-INF"/>       <copy file="${webinf.dir}/ticker.tld" todir="${build.dir}/META-INF"/>       <mkdir dir="${taglibdeploy.dir}"/>	<jar basedir="${build.dir}" jarfile="${taglibdeploy.dir}/${taglib.distname}"/></target>

In this file, the first property defines the name of the result archive. The second one defines the folder where the archive will be placed. To use the new Ant target coding we added, go to the Ant folder and run the script by typing from the command line:

ant createtaglib

To see how this works now, copy the mylib.jar file to the WEB-INF/lib folder of any Java Server Faces project. Then insert your new custom tag on one of the JSP pages. Don抰 forget to insert at the top of the page the definition:

<%@ taglib uri="http://jsftutorials.com/" prefix="d" %>

If you do everything right, the custom tag should work properly.

Note: Don‘t worry that you are going to use your custom tag libraries with projects that will usually have their own faces-config.xml files. It won‘t conflict with the faces-config.xml file that you have inside the META-INF folder in your library file. All of the files will be properly integrated at run-time.

See Also:

Guidelines for Designing Reusable Custom Components Using JavaServer Faces Technology


This article gives you some basic guidelines for designing
custom components using ChartComponent as an example.


Creating JSF Custom Components by Bill Dudney


This article illustrates how to build custom components for use
in web applications based on JavaServer Faces (JSF).

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
A first look at JavaServer Faces, Part 1 | JavaWorld
快速建立JSF環(huán)境
用jwebap監控獨立數據源應用
關(guān)于Liferay的配置文件 —— 基于Struts開(kāi)發(fā)Portlet
struts 使用多個(gè)配置文件 struts
Mule入門(mén)文檔
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久