InputFile value lost after the validation fires

Hi all

I use Jdeveloper 11.1.1.5.
I have a date. MinValue, InputFile and a commandButton control.

Requirement: -.
1. the user will select the file using the InputFile component, and then he clicks the command button to process the file.
2. but if the date value. MinValue is null, the system will display an error message that the value of Date entry is necessary. (Note:-c' is just an example, the scenario real business contains a complex logic here).
3. If the value is available in date. MinValue, the system will process the file.

Now the problem is that if the user selects the file & directly click on the button, then as the component date. MinValue does not contain a value, it will show a mssage error, but at the same time the inputFile changes through update.
Now, if the user selects a value in the date, and then he clicks the button, the value of inputFile in my managed bean will be void. Given that the user is nt going to browse the file again. In any case, there should be a way to get the value of the inputFile.

This is my code jspx: -.
< af:form id = "f1" usesUpload = "true" binding = "#{backingBeanScope.PanelSplitterBean.f1}" >
< af:inputDate label = "Label 1" id = "id1" binding="#{backingBeanScope.PanelSplitterBean.id1}"/ >
< af:commandButton text = "commandButton 1" id = "cb1" action ="#{backingBeanScope.PanelSplitterBean.executeFile} '"
partialSubmit = "true" binding="#{backingBeanScope.PanelSplitterBean.cb1}"/ >
< af:inputFile label = "Label 1"id = "if1' valueChangeListener =" #{backingBeanScope.PanelSplitterBean.getFile} ".
Binding="#{backingBeanScope.PanelSplitterBean.IF1}"/ >
< / af:form >

This is my bean managed code: -.
file UploadedFile private;
private text RichInputText;
private RichInputFile if1.
private RichCommandButton cb1;
private RichInputDate id1;
private RichForm f1;
private RichMessages m1;
private RichDocument d1;
private UploadedFile fo;

{} public void getFile (ValueChangeEvent valueChangeEvent)
Add the code in the event here...
file = (UploadedFile) valueChangeEvent.getNewValue ();
}

public String executeFile() {}
Add the code in the event here...
try {}
Here, it may be any postings business logic
{if (ID1. GetValue () is nothing)}
FacesContext.getCurrentInstance () .addMessage (id1.getClientId (FacesContext.getCurrentInstance ()),
new FacesMessage (FacesMessage.SEVERITY_ERROR,
"The date is requested."
"Please enter date"));

}
else {}
Gets the file with the null value if the validation of Date fires once.
System.out.println (file. GetFilename()); +
}
Returns a null value.


} catch (Exception e) {}
TODO: Add catch code
e.printStackTrace ();
}
Returns a null value.
}


Why the value of the file takes the value zero, if validation is triggered. Because either way, the user will fix the error and then click the command button? This point of time, that value will be nil in the object file.
Is it possible to keep the inputFile value?

Please think!

Kind regards
Shah

Well, look more closely your still not formatted code shows you use support beanScope to store the value of the downloaded file. Problem is that after clicking on the button, the bean is killed and (now empty a new) is created. A reason to get rid of the link moer automatic usles in a bean!
You should take a look at https://blogs.oracle.com/groundside/entry/the_uimanager_pattern and store the values in a uiManager bean that you inject into the bean application scope that manage you the logic.
I used a xxyyzz bean in the scope of the application to manage the logic


private static ADFLogger _logger = ADFLogger.createADFLogger(Xxyyzz.class); 

   public String handleUpload() {
        //Here it can be any business logic validations
        if (getUiManager().getUser() != null && !getUiManager().getUser().isEmpty()) {
            //Gets the file as null if the validation of Date is being triggered once.
            String name = getUiManager().getFile().getFilename();
            _logger.info("Information" + name);
        } else {
            FacesContext.getCurrentInstance().addMessage("it1", new FacesMessage(FacesMessage.SEVERITY_ERROR, "Input is required", "Please enter data"));
        }
        return null;
    } 

    public void handleGetFile(ValueChangeEvent valueChangeEvent) {
        getUiManager().setFile((UploadedFile)valueChangeEvent.getNewValue());
    } 

    public void setUiManager(UIManager _uiManager) {
        this._uiManager = _uiManager;
    } 

    public UIManager getUiManager() {
        return _uiManager;
    } 

