Upload files to database using ADF

person Bijeshfolder_openADF, Oracleaccess_time July 12, 2011

While exploring options to develop an upload-to-database feature, I came across repeated suggestions that using Oracle MultiMedia (previously InterMedia) datatypes (OrdDoc, OrdImage, etc.) was the way to go. A few forums started me off in the right direction. This one for e.g. However, it wasn’t as straightforward to get it working especially given that there was no documentation whatsoever around OrdDomain types in the Fusion guides. So these are the steps that need to be done.

  1. Configure the OrdPlayMediaServlet in your web.xml and map it to the url-pattern “ordDeliveryMedia”
      <servlet>
        <servlet-name>ordPlayMediaServlet</servlet-name>
        <servlet-class>oracle.ord.html.OrdPlayMediaServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>ordPlayMediaServlet</servlet-name>
        <url-pattern>ordDeliveryMedia</url-pattern>
      </servlet-mapping>
    
  2. Map the adfBindings filter to this servlet
      
      <filter-mapping>
        <filter-name>adfBindings</filter-name>
        <servlet-name>ordPlayMediaServlet</servlet-name>
      </filter-mapping>
    
  3. Ensure that the entity uses the Ord types – oracle.ord.im.OrdDocDomain, oracle.ord.im.OrdImage, etc. – for the document attribute. I had JDeveloper go crazy on me a few times when it automatically created some custom domain types for the “ORDSYS.ORDDOC” column. These were unusable as they exposed only the metadata related to the Ord type – mime type, location, etc. I don’t know what triggered that behaviour but after deleting and recreating some of the objects it was alright.

  4. Set the usesUpload attribute on the af:form to true.
  5. Create the inputFile element and bind it to the view attribute. For e.g #{bindings.Doc.inputValue}
  6. Add the binding:convertOrdDomain converter to the inputFile. To do this, first
    a) Add the BC4J HTML library to the ViewController Project and
    b) add the “ADF Faces Bindings 1.0” tag library to the component palette.

    <af:inputFile 
    value="#{bindings.Doc.inputValue}" 
    label="#{bindings.Doc.hints.label}"
    required="#{bindings.Doc.hints.mandatory}"
    columns="#{bindings.Doc.hints.displayWidth}"
    shortDesc="#{bindings.Doc.hints.tooltip}" id="it2">
         <f:validator binding="#{bindings.Doc.validator}"/>
         <binding:convertOrdDomain bindingRef="#{bindings.Doc}"/>
    </af:inputFile>
    
  7. In the pageDef, set the CustomInputHandler for the view object attribute binding to OrdDomainValueHandler

        <attributeValues IterBinding="TestDocView1Iterator" id="Doc"
               CustomInputHandler="OrdDomainValueHandler">
          <AttrNames>
            <Item Value="Doc"/>
          </AttrNames>
        </attributeValues>
    

Comments

  1. Pingback: JavaPins

  2. I am working on a similar use case to upload a file and found thought that storing it as Ord Type would be a better solution than storing it as a Blob. I believe I followed all the steps you had outlined above but once I’ve select a file to upload the file name is shown in the input file component, but saving it erases the file name and does not save the file. I set AutoSubmit to true but this did not help either. Do you know if I may have missed something. I verified that I followed all the steps that you had outlined, and also looked at some of the blogs you mentioned. Is there any code that needs to be written in the value change event to convert the file?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>