Table of Contents


Since 4.0

The ace:dynamicResource component serves JSF resources created by custom implementations of javax.faces.application.Resource, allowing for greater control and flexibility.

See the ICEfaces Showcase Live Demo of this component, complete with source code.

Getting Started

To use the DynamicResource component, it is necessary to first make a custom implementation of javax.faces.application.Resource, as the basic example below. The implementation can modify the behaviour of the Resource in any way to better suit the purposes of the application.

    public class MyResource extends Resource implements java.io.Serializable {

        private String path = "";
        private HashMap<String, String> headers;
        private byte[] bytes;
        public MyResource(byte[] bytes) {
            this.bytes = bytes;
            this.headers = new HashMap<String, String>();
        public InputStream getInputStream() {
            return new ByteArrayInputStream(this.bytes);

        public String getRequestPath() {
            return path;
        public void setRequestPath(String path) {
            this.path = path;

        public Map<String, String> getResponseHeaders() {
            return headers;

        public URL  getURL() {
            return null;

        public boolean userAgentNeedsUpdate(FacesContext context) {
            return false;

Once this is done and an instance is initialized, the component is added to the page, specifying this Resource instance, as well as other attributes that specify the way the resource is delivered.

<ace:dynamicResource id="dynamicResource"
	label="Download resource" 
	fileName="MyCustomFileName.pdf"  />


TagLib Documentation
This section covers attributes involved in the typical use-cases for this component. For reference, the complete taglib documentation for this component is available here.

The resource attribute references the instance of the Resource object to serve.

The type attribute specifies if a link, image, or button is displayed to the user to activate and download the resource.

Note that if you intend to produce a dynamic resourced based on some user input at the moment of clicking on this component, then you have to use the button type, in order to submit the form and process all input fields before generating and saving the resource, based on such input.

The label attribute specifies the label of the link or button when the resource is presented in these ways.

The attachment flag indicates whether the resource should be downloaded as an attachment, in order to force the browser to save the resource instead of trying to open it.

The fileName attribute specifies the name used to save this file as, when downloading it as an attachment.

Event Listeners


Client Behavior Events


JavaScript API

Not applicable.

Keyboard Support


CSS Classes

This component doesn't use any default CSS class names. The custom class names and styling specified in styleClass and style are applied on the a or input element, depending on the value of the type attribute.

Known Issues


Additional Resources


This component appears in the following ICEfaces tutorials:


Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

© Copyright 2021 ICEsoft Technologies Canada Corp.