the uiManager bean


import org.apache.myfaces.trinidad.model.UploadedFile; 

public class UIManager {
    private UploadedFile file;
    private String user;
    public UIManager() {
        super();
    } 

    public void setFile(UploadedFile file) {
        this.file = file;
    } 

    public UploadedFile getFile() {
        return file;
    } 

    public void setUser(String user) {
        this.user = user;
    } 

    public String getUser() {
        return user;
    }
} 

and the code page of the user interface



                
                
                
               

The installation program of the bean in faces-config. XML



    uiManager
    de.hahn.xxyyzz.UIManager<;/managed-bean-class>
    session
   

the injection into the bean xxyyzz


  
    xxyyzz
    de.hahn.xxyyzz.Xxyyzz<;/managed-bean-class>
    request
    
      uiManager
      de.hahn.xxyyzz.UIManager<;/property-class>
      #{uiManager}
    
   

So your use case works as you expect.

Timo

Tags: Java

Similar Questions

  • APEX_ITEMS does not store the value in the SESSION after the validation error

    Hello

    I'm build dynamically using APEX_ITEMS, but it does not keep the value when the page is submitted and the validation error occurs. Here are the following steps that I am following.

    When I enter SUE (more than 8 characters), SUBMIT, validation fails and the error is displayed on the page (which is fine)
    BUT it does not keep SUE value (which I got) and filled with the old value which is ABC.

    WHY it does not keep the value that the user entered (even as the normal Page items)

    Region PL\SQL
    declare
      v_value varchar2(20);
    begin
      v_value := 'ABC'; 
      htp.p(apex_item.text(7,v_value));
    end;
    Validation (function returning the error text)
    DECLARE
     v_count number;
     v_value varchar2(50);
     v_value1 number;
    BEGIN
      v_value := apex_application.g_f07(1);
      select length(v_value) into v_value1 from dual;
    
          if v_value1 > 8 then
              return 'Field must have less than 9 character';
          ELSE
             return null;
          END IF;
    END;

    You use collections if you want the State to show if, after a validation error. Unfortunately, this is the case if you do not use the normal tabular forms.

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Apress.com/9781430235125
    https://Apex.Oracle.com/pls/Apex/f?p=31517:1
    http://www.Amazon.de/Oracle-Apex-XE-Praxis/DP/3826655494
    -------------------------------------------------------------------

  • Application process, do not run after the validation error

    Hi all.

    APEX 4.1
    XE 11 GR 2
    WIN7
    Firexfox

    I have a page where I add additional javascript code to a page by using htp.p in a process of application "before the footer. It works fine as long as there is no validation error. When the validation fails (for example a UK-check with the location of the error value "Inline notification"), the page is re-fondue, but the application process is not running and so my extra code is missing from the page.

    Is this intended behavior or am I doing something wrond?

    Andreas

    Addition:

    I tried the sam using a 'local' page process, but these do not seem to fire.

    Published by: Andreas Weiden on 22.12.2011 21:31

    Andreas Weiden says:

    Is this intended behavior or am I doing something wrond?

    This is the expected behavior. Generally, the process and calculations source item, the actions are not executed when the page is re-made after validation errors. They also provide great potential for confusion of side effects (for example reset to a default value for an item that had an invalid value sent).

    However, the engine provides a special treatment for the process with the built-in Inline Validation errors displayed condition so that they will be run when a page is rendered with validation errors. See + {: identifier of the thread = 493070} + for an interesting discussion on this topic.

    An alternative (and in my opinion a more classic and rather more clear) would be to generate the JS in a dynamic region of PL/SQL code on the Page zero. Always reuse the code on all or several pages, but is more clearly part of the rendering of the page as an application process and does not rely on a very obscure condition, being the only way you can make it work.

  • Module CVI written TestStand property, property value resets after the step execution.

    Hello

    I did a lot of research and find nothing relevant to the question that I have. I've created a DLL in CVI containing several functions I call TestStand. I also created a type of step customized for each function call. Every function in the DLL has a runtime version and a version edit-time. Time edition features each have a UI associated with them are called from teststand. Change these functions are placed in the custom under the heading "change" step step-type tab Before executing a sequence with these custom steps the edit-time user interface is launched to allow the user to input values that will be passed to the run function. originally, I tried to set up my functions as a 'post step' step in the step properties. However, the sequences would fail to run because the parameters of the step module was empty. Then, I selected CVI as the adapter in the step properties and specified a default module for each type. This filled the tab module settings step like I wanted. However, when I ran the sequence each function execution of measures was called twice, once for the stage of the post, and once for what was in the tab module I suppose. I then re-entered the types of step and deleted all the steps of the post office. I thought that all the problems have been resolved at this point, however, after doing some more extensive tests I always have a bug, I was unable to get rid of that.

    The problem is that two of my step types have to write data to current TestStand to execution after they ask an external device for IT. I know that the query works because my log text that generates the DLL displays the correct values. However, the data are not get rewritten on TestStand correctly. In the enforcement functions after checking the valid data has been returned, I try to write to TestStand using: "TS_PropertySetValNumber (seqContextCVI, NULL,"ThisContext.Step.ParameterValue.NumericParameter", 0, (double) ushortint);" »

    I checked that this call generates an error and also used the TS_PropertyExists method to check that I had the correct search string. These extract so I added then another command that reads the value written to TestStand two return immediately after to write it. I printed this in my log file and found that the value is written to the property of TS. So, the problem is that TestStand is defining the property to reset after the code module is running. How to prevent this?  

    Thanks for all comments, let me know if anything specified needs.

    Josh Meyer

    Well, I came to the conclusion that my 'problem' is not really a problem. I had a bit of a basic misunderstanding of the works of TestStand (I don't actually use it, I am writing just a code which will bring an existing one of the tools of the features inside the TS).

    in any case, what I learned is that these properties are retained (so you can set up a sequence, save it, re - open and be able to run it without any reconfiguration for example), when you write to a property when installing editting/sequence. The run time values are not preserved (if connected) because they are only required to carry out. For example, if a user calls one of these functions to extract value from a controller, they probably do so because they want to check the value, it's what they expect it to be. Rather than watching the value after execution (which is what I me assuming they would do), they would set up the step after step "read value" to test the value that it returned. This value is available in 'RunState.PreviousStep.valuename' in the downloaded step step "read value".

    Hope that I did not confuse anyone a lot, I'm completely new to TestStand.

  • WebCenter content get lost after the redeployment of the application

    Hi all

    We have a portal web Center running application to our company. After it has been deployed in the production environment, a member of the admin team added some content on some pages using the Oracle WebCenter Portal administration Console. Now, there are a few requests of change that we are working on the same application. Every time we complete the change and it is deployed to the integration and Production environment, content published by the administration team is lost. They are having to redo this content on this page on any redeployment of the application. It always happens in integration / prod environment. Is there a way, that when redeploy us the application, we do not replace the content already added to the pages of the application?

    Or do we need to perform the same content in the Jdeveloper environment and produce some deployable for this be packed with deployment files? Please let us how we can resolve this situation. Thank you.

    Kind regards

    Anitha

    Hi all

    We found what was the problem that was causing the above behavior. According to the guidelines of this doc (WebCenter portal deployment: Applications Framework - 11 g Release 1 (11.1.1.6.0)), all content added to the pages, should be retained even after the redeployment. Only changes made to the navigation model must "round-trip on development." Added content on the pages after that initial deployment runtime does not "round-trip on development."

    The question was essentially in the way in which the application has been deployed. Each time, the new version was to be deployed we were not deployment out the version of the application and the deployment of the new version. Now, we have used "Redeploy" option to deploy the release. This fixed our problem. The content is now kept after the new deployment version too. It was also important to use the same MDS and Partition repository for deployment after the addition of the duration of the content to the pages.

    Kind regards

    Anitha

  • Some ESX4 configurations are lost after the reboot of the system

    Hi people,

    I use ESX4 server for months.

    Lately, after creating a few Pools of resources (RP) and the addition of virtual machines in the pool, I noticed that after rebooting my system, I lost all the Resource Pools, I created.

    This problem of loss of configuration is not only limited to the RPs, I also lost some of the configurations of the network/portgroup after system reboot.

    This problem is is produced as well when I entered "Maintenance mode" and then then rebooted the system;  and also when I typed the command "reboot" in the bash shell (I typed 'reboot' command 'sync' several times before typing.)

    This problem becomes a kind of annoyance since I have to re-create the lost configuration each time that I reboot.

    Is it possible to manually force the ESX4 to save the configuration for that I do not keep losing part of my configurations?

    Could someone please help?

    Thanks in advance.

    Danny

    Really glad its sorted for you, as I said, I saw the question before at a customer's site and you will never know that the root is full, except if you look in the service console. It would be good to have this visible through the vi client, but in the meantime it just added monthly controls!

    Thank you

    Dan

  • How keep radiogroup verified to the tabular report after the validation error?

    Hello!

    I have a tabular report with radiogroup fields, and when I try to send the page, if the validation does not pass by, my radiogroup fields unchecked.

    Does anyone know how to prevent this?

    If I can't fix this evil must pass the JavaScript validation.

    I use the version 4.2.1 of the apex

    EgaSega wrote:

    If I can't fix this evil must pass the JavaScript validation.

    ZAPEX wrote:

    There is no harm in using JavaScript validation to proceed with it.

    You can not 'show' validation JavaScript, and there is a lot of prejudice based on this alone.

    JavaScript validation can be used in addition to the validation server-side such that it can easily be turned off or bypassed in the browser. Any JavaScript validation in the browser in order to improve the user experience needs to be duplicated on the server to ensure that the controls provided have been performed.

  • Warning message after the validation stage

    Hello
    In the error message on the validation step, I put:

    < script type = "text/javascript" >
    Alert ('Invalid Date');
    $x ($v ('P5000_DATA_CAD_INI')) .focus ();
    html_GetElement ('P5000_DATA_CAD_INI'). Focus();
    < /script >

    but the Don t of development work...

    Thank you

    You posting about "P5000_DATA_CAD_INI" and you try to set foucs on the element even if the validation fails? If so it will not work, because "script error messgae" runs before the element renders. If "Error script messgae" cannot found the element 'P5000_DATA_CAD_INI '.

    If you want to set any other element which sequence number is less than that of the 'P5000_DATA_CAD_INI' element, then you can see 'Error messgae script' set focus correctly. Even to do this, you must set "-> Page attributes-> cursor Focus display attributes" to "don't focus cursor.

    Kind regards
    Hari

  • How to lock before the send in pdf form but AFTER the validation check

    I have this javascript on my form submit button, (who submits in pdf format).

    Form1. MainPage.Submit::preSubmit:form - (JavaScript, client)

    If (form1.execValidate () is true)
    {
    Form1. MainPage.Submit.presence = "invisible";
    Form1.access = "protected";
    }

    The problem is that I don't want the form fields to be protected until all of the fields have been validated.  After validation, I want the whole pdf locked before the pdf file is submitted.  I have this script the submit events, but he doesn't know the "form1.access ="protected "; "code.

    The PDF can not lock until all required fields have been filled.  It must lock before being submitted so that the recipient of the form may not change it.  I really try to avoid to have 2 buttons submit or a solution along these lines.  I am at a loss, why I can't get the fields to protect inside the script of "If"?

    Hello

    I don't know why the preSubmit isn't catching the change access. Maybe it's too close for the submission process. You would it be in the mouseUp event of the submit button. It fires immediately before the click event, so should be completed when starting the submission process.

    if (form1.execValidate() == true)
    {
         form1.access = "protected";
    }
    

    Note, however, that this locks everything, including the buttons. Once access is changed to protected you will have no way to change back to open, unless you build in a mechanism.

    All of the solution of Paul is preferable, because it keeps it the buttons open, that would be better that the bid may fail and the user may want to resubmit. There are ways around that as well. Overall, I always recommend the solution of Paul.

    There is a screenshot and explanation here: Re: fillable recording not fillable PDF

    Hope that helps,

    Niall

  • Disk space lost after the restoration of Bootcamp - El Capitan

    Hello

    I've created a Partition of Windows 49 GB using Bootcamp and then tried to restore the partition after. To restore the partition that I got a message error "your drive could not be restored to a single partition. Since then, I have "lost" the 49 GB of space.

    I checked the similar thread, but I'm not sure on what to do to fix this. Outputs of suggested controls are as follows:

    I can see on the screenshot on the bottom the 49GB, but do not know how to release.

    I tried running in Recovery Mode and diskutil repairDisk disk0 disk utility but this has not resolved.

    Any help would be appreciated!

    Thank you

    You will temporarily lose the HD recovery. Please backup OS X.

    1. merge the HD recovery in OS X. The order of the disk slices is essential in the following command.

    diskutil mergePartitions jhfs + "Macintosh HD" disk0s2 disk0s3

    2. in disk utility, expand the new OS X partition to cover the entire disc.

    3. re-install OS x and recover your Recovery HD.

    If you are comfortable with the Terminal commands, then

    1 backup OSX and all of your files - use Time Machine to back up or restore your Mac - Apple Support .

    2. boot into Internet recovery (CMD + Opt + R) - OS X: on OS X Recovery - Apple Support .

    3. click on Utilties-> disk utility and erase your entire internal drive.

    4. restoration of OSX and your files - use Time Machine to back up or restore your Mac - Apple Support .

    This requires another external drive that can accommodate TM backup - backup disks that you can use with Time Machine - Apple Support .

  • Start Windows lost after the partitioning of the disk next to Mac!

    Hi, I've lost my windows boot after creating a small new partition in disk utility. Could someone help me pls?

    Can you post the output of the following commands in OSX Terminal?

    diskutil list

    Cs diskutil list

    sudo TPG - vv - r see the/dev/disk0

    sudo fdisk/dev/disk0

    The "sudo" commands will prompt to enter your password, and there do not appear to come back. You can also see caution against improper use 'sudo' and the potential loss of data due to an "abuse" of the order.

  • Animations in the taskbar are lost after the installation of Windows 7 Service Pack 1!

    Hello

    Today I installed Windows 7 Service Pack 1. After you install the service pack, all the animations in the taskbar are lost! I tried to restart the computer 2 times, always the same.
    Then, I uninstalled SP1. The animations are back! Now I tried to reinstall SP1, and the animations are lost again! I want to have the SP1 and animations.

    Help, please!

    Marko Calasan.

    Hello

    ·         Are you referring to the Aero features in Windows 7?

    I suggest you run the aero Troubleshooter and check if that helps resolve the issue.

    See the link below to open utility troubleshooting Aero.

    Open the Aero Troubleshooter

    http://Windows.Microsoft.com/en-us/Windows7/open-the-Aero-Troubleshooter

    See also:

    Guided Help: Troubleshoot aero in Windows 7

    http://support.Microsoft.com/kb/976170

  • Home field after the validation error

    Using Application Express 4.2.5.00.08

    I created a validation for each required to shoot the submit button field. If a field is NULL, the error message 'field is required' online is displayed.

    If an error occurred, is there a way to put the cursor in the field associated with the error? Currently, it returns the first field at the top of the page.

    Thank you very much

    Validation_Error.png

    Hi HRSysAdmin,

    Your answer is already given by fac586 in the very next post the question. Although there are a few minor changes to the solution.

    fac586 wrote:

    HRSysAdmin wrote:

    Using Application Express 4.2.5.00.08

    I created a validation for each required to shoot the submit button field. If a field is NULL, the error message 'field is required' online is displayed.

    If an error occurred, is there a way to put the cursor in the field associated with the error? Currently, it returns the first field at the top of the page.

    Do the a Page Load Set Focus dynamic action with Selection of Type jQuery Selector and jQuery Selector defined value on :input.apex-page-item-error:first .

    Here are the changes made to the fac586 solution:

    • Go to the Page attributes-> display attributes-> Set Cursor Focus not cursor focus

    Why is it necessary? As it is set by default to the first point of page bothers our dynamic action set out below and, making it useless.

    • Here is the dynamic action proposed by fac586

    Here, the change is jQuery Selector is passed to input.apex - page-point-error: first to .apex-page-point-error: first as the prior takes the elements of entry into consideration, what happens if the first element on which the error occurred is a textarea or select list. For more information, see jQuery selectors.

    jQuery is a powerful javascript library when it comes to complex interactions between the user interface. You should save some time to learn the basics.

    Not to mention that the solution of Reema is not relevant because it proposes to transfer validation logic in javascript.

    I hope this helps!

    Kind regards

    Kiran

  • Metadata of Geotag lost after the publication on Flickr

    I added geotags to photos in Lightroom 6 after that that they were imported. GPS coordinates appear in the section of EXIF metadata. Here's the psd, tif and raw files. When I use Lightroom to publish on Flickr, the location is lost on Flickr. I tried to synchronize metadata in Lightroom and then reissue but has not made a difference. Is this a bug or I'm doing something wrong or feature until that just isn't there?

    Go to the privacy settings on your account page: https://www.flickr.com/account/privacy/. Ensure that import EXIF location data is set to Yes.

  • quality icon lost after the backup

    Hello world

    I created a few trays icon in illustrator size 16px and I saved it in png.

    Uploaded on photoshop and save as ICO.

    This process makes the icon lose quality.

    Even just save as png since lost half of the details that make a good icon.

    Does anyone have a better way to have an icon of good quality in the end?

    Thanks in advance,

    Ana

    Well, you can always design in Illustrator. But certainly turn on preview pixelated and align your shapes to the grid. They may need an extra in Photoshop clean after that you export, as well.

Maybe you are looking for

  • Disabled in Windows XP administrator account

    I disabled the administrator account in Windows XP (do not think), and my other accounts have been locked. When I try to log in as Administrator via CTRL-ALT-DEL, I get a message stating that the account its been disabled. What should do? Or the driv

  • Smartphones blackBerry BB 8520 ringtones

    I don't get a beep when I receive an e-mail message. I get a very short beep for a text. Is there a way I can manage ringtones so I can choose a tone for each function. It's the email text and phone call. Thank you

  • My HP Officejet 4500 printer install problem

    My HP Officejet 4500 printer keep installation on HP Pavilion dv6 workstation even if it is already installed all day

  • external enclosure for lightscribe DVD burner

    I have an old Pavilion dv7 that burned, but I really like the CD/DVD Lightscribe burner and want to convert it to an external burner for use with my new laptop. Is there a case external caddy appropriate or recommended on the market that fits this di

  • Adobe dc on server 2008r2

    HelloI'm trying to install Adobe DC via Group Policy. I have done several times before. I have a problem when the selection of the OS, I select the Server 2008 R2 but only get option 10. XXX Reader. I want DC. Can I just select Windows 7?