Show TOC

Background documentationBringing Files To Context Locate this document in the navigation structure

 

The Resource Service allows you to create context attributes of type Resource to bring files to context. The Resource type is needed for UI elements that handle files, e. g. FileUpload, FileDownload or OfficeControl. The xml file you need to display a Gantt or Network UI element is also handled this way.

Procedure

  1. Create a context attribute of type Resource, as described in Binding UI Element Properties to Dictionary Types and call it dataSource.

  2. Store the file (in this case: word.doc) in the mime repository in the directory: <Your   WD project>   Resources   src   mimes   Components   <your component>.  

  3. Insert the following code into the wdDoInit method:

    IWDWebModule module = wdComponentAPI.getDeployableObjectPart().getWebModule();

    String filename = WDURLGenerator.getResourcePath(module,"word.doc");

    IWDResource resource = WDResourceFactory.createMassDataResource(new FileInputStream(filename),WDWebResourceType.DOC);

    element.setDataSource(resource);