- 浏览: 15786 次
- 性别:
- 来自: 苏州
最新评论
This post will teach you how to configure the ADF Progress Indicator component within a .jspx web page of your OFM 11g application.
Implementation
Step 1
Add the following code to your web.xml file:
<context-param> <description>Max size of a file that will be uploaded in ram (10B)</description> <param-name>org.apache.myfaces.trinidad.UPLOAD_MAX_MEMORY</param-name> <param-value>10</param-value> </context-param> <context-param> <description>Max size of a file that will be uploaded on HDD (100MB)</description> <param-name>org.apache.myfaces.trinidad.UPLOAD_MAX_DISK_SPACE</param-name> <param-value>104857600</param-value> </context-param>
UPLOAD_MAX_DISK_SPACE Context Parameter – by default this parameter is equal with 2 MB and it isn’t explicitly defined within web.xml.
Step 2
Open adfc-config.xml and define a new managed bean. The newly created bean should have it’s scope set to session and must extend org.apache.myfaces.trinidad.model.BoundedRangeModelabstract class.
BoundedRangeModel abstract class declares 2 methods:
getMaximum() – which will be used by the progress indicator to get the size of the file to be uploaded:
public long getMaximum() { long result; long maxByte = getMaximumBytes(); if (maxByte == 0) result = -1; else { result = maxByte; } return result; }
getValue() – which will be used by the progress indicator to set the size that remains to be uploaded (or the size that has been already uploaded):
public long getValue() { long result; long availableByte = getMaximumBytes() - getAvailableBytes(); if (availableByte == 0 || availableByte == getMaximumBytes()) result = -1; else { result = availableByte; } return result; }
The uploading process is handled by the doUpload() method:
public void doUpload(ActionEvent actionEvent) { if (file != null) { setSizeOfFile(file.getLength()); Map<String, Object> atts = getPollid().getAttributes(); InputStream is; OutputStream os; File destinationFile = new File(file.getFilename()); try { is = file.getInputStream(); os = new FileOutputStream(destinationFile); int data; setMaximumBytes(getSizeOfFile()); while ((data = is.read()) != -1) { os.write(data); setAvailableBytes(is.available()); } this.stopPoll(); FacesContext fctx = FacesContext.getCurrentInstance(); FacesMessage message = new FacesMessage("Succesfully uploaded file: " + " " + file.getFilename() + ", containing " + getSizeOfFile() + " bytes."); message.setSeverity(FacesMessage.SEVERITY_INFO); fctx.addMessage(null, message); is.close(); os.close(); } catch (IOException e) { e.printStackTrace(); FacesMessage message = new FacesMessage(e.getMessage()); message.setSeverity(FacesMessage.SEVERITY_ERROR); FacesContext.getCurrentInstance().addMessage(null, message); } } }
In order to stop the poll, once the upload is done, we use the following method:
public void stopPoll() { FacesContext fctx = FacesContext.getCurrentInstance(); ExtendedRenderKitService service = Service.getRenderKitService(fctx, ExtendedRenderKitService.class); service.addScript(fctx, "AdfPage.PAGE.findComponent('" + getPollid().getClientId(fctx) + "').setInterval(-1);"); }
Step 3
In order to start the poll we shall use JavaScrip. The handlePoll function is listed below:
handlePoll = function (event) { //stops the event from propagating to the server side event.cancel(); //gets the poll component, with respect to it's id, from the jspx page var poll = AdfPage.PAGE.findComponent('pollid'); if (0 > poll.getInterval()) //starts the poll and sets it's update interval to 1 second poll.setInterval(1000); else //stops the poll poll.setInterval( - 1); }
Step 4
Now we shall configure the .jspx page as follows:
1. Register the JavaScript file with the jspx page by using the below line, inside af:document:
<af:resource type="javascript" source="/js/handlePoll.js"/>
2. Enable upload on the page:
<af:form id="f1" usesUpload="true">
3. Use af:inputFile to upload the file:
<af:inputFile label="File to upload:" id="if1" value="#{MyProgressRangeModel.file}" valueChangeListener="#{MyProgressRangeModel.uploadedFileChanged}"/>
4. Use af:progressIndicator in order to display the current status of the uploading process:
<af:progressIndicator id="progressIndicator" value="#{MyProgressRangeModel}"> <af:outputFormatted value="#{MyProgressRangeModel.percentageUploaded}% completed" id="of1"/> </af:progressIndicator>
Notice the value of the af:progressIndicator - is set as the managed bean that we have implemented at step 2.
Also, although you cannot see it here (because is defined in the parent of the af:progressIndicator), we use a Partial Trigger, having it’s value equal to the id of the af:poll component , in order to update the af:progressIndicator.
5. af:poll component enables automatic update for af:progressIndicator:
<af:poll id="pollid" interval="-1" binding="#{MyProgressRangeModel.pollid}" clientComponent="true"/>
6. af:commandButton is used to invoke the doUpload() method and start the upload process:
<af:commandButton text="Run" id="cb2" actionListener="#{MyProgressRangeModel.doUpload}"> <af:clientListener method="handlePoll" type="click"/>
The af:clientListener is used to call the JavaScript method that will start the poll once the upload starts.
The look of the progress indicator component can be changed by changing the skin-family within thetrinidad-config.xml file or by implementing your custom component and use css to integrate it with the OFM application. ADFProgressIndicator sample application uses fusion skin-family.
Running the application
Open ADFProgressIndicator OFM application in your JDevelopper IDE, navigate to Main.jspx page and run it – use Mozilla Firefox or Internet Explorer browsers; Google Chrome browser represents a special case which will be discussed later in this post.
Hint: In order to set JDevelopper IDE default browser follow the steps below:
Open JDevelopper IDE -> Tools -> Preferences… -> Web Browser and Proxy (bottom part of the left facet) -> Browser Command Line:
After the application is successfully deployed you should see the following page:
Choose a file and press Run. A new panel box will be displayed, containing the progress indicator:
After the upload is done the progress indicator is hidden and the following info message is displayed:
Notice: In order for ADFProgressIndicator OFM application to run when using Google Chrome browser the following are required:
1. Create a new jspx page containing the af:progressIndicator and af:poll conponents.
2. Integrate the newly constructed page within the current page by using the iframe component:
<iframe src="NewlyConstructedPage.jspx"/>
- ADFProgressIndicator.zip (230.1 KB)
- 下载次数: 26
相关推荐
### 锁相环ADF5355的使用经验与技巧 #### 一、概述 ADF5355是一款高性能的锁相环(PLL)频率合成器芯片,它结合了外部环路滤波器和外部参考频率,能够实现小数N分频或整数N分频的PLL频率合成。该芯片具有集成的...
压缩包中的“ADF检验MATLAB程序.doc”文档可能详细介绍了如何使用MATLAB代码实现这些步骤,包括如何调用`adftest`函数,如何处理结果以及可能遇到的问题和解决方案。阅读这份文档将有助于深入理解和应用ADF检验。 ...
标题中的“宽带PLL ADF41513(1)_ADF_acceptwcc_adf4360_ADF41513_ADf4360-7_”提及了两个关键器件:ADF41513和ADF4360-7。这两个都是高性能的频率合成器,在无线通信、测试设备以及各种信号处理应用中广泛使用。 ...
**ADF4351配置程序** ADF4351是一款高性能、高精度的频率合成器,广泛应用于无线通信、测试设备、卫星接收等系统中。它具有宽范围的频率输出能力,可编程的分频器和倍频器设计,使得在不同应用中能够灵活调整输出...
同时,使用ADF提供的调试工具可以方便地查看和调整皮肤效果。 通过上述知识点的学习和实践,开发者可以为ADF应用创建并实现多皮肤功能,提升用户体验,同时保持代码的可维护性和扩展性。在实际项目中,可以结合具体...
压缩包内的“adf4159.c”文件很可能是一个C语言源代码,包含了使用ADF4159芯片的具体程序实现。通过分析这个源代码,我们可以深入理解如何配置ADF4159以实现1.5GHz的非FMCW输出,以及可能的寄存器设置和时序控制。...
**ADF4351简介** ADF4351是一款高性能的射频(RF)频率合成器,由ADI公司设计生产,适用于多种无线通信系统。它采用先进的锁相环(PLL)技术,能够产生精确且可调的射频信号,频率范围广泛,正如描述中所提及的,...
### ADF4110/ADF4111/ADF4112/ADF4113 RF PLL 频率合成器 #### 特点 - **ADF4110**: 最大工作频率为550MHz。 - **ADF4111**: 最大工作频率为1.2GHz。 - **ADF4112**: 最大工作频率为3.0GHz。 - **ADF4113**: 最大...
在本压缩包文件中,我们有两个关键文件,一个是配置软件"ADF435x_v4_5_0.exe",另一个是ADF4351的设置文本文件"ADF4351_settings.txt",以及一份简要的使用说明"readme.txt"。 首先,"ADF435x_v4_5_0.exe"是专为ADF...
本教程将深入探讨如何使用硬件描述语言Verilog对ADF4355进行初始化配置。 首先,我们需要了解ADF4355的基本工作原理。ADF4355由一个锁相环(PLL)组成,可以产生精确的可调频率输出。它包括一个内置的压控振荡器...
5. 单端参考输入:ADF41513 的参考输入端口为单端结构,方便用户使用。 6. 3.3 V 电源供应:ADF41513 的电源供应电压为 3.3 V,满足了大多数应用的需求。 7. 1.8 V 逻辑能力:ADF41513 具有 1.8 V 的逻辑能力,满足...
本教程将深入探讨如何使用STM32微控制器通过SPI协议与ADF5355频率合成器进行通信。 **ADF5355简介** ADF5355是一款高性能的频率合成器,由Analog Devices公司生产,可提供广泛的频率范围和灵活的配置选项。它集成...
在这个压缩包中,包含的是ADF4351相关的关键资源,包括驱动代码、中文数据手册和相关论文讲解,这些都是理解和使用ADF4351所必需的知识点。 首先,让我们深入了解一下**ADF4351驱动代码**。驱动代码是与硬件设备...
2. 软件通常需要与特定版本的adf4350芯片兼容,使用前应确认软件版本与芯片版本匹配。 3. 在实际应用中,可能需要对电源、滤波器和输出匹配网络进行优化,以获得最佳性能。 总的来说,adf4350寄存器配置软件是实现...
ADF435x系列是ADI公司推出的一系列高性能、高精度频率合成器,主要应用于通信系统、测试设备、雷达系统等需要精确频率控制的场合。在这些设备中,ADF435x的寄存器配置至关重要,因为它直接影响到输出频率的精度和...
本文将深入探讨基于正点原子MINISTM32平台的ADF4001/ADF4002驱动代码,这两个器件是高性能的锁相环(PLL)芯片,广泛应用于无线通信、射频系统以及频率合成等领域。 首先,我们要理解锁相环(Phase-Locked Loop,简称...
"ADF4351模块资料-V1.0"是一个全面的资源包,涵盖了从软件驱动到硬件设计的所有方面,为使用ADF4351和STM32进行射频系统开发的工程师提供了便利。无论你是新手还是经验丰富的开发者,这个资料包都能帮助你快速上手并...
MSP430以其高效能、低功耗和丰富的外设接口著称,非常适合在需要精确控制和节省能源的应用中使用。 **CCS(Code Composer Studio)**是TI提供的一个集成开发环境,用于编写、调试和优化基于TI微控制器和处理器的...
本话题主要涉及"adf文件转TIFF文件",这是一种将特定的数据格式转换为广泛使用的图像格式的过程。下面我们将深入探讨ADF(Arc/Info Binary Grid)文件和TIFF(Tagged Image File Format)文件,以及如何进行这种转换...