概述
zPfileupload.jar打包总结
新建一个java project
src中目录结构:
原先primefaces4.0中包名+文件名为:org.primefaces.component.fileupload+文件名
现在以示区别将包名中的org去掉改为primefaces.component.fileupload
第一部分:则现在目录结构为:包名:primefaces.component.fileupload
文件名:1.CommonsFileUploadDecoder.java
2.FileUpload.java(与组件标签的属性对应,并内注依赖的js,css在META-INF/resources/fileupload/文件夹中,不要与primefaces4.0jar中路径同名)
修改@ResourceDependency(library="fileupload", name="fileupload.js")
@ResourceDependency(library="fileupload", name="fileupload.css")
3.FileUploadHandler.java
4.FileUploadRenderer.java(encode等方法将组件encode为一些标准html标签的组合)
5.NativeFileUploadDecoder
改动是在FileUploadRenderer.java在encodeChooseButton对应选择按钮和encodeButton对应上传取消按钮这两个方法cssClass加上的一个class" ui-state-nodisplay "
(备注该" ui-state-nodisplay "双引号中前后含有空格,传到浏览器中class 名字以空格间隔)
第二部分:
在META-INF中/resources/fileupload/
1.fileupload.css
修改部分增加
.ui-fileupload-buttonbar .ui-state-nodisplay{
display:none;
}
2.fileupload.js
修改部分:(作用在通过增加class display:none来调节按钮之间切换隐显)
disableButton: function(btn) {
//alert(btn.prev());
//alert(btn.parent().children().first());
btn.parent().children().first().removeClass('ui-state-nodisplay');
btn.prop('disabled', true).addClass('ui-state-disabled').addClass('ui-state-nodisplay').removeClass('ui-state-hover ui-state-active ui-state-focus');
},
enableButton: function(btn) {
//alert(btn.prev());
//alert(btn.parent().children().first());
btn.parent().children().first().addClass('ui-state-nodisplay');
btn.prop('disabled', false).removeClass('ui-state-disabled').removeClass('ui-state-nodisplay');
},
3.ie-anim.gif
在META-INF中配置文件:
1.faces-config.xml(配置了component-class,renderer-class均指向自己新建的类)
<?xml version="1.0" encoding="utf-8"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
<name>fileUpload</name>
<component>
<component-type>primefaces.component.FileUpload</component-type>
<component-class>primefaces.component.fileupload.FileUpload</component-class>
</component>
<render-kit>
<renderer>
<component-family>primefaces.component</component-family>
<renderer-type>primefaces.component.FileUploadRenderer</renderer-type>
<renderer-class>primefaces.component.fileupload.FileUploadRenderer</renderer-class>
</renderer>
</render-kit>
</faces-config>
2.primefaces-p.taglib.xml(使用命名空间http://primefaces.org/uigai;标签属性component-type,renderer-type在faces-config.xml中有对应字符串任意但是要与源码的标识符区别)
<?xml version="1.0" encoding="UTF-8"?>
<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
version="2.0">
<namespace>http://primefaces.org/uigai</namespace>
<tag>
<description><![CDATA[FileUpload goes beyond the browser input type="file" functionality and features a flash-javascript solution for uploading files.
File filtering, multiple uploads, partial page rendering and progress tracking are the significant features compared to legacy fileUploads.]]></description>
<tag-name>fileUpload</tag-name>
<component>
<component-type>primefaces.component.FileUpload</component-type>
<renderer-type>primefaces.component.FileUploadRenderer</renderer-type>
<handler-class>primefaces.component.fileupload.FileUploadHandler</handler-class>
</component>
<attribute>
<description><![CDATA[Unique identifier of the component in a namingContainer.]]></description>
<name>id</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Boolean value to specify the rendering of the component, when set to false component will not be rendered.]]></description>
<name>rendered</name>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
<attribute>
<description><![CDATA[An el expression referring to a server side UIComponent instance in a backing bean.]]></description>
<name>binding</name>
<required>false</required>
<type>javax.faces.component.UIComponent</type>
</attribute>
<attribute>
<description><![CDATA[Value of the component.]]></description>
<name>value</name>
<required>false</required>
<type>java.lang.Object</type>
</attribute>
<attribute>
<description><![CDATA[An el expression or a literal text that defines a converter for the component. When it's an EL expression, it's resolved to a converter instance.
In case it's a static text, it must refer to a converter id.]]></description>
<name>converter</name>
<required>false</required>
<type>java.faces.convert.Converter</type>
</attribute>
<attribute>
<description><![CDATA[When set true, process validations logic is executed at apply request values phase for this component. Default is false.]]></description>
<name>immediate</name>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
<attribute>
<description><![CDATA[Marks component as required.]]></description>
<name>required</name>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
<attribute>
<description><![CDATA[A method expression referring to a method validationg the input.]]></description>
<name>validator</name>
<required>false</required>
<type>javax.faces.validator.Validator</type>
</attribute>
<attribute>
<description><![CDATA[A method binding expression referring to a method for handling a valuchangeevent.]]></description>
<name>valueChangeListener</name>
<required>false</required>
<type>javax.faces.event.ValueChangeListener</type>
</attribute>
<attribute>
<description><![CDATA[Message to display when required field validation fails.]]></description>
<name>requiredMessage</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Message to display when conversion fails.]]></description>
<name>converterMessage</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Message to display when validation fails.]]></description>
<name>validatorMessage</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Name of the client side widget.]]></description>
<name>widgetVar</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Inline style of the main component.]]></description>
<name>style</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Style class of the component.]]></description>
<name>styleClass</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Component(s) to be updated after fileupload completes.]]></description>
<name>update</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Component(s) to be processed during fileupload request.]]></description>
<name>process</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Method expression to listen file upload events.]]></description>
<name>fileUploadListener</name>
<required>false</required>
<type>javax.el.MethodExpression</type>
</attribute>
<attribute>
<description><![CDATA[Allows choosing of multi file uploads from native file browse dialog, turned off by default.]]></description>
<name>multiple</name>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
<attribute>
<description><![CDATA[When set to true, selecting a file starts the upload process implicitly. Default is false.]]></description>
<name>auto</name>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
<attribute>
<description><![CDATA[Label of the browse button, default is 'Choose'.]]></description>
<name>label</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Regular expression for accepted file types, e.g. /(.|/)(gif|jpe?g|png)$/]]></description>
<name>allowTypes</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Maximum number of files to be uploaded.]]></description>
<name>fileLimit</name>
<required>false</required>
<type>java.lang.Integer</type>
</attribute>
<attribute>
<description><![CDATA[Individual file size limit in bytes. Default is unlimited.]]></description>
<name>sizeLimit</name>
<required>false</required>
<type>java.lang.Long</type>
</attribute>
<attribute>
<description><![CDATA[Mode of the uploader, valid values are "simple" and "advanced".]]></description>
<name>mode</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Label of the upload button, default is 'Upload'.]]></description>
<name>uploadLabel</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Label of the cancel button, default is 'Cancel'.]]></description>
<name>cancelLabel</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Message to display when file size validation fails.]]></description>
<name>invalidSizeMessage</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Message to display when file limit validation fails.]]></description>
<name>invalidFileMessage</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Message to display when file count validation fails.]]></description>
<name>fileLimitMessage</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Specifies dragdrop based file selection from filesystem, default is true and works only on supported browsers.]]></description>
<name>dragDropSupport</name>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
<attribute>
<description><![CDATA[Callback to execute at the beginning of fileupload.]]></description>
<name>onstart</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Callback to execute after fileupload request completes.]]></description>
<name>oncomplete</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Callback to execute after fileupload request fails.]]></description>
<name>onerror</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Disables fileupload user interface interaction.]]></description>
<name>disabled</name>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
<attribute>
<description><![CDATA[Message template to use when displaying file validation errors. Default is "{name} {size}".]]></description>
<name>messageTemplate</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Width for image previews in pixels. Default value is 80.]]></description>
<name>previewWidth</name>
<required>false</required>
<type>java.lang.Integer</type>
</attribute>
</tag>
</facelet-taglib>
OK,打包
primefaces官网:http://www.primefaces.org/
primefaces是基于JSF框架的组件库
最后
以上就是个性大叔为你收集整理的学习primefaces上传组件并重新打包的全部内容,希望文章能够帮你解决学习primefaces上传组件并重新打包所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复