Reseting the InputFile Component

Hi,
i have the problem that i upload a file with the help of th af:inputfile component and write it to DB with own SQL.
Everything works fine but the component remembers the upload of the file the next time i want to upload something - it only shows the possibility to "update" the preuploaded file. But i want to upload the next one and i don't find a command to "reset" the state of this component - is there a way to set the component to "browse" again?
I only found "RichInputFile.resetvalue()" but it has not the effect i wanted to have. The file keeps inserted in the component.
Thanks for help!

Make sure that you close the call file.dispos(); on the UploadFile you use to read the stream. If you have bind the af:inputFile to a bean you should also set it to null after the blob is uploaded.
     UploadedFile file = ....
     file.dispose();This should clear the filename and make the upload available for the next file.
Timo

Similar Messages

  • Reset the whole Component Tree?

    Hi,
    I've got 2 qeustions:
    1. How can I reset the whole Component Tree?
    2. And is it possible to destroy the User-Session for the current JSF application? If I use session.invalidate() the whole session will be destroyed, but I only want that all jsf things are resetted.
    Would be great if someone could give me a hint!

    A better way is to recreate the managed bean in the session scope.
    For example, to reset the current session instance of the backing bean MyBean which is definied as managed bean "myBean":public class MyBean {
        public void reset() {
            FacesContext
                .getCurrentInstance()
                    .getExternalContext()
                        .getSessionMap()
                            .put("myBean", new MyBean());
    }

  • Delete upload button in the inputFile component

    Hi Team,
    I implemented File upload machanism in ADF via the inputFile component. As per my requirement I dont need upload button in that.
    Is there any way to delete upload button from this File upload meachanism??
    Please suggest me regarding this.
    Thanks,
    Ramit

    Wild Guess.
    There is this code in your form:
    <af:form usesUpload="true"/>Try making it to false.
    Or else,
    There is a commandButton which is used for Uploading the file. Check the code with the following.
    <af:commandButton text="#{res['srfileupload.uploadbutton']}"
                      action="#{backing_SRFileUpload.UploadButton_action}"
                      visible="false"/>Edited by: Sahar Hassan on Jun 13, 2012 3:55 AM

  • Reset the UI component

    Hi
    i wrote my own method in session bean(JPA application) to insert record in tables. and i bind the method in jspx page. if i click to save its working fine.if i click cancel i want to reset the component i tried by using this code
    inputText1.resetValue();
    but it is not reseting the values. its show the values what i entered.
    i tried the same code in simple page with out binding the values or button its working fine
    Thanks and Regards
    purush

    hi
    I used this code to reset the values in text box.
    what i did is right ? please give suggestion
    FacesContext ctx = FacesContext.getCurrentInstance();
    Application app = ctx.getApplication();
    ValueBinding bind = app.createValueBinding("#{bindings.id.inputValue}");
    ValueBinding bind1 = app.createValueBinding("#{bindings.userName.inputValue}");
    ValueBinding bind2 = app.createValueBinding("#{bindings.id1.inputValue}");
    ValueBinding bind3 = app.createValueBinding("#{bindings.firstName.inputValue}");
    ValueBinding bind4 = app.createValueBinding("#{bindings.lastName.inputValue}");
    bind.setValue(ctx,null);
    bind1.setValue(ctx,null);
    bind2.setValue(ctx,null);
    bind3.setValue(ctx,null);
    bind4.setValue(ctx,null);

  • InputFile Component remembers last uploaded file

    Hi
    JDeveloper 11.1.1.5
    I have a file upload button in my page.
    File upload is working fine, but the InputFile component seems to remember the last file uploaded what so ever.
    It just shows the file name but actually does not have the file associated with the component for the second time.
    For simplicity, I want the component to show a blank field always.
    So before showing the popup, I am trying to reset the InputFile component with the following code.
    But it still shows the read only file name.
    Page code ..
    <af:inputFile label="Select CSV File" id="if1" value="#{pageFlowScope.workbookHelper.uploadedFile}" binding="#{pageFlowScope.workbookHelper.uploadedFileHandle}"/>
    Bean code ..
    private RichInputFile uploadedFileHandle;
    private UploadedFile uploadedFile;
    public void showXPopup(ActionEvent actionEvent)
    getUploadedFileHandle().resetValue(); // approach 1
    setUploadedFile(null); // approach 2
    UploadedFile file = getUploadedFile();
    if(file != null)
    file.dispose(); // approach 3
    ADFUtils.invokePopup(getXPopup().getClientId(FacesContext.getCurrentInstance()));
    Can you please tell me how to show blank input file component each time the component is shown in the popup?
    Thanks for any help.
    Sameer

    Hi,
    the input-file is in a af:popup, so did you try
    <af:popup ...contentDelivery="lazyUncached"> ?
    Another thing, for showing and hiding the framework support a direct api:
    public void showPopup(ActionEvent event)
       UIComponent source = (UIComponent) event.getSource();
       RichPopup popup = this.getPopup();
       RichPopup.PopupHints hints = new RichPopup.PopupHints();
       hints.add(RichPopup.PopupHints.HintTypes.HINT_ALIGN_ID, source)
            .add(RichPopup.PopupHints.HintTypes.HINT_LAUNCH_ID, source)
            .add(RichPopup.PopupHints.HintTypes.HINT_ALIGN, RichPopup.PopupHints.AlignTypes.ALIGN_AFTER_END);
       popup.show(hints); 
    }And binding a UI-Component to a scope like "pageFlowScope" is not a "best practise" ;)
    Martin

  • Issue with Getting the file path from InputFile component

    Hi,
    One of our requirement is like below:
    I am working on ADF 11g (latest release R1) page. User will select the file and when he/she clicks on the Save button we need to store the file path in the database.
    In the database file_path is varchar2(300). We need to store just the file path. I am using InputFile component but filepath is not getting inserted.
    This is really urgent. It would be really appreciate if anyone can guide me on this.
    Thanks
    MC

    Hi Mahesh,
    I have manage to store the file path from the InputFile component in Jdev 11g. I found the file upload script from this forum and manage to alter it so that i could save the file path to the database. But my problem is to retrieve it back to view as a document. Hope this will help you :)
    This is an example of what I have manage to save to my DB :
    (CLOB) //192.168.238.53/c$/Research/Docs/0906160744/EyeCandyLog.txt
    In my form, I save the file path first before I update the other fields. My code is something like this :
    public void uploadFile(ValueChangeEvent valueChangeEvent) {
    // Add event code here...
    InputStream in;
    FileOutputStream out;
    if(tanda == 0){
    try {
    // final Context context = getInitialContext();
    RS01Proposal rS01Proposal = (RS01Proposal)new InitialContext().lookup("Phase2-RS01Proposal#sr.model.RS01Proposal");
    id = rS01Proposal.dptProposalid();
    tanda = tanda + 1;
    System.out.println("tanda"+ tanda);
    } catch (Exception ex) {
    ex.printStackTrace();
    System.out.println("id"+id);
    proposal = id.substring(6);
    System.out.println("proposal"+proposal);
    UploadedFile file = (UploadedFile)valueChangeEvent.getNewValue();
    String fileUploadLoc = "//192.168.238.53/c$/Research/Docs/"+id+"/";//The place where file will saved
    //create upload directory
    boolean exists = (new File(fileUploadLoc)).exists();
    if (!exists) {
    (new File(fileUploadLoc)).mkdirs();
    if (file != null && file.getLength() > 0) {
    FacesContext context = FacesContext.getCurrentInstance();
    FacesMessage message =
    new FacesMessage("File Uploaded " + file.getFilename() +
    " (" + file.getLength() + " bytes)");
    *// extracting the file message to get the path*
    context.addMessage(valueChangeEvent.getComponent().getClientId(context), message);
    columnL = valueChangeEvent.getComponent().getClientId(context);
    column = columnL.substring(9);
    System.out.println(column);
    columnLengkap = "RS01"+column.toUpperCase();
    System.out.println("columnLengkap"+columnLengkap);
    *try {*
    out = new FileOutputStream(fileUploadLoc + "" + file.getFilename());
    in = file.getInputStream();
    *for (int bytes = 0; bytes < file.getLength(); bytes++) {*
    out.write(in.read());
    in.close();
    out.close();
    } catch (IOException e) {
    e.printStackTrace();
    } else {
    String filename = file != null ? file.getFilename() : null;
    String byteLength = file != null ? "" + file.getLength() : "0";
    FacesContext context = FacesContext.getCurrentInstance();
    FacesMessage message =
    new FacesMessage(FacesMessage.SEVERITY_WARN, " " + " " +
    filename + " (" + byteLength + " bytes)",
    null);
    context.addMessage(valueChangeEvent.getComponent().getClientId(context),
    message);
    System.out.println(fileUploadLoc+file.getFilename());
    a = fileUploadLoc+file.getFilename();
    b = b + 1;
    if (flagInsert == 0){
    try {
    // final Context context = getInitialContext();
    RS01Proposal rS01Proposal = (RS01Proposal)new InitialContext().lookup("Phase2-RS01Proposal#sr.model.RS01Proposal");
    rS01Proposal.insertDoc(id,proposal,columnLengkap,a);
    flagInsert = flagInsert + 1;
    System.out.println("tanda"+ tanda);
    //session
    ProposalSession.storeCurrentProposalId(id);
    } catch (Exception ex) {
    ex.printStackTrace();
    }else{
    // update proses
    try {
    // final Context context = getInitialContext();
    RS01Proposal rS01Proposal = (RS01Proposal)new InitialContext().lookup("Phase2-RS01Proposal#sr.model.RS01Proposal");
    rS01Proposal.updateDoc(id,proposal,columnLengkap,a);
    flagInsert = flagInsert + 1;
    //session
    ProposalSession.storeCurrentProposalId(id);
    System.out.println("tanda"+ tanda);
    } catch (Exception ex) {
    ex.printStackTrace();
    }

  • Getting null value for inputfile component in the popup

    Hi,
    My requirement is when i select the selectBooleanCheckBox a popup has to be rendered and with in that popup i have to display the inputfile component when i browse it should read the appropriate file.
    But i am getting null from the input file component.
    I written the code like this:-
    1.First i have written a value change listener for the selectBoolenCheckBox.
    2.I am rendering the popup from the valueChageEvent.
    3.And i written the dialogListener for the Dialog in the popup.
    and the code for the Dilog listener is:--
    public void readingInputFile(DialogEvent dialogEvent) {
    inputFile1.getValue();
    //it is giving null value.
    thanks in advance.
    From
    Srikanth.V

    thanks for giving suggestion.
    but i am not able to understand what meant by multipart in dialog page.
    Actually,The code i written was:--
    1. for selectBooleanCheckBox i written value chage listener
    onChangeValue(ValueChageEvent valueChageEvent){
    // in this i call the method to raise popup;
    risePopUp();
    2.The popup structure has follows:-
    af:form --> af:popup ---> af:dialog --->af:inputfile
    for this dialog i have written dilogListener:
    getInputFile(DialogEvent dialogEvent){
    //giving null for the inputFile,getValue();
    for this dialog i don't have any multipart property
    From,

  • Problem while displaying popup message while using inputfile component

    Hi
    I am using JDEV 11.1.1.2.0, using ADF i developed and application
    in my page i have a input file component, from which i am taking a csv file and reading it through valuechangeevent of inputfile component. I have used myfaces.trinidad-UploadedFile to get the selected file and read it using inputstream.
    I have put some validation check (validation check is done while reading the file using valuechangeevent of the inputfile component), while reading the file and incase i receive any error (validation mismatch), the reading of file stops ... and before doing that i used to display error message using below method:-
    public String ValidationCheck(String attrname, String attrvalue, int rownumber) {
    String msg="Validation error found in "+attrname+" with value "+attrvalue+" of row "+rownumber+" in the file. Please correct the file and retry/";
    FacesContext ctx = getFacesContext();
    FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, "");
    ctx.addMessage(null,fm);
    return null;
    i have used the same method to display message in other places where its showing correctly but fails in inputfile component.
    Please help me out how can display messages from inputfile component??
    Thanks
    Sudeep
    Edited by: SKD on Feb 21, 2012 12:02 PM
    Edited by: SKD on Feb 21, 2012 4:08 PM
    Edited by: SKD on Feb 21, 2012 4:11 PM

    It works fine for me (albeit on 11.1.2.1). Here is my complete test case:
    FileUploadTest.jspx:
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
      <af:document title="FileUploadTest.jsf" id="d1">
        <af:form id="f1" usesUpload="true">
          <af:inputFile label="Label 1" id="if1" valueChangeListener="#{TestBean.vcl}"/>
          <af:commandButton text="commandButton 1" id="cb1"/>
        </af:form>
        <af:messages id="m1"/>
      </af:document>
    </f:view>TestBean.java:
    package view;
    import javax.faces.application.FacesMessage;
    import javax.faces.context.FacesContext;
    import javax.faces.event.ValueChangeEvent;
    import oracle.adf.share.logging.ADFLogger;
    public class TestBean
      private static final ADFLogger _LOG = ADFLogger.createADFLogger("view.TestBean");
      public TestBean()
      public void vcl(ValueChangeEvent valueChangeEvent)
        _LOG.severe("in the value change event");
        FacesContext ctx = FacesContext.getCurrentInstance();
        FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_ERROR, "This is a message", "Message");
        ctx.addMessage(null, fm);
    }adfc-config.xml:
    <?xml version="1.0" encoding="windows-1252" ?>
    <adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
      <managed-bean id="__1">
        <managed-bean-name>TestBean</managed-bean-name>
        <managed-bean-class>view.TestBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
      </managed-bean>
    </adfc-config>John

  • Default File Types in inputFile Component

    This is a two part question in regards to some usability issues with the inputFile component. First, I'm using the inputFile component to upload files; however I need to be able to default the allowed (or rather default) file types in the Browse window. Is there any way to do this?
    If not, is there any way to manually create inputFile type logic? For example, could we use our own inputText field and commandButton to upload a file? I'm not sure this is possible with the inputText field being a String and the inputFile being an UploadedFile type.... I've seen the same question asked in a thread that asks about creating a style and translating the text for the Browse button, but no one had answered it at the time of this post.

    .. playing around with this options it appears that browsers tend to ignore the accept attribute...
    "The HTML 4.01 specification defines an accept attribute for use with input type="file" as follows:
    which explaind by that the accept attribute only is a recommendation that browser vendors may or may not implement:
    "This attribute specifies a comma-separated list of content types that a server processing this form will handle correctly. User agents may use this information to filter out non-conforming files when prompting a user to select files to be sent to the server.
    Thus you could specify, for example, accept="image/gif,image/jpeg", if you are willing to get image files in GIF or JPEG format only. Browsers might use this information to set up the Browse menu so that only such files are selectable, at least initially"
    [http://www.cs.tut.fi/~jkorpela/forms/file.html]
    Frank

  • Help using af:inputFile component in table.

    Hi
    I am using Jdev version 11.1.1.5
    I am having below scenario
    I have a af:table bind to an ViewObject.
    In this table I want to provide a facility to upload a file in each row.
    In view object I will use a transient attribute to capture this file for each row
    After this i have a button on which I am calling a bean method where I will iterate through each row get the file for each row and write it to a different table..
    I have got some help how to use the inputfile component having code written in valueChangeEvent of the inputFile component.
    But I don't want to use valueChangeEvent instead I want to do it on button.
    What transient attribute type in viewObject should be used to capture this file in each row?

    This will not work. To pass the data to the vo you have to submit the data. One the form is submitted the data has to be read and stored somewhere. A transient attribute is not the right place to store this data as the data will consume lots of memory and your application might run out of memory.
    File or other binary data is stored in blobs in the db. The data type for this is oracle.domain.BlobDomain.
    You can upload the data for each row directly.
    Timo

  • Absolute Path issue with af:inputFile component

    Hi All,
    I am using an input file component and selecting a file from location "C:/temp.xml".In the code, I am trying to get the absolute path of the file selected and since the input type of this component is "UploadedFile", I have created a variable SourceFile of type "UploadedFile" this is what I am doing to get the path:
    <af:inputFile label="Source File" id="if1"
    value="#{viewScope.UpdateMetadataBb.sourceFile}"
    autoSubmit="true" required="true"
    showRequired="true"/>
    In the Bean:
    UploadedFile source = this.getSourceFile();
    File sourceFile = new File(source.getFilename());
    String path = sourceFile.getAbsolutePath();
    Now when I print the "path" it returns something like "C:/users/Swathi/appdata/roaming/..../text.xml" instead of directly giving "C:/temp.xml", Any ideas?
    Thanks,
    Swathi Patnam

    Hi Timo,
    As you said the InputFile component writes the file in the temporary directory but in my case it is not able to write it in the temp directory.
    I am using Jdeveloper11.1.1.5 and i have created an application and deployed on the SOA Server.Now when i try to get the file, it gives the file not found exception and it shows the path as :- javax.faces.el.EvaluationException: javax.xml.ws.WebServiceException: java.io.FileNotFoundException: D:/Oracle/Middleware/UserProjects/Domains/base_domain/abc.TIFF.
    I have implemented the same application and deployed on the integrated weblogic server and it is working fine but as i have deployed on the SOA Server then it is not able to write the file at the particular location.
    Is there any extra configuration which needs to be done while using the InputFile component on the managed server ??
    Even i have started the SOA Server with the admin rights but no help..
    Even i have used this parameter in web.xml file to store the file in another location but no help :-
    <context-param>
    <description>Directory to store temporary files</description>
    <param-name>org.apache.myfaces.trinidad.UPLOAD_TEMP_DIR</param-name>
    <param-value>C:/tmp/</param-value>
    </context-param>
    Please suggest!!!
    Regards,
    Shah

  • InputFile Component: Change Appearance

    Is there anyway to modify the InputFile Component? I want to remove the input text field that displays the file path, but keep the same functionality. Is this possible?
    Thanks,
    Tim

    Hi,
    no you can't. What you can try though, use Firebug to identify the ID or assigned style class of this file. Then add CSS to the page that hides the input field. My expectation is though that the upload button goes away too.
    Frank

  • The search service is not able to connect to the machine that hosts the administration component

    Hi
    After uninstalling the binaries, and reinstalling / joining back to the farm, everything seems happy expect search.
    When we try and start the Search Service back, it takes us to the Search Application section, and shows this message;
    The search service is not able to connect to the machine that hosts the administration component
    How can I get search to work again, or get around this error?
    I am pretty inexperienced with Search

    Hi  Tibsy80,
    For your issue, it can be caused by the search admin timer job was disabled.
    Run below PS command to know the status:
    Get-SPTimerJob job-application-server-admin-service | fl
    If it returns “IsDisabled: True”, ran below PS command to enable the service:
    Enable-SPTimerJob job-application-server-admin-service
    Then run below PS command to stop and start the timer and IIS reset:
    Net Stop timer
    Net start timer
    iisreset
    Then wait 1-2 min and try browsing to the SSA again.
    Reference:
    http://neelb.wordpress.com/2012/01/19/the-search-service-is-not-able-to-connect-to-the-machine/
    Also you can refer to the blogs:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/b04498ec-78d1-4bb9-8077-0481977cef10/the-search-service-is-not-able-to-connect-to-the-machine-that-hosts-the-administration-component?forum=sharepointadminprevious
    http://davidbajak.com/blog/post/2011/09/29/Fix-SharePoint-2010-Enterprise-Search-After-Using-AutoSPInstaller-Script-Installer.aspx
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • How to reset the value in valueChangeListener

    I would like to reset the value in a component to its earlier value in the valueChangeListener.
    Here is an example method in the bean:
    public void valueChangeListener(ValueChangeEvent valueChangeEvent) {
    Date oldDate = (Date)valueChangeEvent.getOldValue();
    Date newDate = (Date)valueChangeEvent.getNewValue();
    if(newDate > sysdate) {
    //valueChangeEvent.getComponent().WHATEVER.setValue(oldDate)
    } else {
    valueChangeEvent.getComponent().processUpdates(FacesContext.getCurrentInstance());
    Please suggest the code that I need to put in comments.
    Note: One way to achieve this is to bind the component to the bean and do a setValue. I do not want to do this(I have master-detail tables with many rows to edit. So, this resetting should be done at row level by fetching the current row on the selected table and set).

    public void firstNameChanged(ValueChangeEvent event)
    System.out.println("FirstName changed");
    System.out.println("old value = " + event.getOldValue());
    System.out.println("new value = " + event.getNewValue());
    String oldValue = (String) event.getOldValue();
    String newValue = (String) event.getNewValue();
    RichInputText firstname = (RichInputText) event.getComponent();
    RichInputText lastname = (RichInputText) JSFUtils.findComponentInRoot("EmployeesLastName");
    firstname.setSubmittedValue(oldValue);
    firstname.setValue(oldValue);
    lastname.setSubmittedValue("lastname");
    lastname.setValue("lastname");
    AdfFacesContext.getCurrentInstance().addPartialTarget(firstname);
    AdfFacesContext.getCurrentInstance().addPartialTarget(lastname);
    }

  • Resetting the date and time after the phone has be...

    Hi,
    I keep having to reset the date and time very time I turn my phone off. I was thinking it was to do with the battery so I fully charged it, turned it off then turned it on again and it asks me for the date and time.
    I only noticed this because I've had exams and I have to turn my phone off for them.
    Could it be a dying internal battery?
    I know with computers there's a BIOS battery that controls date and time. When they start to die the date and time are inaccurate.
    I'll have to find time to take it to the 3-Mobile shop either on Sunday or sometime next week if it is an internal battery problem.
    Thanks,
    Omar
    "A Jade stone is useless before it is processed; a man is good-for-nothing until he is educated."

    Hi omar3256
    I believe that there is a very small component on the motherboard which serves this purpose, although whether battery or sort of capacitor I am not certain. The N80 especially seemed to be prone to this failure.
    Happy to have helped forum in a small way with a Support Ratio = 37.0

Maybe you are looking for

  • Is there a better way to stop a Method than Thread.stop()?

    First my basic problem. In one of my programs I am using constraint solver. I call the constraint solver with a set of constraints and it returns a Map with a satisfying assignment. In most cases this works in acceptable time ( less than 1 second). B

  • Can't open a pdf file attachement to e-mail

    I canot open an e-mail pdf file attachment..I get a message You have chosen to open Invoice---pdf which is: Firefox HTML Document (479kB) What should Thunderbird do with this file? Open with Firefox (default) I do all of the above but nothing happens

  • Bridge for Newbie

    I can't find a Bridge forum, so I'll ask my question(s) here. I've been using CS3 for years and just subscribed to Creative Suite Cloud. I've never used Bridge; hardly even knew what it was. I just started exploring Bridge Cloud and am sold, though I

  • How can I make my page scroll to a specific anchor on load

    Hi! I have built a vertically scrolling page, but don't want my visitors to enter at the top of the page, but in the middle. How do I do this? Thank you, Charlotte

  • If i order online, how can i get vat return in UK

    I'll travel to UK in November, and plan to buy unlocked iphone5s online shipping to the hotel. I am not sure that how I can  do vat return in the airport? Or I need a vat form fot the tax return? Or it's better to buy in the Apple store, and SA would