Prevent the event of action af:fileDownloadActionListener

# Background

The following problem is also described in the: http://stackoverflow.com/questions/14638103/prevent-affiledownloadactionlistener-action-event

Using JDeveloper 11.1.2.3 to create a report download button using 'fileDownloadActionListener' as follows:
    <af:commandButton text="Run Report" id="submitReport">
      <af:fileDownloadActionListener method="#{reportBean.run}"/>
    </af:commandButton>
At the top of the JSF page is the following:
    <f:view afterPhase="#{validationBean.afterPhase}" ...>
      ...
        <af:form id="f1">
          <f:event listener="#{validationBean.postValidate}" type="postValidate"/>
The idea is that the bean Validation allows you to capture validation issues as follows:
    public void afterPhase(javax.faces.event.PhaseEvent phaseEvent) {
      if (phaseEvent.getPhaseId() == PhaseId.RENDER_RESPONSE) {
        FacesContext context = phaseEvent.getFacesContext();
        FacesMessage.Severity severity = context.getMaximumSeverity();
    
        if (isSevereError(severity)) {
          context.getExternalContext().getSessionMap().put(ERROR_FLAG_NAME, true);
        }
      }
    }
This works as expected. When the user presses the button, but the form has an error, the session variable "validationError" is set to 'true '. This should allow the frame avoid the generated report if the form parameters have errors.

# Problem

The session variable "validationError" is used by the run method of the bean the report as follows:
      public void run(FacesContext facesContext, OutputStream outputStream) {
        Object error = facesContext.getExternalContext().getSessionMap().get( ERROR_FLAG_NAME );
        
        if( error != null && error != Boolean.TRUE ) {
          Report report = null;
    
          try {
            report = getReport();
            report.setOutputStream(outputStream);
            configure(report.getParameters());
            report.run();
          } catch (Exception e) {
            if (report != null && facesContext != null) {
              report.publish(e);
            }
          }
        }
        else {
          facesContext.getExternalContext().getSessionMap().remove( ERROR_FLAG_NAME );
          facesContext.renderResponse();
        }
      }
When there is a validation on the page, the "facesContext.renderResponse ()" error; the code is executed, but the resulting web page is empty. Any exceptions are documented. No errors are generated.

# Question

One way to avoid this situation uses a button hidden, customized Java and JavaScript, as described in the following pages:

-http://jobinesh.blogspot.ca/2010/01/customizing-execution-of-to-validate.html
-http://tompeez.wordpress.com/2011/07/14/validate-data-before-export-via-afexportcollectionactionlistener-or-affiledownloadactionlistener/

However, this mechanism is complicated. The solution I have in mind will work if the page can be rendered as usual.

How do force you the page to render once triggered by the event "af:fileDownloadActionListener"?

Thank you!

Dave,

using a hidden button is the only option you have available today. I will drop an ER that fires an event to the listener fileDownload (kind of prior download) should allow you to cancel it by calling make response. As said, this does not yet exist and the hidden button is the option you have available (note that the download file tag is a tag of customer behavior and not a user interface component full, it is why there is no way yet to interrupt execution.

Frank

Tags: Java

Similar Questions

  • Events of action stops working

    Greetings,

    I was wondering what could interfere with the events of action?

    I have a few tabs in a JSF (11.1.2.4.0) page and they understand

    forms with navigation buttons that works very well.  When I drag and drop any other

    table as a form, even those that works very well on my tabs to work, their

    navigation buttons stop working, I click on them and nothing happens.

    It happen to me last year and I was wondering what it would cost?

    The only good that I know for sure, that is if the button have immediate true,

    most of the time will stop working. But it's just a fresh drug table and falling, without modification.

    I check the properties of the tabs and grouplayouts modifications by mistake and they are always the same.

    What else could cost a disfaction of button? more specific, and form navigation buttons?

    OK I found the problem and resolved, apparently for no reason, my function that is running the parameter when loading the page did not load correctly the data inside

    the iterator, I do not know why. I add a function to listener disclosure point detail that will run settings, and work fine now, thanks for the help.

  • How to prevent the opening of the popup submenu of mx:MenuBar during its events mouseOver/rollOver?

    I'm using a component mx:MenuBar with the xml data to a menu. The basic behavior as I see is, first by clicking on the top level menu item (IE on the horizontal bar), pop-up windows submenu opens. Then without clicking anywhere, if I have the mouse on / roll on the horizontal menu bar, the pop-up menus under other top level menus opens.

    This behavior seems to be incompatible. The pop-up submenus should open either on click any element of top-level menu (menu bar horizontally) or only on mouse over / roll of the menu bar.

    I want the pop-up submenus to open only when the click on the top-level menu (menu bar horizontally). So I added event handlers for the passage of the mouse as well as the rollOver events (I don't know which event gets actually produced on hovering over the menu bar horizontally). In the case of managers, I called the Event.preventDefault () method to prevent the default behavior (ie the opening of pop-up submenus).  But nothing works. I felt like I have no control over it.

    How to remove the default behavior and open the pop-up submenus only on the click event of the menu bar?

    Bar menus with no user action:

    1.JPG

    Menu after clicking the 'Flex ': menu bar

    2.JPG

    Bar menu after clicking the 'Flex' menu and hovering above the other top-level menus in the horizontal bar:

    3.JPG

    All,

    Go through the link mentioned to find the answer below.

    f-mxmenubar-Flex-during-its-MOU http://StackOverflow.com/questions/15532911/How-to-prevent-the-Opening-of-pop-up-submenu-o

    This solution works perfectly like what I expected.

  • How to detect a user action in the graphic palette with a node of the event?

    Hello

    is it possible to detect a user action in XY-Graph "graphic palette" with a node of the event?

    Thank you very much and best regards,

    Michael

    Hi Michael,

    you only need a toolset for all 6 graphs? Make your own with a few buttons (custom) and you're fine...

  • Prevent the structure elements of the queue of the event?

    Is there a way to prevent a record structure and the queues of the events of the event?

    I have a state machine with a structure of the event in one of the States - the State is waiting for user input before continuing - and I wish that the structure of the event to recognize the events only when the program is in this State. I understand that the current method to catch all events is sometimes (usually) the desired behavior... Heck, I use it to my advantage most of the time. However, this is not one of those times.

    Here is a small example of my configuration:

    (See attachment. I guess that's too big for an extract VI, so it is a standard PNG image)

    The question that I have, is that the Structure of the continuous event of events Records even after pass to the next State. This means that if 'String' is changed at any time, the next time the queue of event happens in the state machine, all updates of the "chain" will run.

    So, how can I implement the code in such a way so that the events will be only intercepted and queue when the structure of event loop is running?


  • Column reorder the event listener and prevent the reorganization in FX 8 column in tableview

    1. how to prevent the tableview FX8 reorganization column. which API to use if necessary.

    2. how to add a listener for tableview on the reorganisation of the column. I want the event fires on the reorganization of the column. Please sample.

    Thank you.

    1. how to prevent the tableview FX8 reorganization column. which API to use if necessary.

    There's a JIRA for this at https://javafx-jira.kenai.com/browse/RT-24669

    According to who, there was to be an impl_ FX8 for reorganization enabled property, but I can say that it is not in. I think that the decision was to incorporate this into something more complex (ability to move only some columns or rearrange column groups, etc.), which will be included in a future release. See also https://javafx-jira.kenai.com/browse/RT-27566 and http://mail.openjdk.java.net/pipermail/openjfx-dev/2013-January/005177.html.

    2. how to add a listener for tableview on the reorganisation of the column. I want the event fires on the reorganization of the column. Please sample.

    Just add a ListChangeListener to table.getColumns (). Unfortunately, the change is not reported as a permutation, but as a combination of adding and removing columns (I suspect that it is because a permutation is a risk that there is a point where the same column is included twice in the list of columns, which would violate the rules of the graphic scene). But basically, you do:

    table.getColumns().addListener(new ListChangeListener>() {
         @Override
         public void onChanged(Change> change) {
              // table columns changed, perhaps due to reordering...
         }
    });
    
  • Adobe InDesign - content overlay Web - prevent the spread of events Scroll

    I have an InDesign magazine that contains a Web Content Overlay (pointing to a responsive website). Everything works fine apart from when it comes to scrolling.

    I run the magazine from an iPad via Adobe Viewer. Is not only the scrolling vertical (up and down) is necessary, horizontal.

    Problem

    When user left or right moves, changing page of the magazine and web content firm.

    Question

    Is it possible that I can stop the scroll events from spreading until the magazine of the overlay of web content? Preferably, it would happen on the web content itself (for example using JavaScript) as it would mean only, I need to change in one place, rather than on each page, the web content.

    Attempted

    Captures the touchmove on the body of the page and calling stopPropagation() on that event.

    Call preventDefault() on the event (this prevents any scrolling at all).

    With the help of pageX touchmove events and call preventDefault() all those who seem to be horizontal scans (too unreliable).

    With the help of CSS overflow-x: hidden

    jQuery scroll personalized Mobile events.

    A little addition to combinations of the above.

    Found a solution. First, insert a ' ' tag 'window' in the head:

    Note that I've set a static width of '701', it's important. Width of the overlay of web content is "700px". Set a width of "701" means that the page can move very slightly. This agitation means that the left/right scan is taken and not percolated to InDesign. There is a slight delay (of a pixel) if they drag, but it's minor compared to the new page.

    Then add the following in your page CSS:

    . Happy {}

    -webkit-too-full-scrolling: touch

    }

    You should not have this CSS, but it was necessary for us.

  • Prevent the default behavior of the events

    How can I prevent the default behavior of the events?

    I know that this concept of JavaScript or ActionScript where you can prevent the default behavior of an event by calling e.preventDefault ().

    How can I achieve this in JavaFX?

    For example, I have a KeyEvent on a TextArea and want to intercept the Enter key and stop him to position the cursor in the new line.

    I tried consume(), but apparently, it's the equivalent of e.stopPropagation ().

    TextArea has a bug on the management of mouse events: http://javafx-jira.kenai.com/browse/RT-17902, whereby scrollpane transmitting text editable eating events and if the events are not exposed to users of the API, do not know if this will have an effect as the key to transformation of the text box you want to perform. If the question in 17902 is at the origin of the text box does not correctly answer the treatment of key events defined by the user, you can add an additional comment to this Jira to see.

    Information on the management of events can be found here: Re: event bubbling smile of understanding

    If the TextArea event management worked properly, you should probably be able to do what you want by adding an EventFilter on the text box and consuming of the event you want to capture. Do this in an EventFilter so you can intercept the event in the capture phase is best to try to do it in an EventHandler for the propagation phase. If try to consume the event in an EventHandler, it may not work because the event may already have been handled by the target node or the children of the node target.

  • Mobile IconItemRenderer - prevent the spread of the events

    Hello

    I don't want anything to be taken when an item is clicked or touched in a mobile itemRenderer that extends from IconItemRenderer.

    The drawBackground method override Isteand and do not to listen to the event of change, is anyway to do it faster, as preventing the propagation of the event?

    Thank you.

    You should be able to set mouseEnabled/mouseChildren false on the rendering engine, or call preventDefault() on the mouseDown event.

  • How certain actions between received the event and related events

    Hi all!
    Sorry my bad English :(

    I want to review the event data (to compare with the form of java method courses) after the event received and match, but before he bound.
    How could I do?

    Have you checked RCD_VALUE?

    You have Network KEY and you can extract the data from table RCD with this NCE KEY.

    ignoreEvent will not work in your case because it is not a custom connector.

  • Boolean switch until released by using a structure of the event

    I use a Boolean control with mechanical action to activate the button, I want to return to the original state.

    I use it in a structure of event defined to trigger a change in value. The action to push the button generates two events in the State on one and the other for when he returned to the stop State.

    How can I control this to prevent a single event is triggered and the second event which is put on hold until is ignored, I want the button to return to the original state and not to execute the code twice.

    Thank you

    Jim

    Right, I should have told latch.  Do not forget to place the control button somewhere it will be read to reset the latch.  It does not need to be connected to anything, just read.  Sitting inside the case of the event is very good if you do not use anywhere elsewhere.

  • Prevent the digital signature if the fields are white

    I am just checking that some fields are filled before the user can digitally sign the form. If the fields are empty, I would like to prevent the display of the digital signature window.  How do I do that?

    Here is my script:

    var vSignature
    if(xfa.form.form1.execValidate() == true){
     vSignature = this.rawValue;
    }
    else{
    xfa.host.messageBox("At Least One Required Field Was Left Blank");
    }
    

    Add controls null (or no matter what field validation that you plan to be completed) in the event the digital signature field preSign, if the validation fails then cancel the action after providing a message

    You can attach your form?

    Santosh-

    http://about.me/nskumar

  • Prevents the application to be modified after being approved

    Hi all

    Senario:

    Prerequisites:
    There is a resource configured on IOM A and it is available to ask
    The approval process requires two levels of approval: 1 the User Manager and the 2nd the authorization object

    Manager1 is the Manager of User1
    Authorizer1 is the purpose of the authorization for resource A


    1 - User1 initiates a request access to resource A to itself.
    2 - User1 must enter information before submitting the request and we denunciations considers the level of access to his account on resources. He chooses the level of 'single user '.
    3 - Manager1 receives an approval task and approves it.
    4 - Authorizer1 receives a task approval, but, for some reason, takes any action. (It is not in the office today)
    5 - User1 goes back to the request and replaces its access level 'admin '.
    6 - Authorizer1 comes back the next day and approves the request.

    Problem: Only approved Manager1 because at the time he checked demand the access level is set to 'single user '. He would not grant admin access level.

    Questions (options):
    (a) is it possible to prevent the application to be modified after being approved by Manager1?
    or
    (b) is it possible to send the application for approval to Manager1 if there was no change once it has been approved?

    Thanks for an overview.
    Adriano.

    There are several solutions to this. See below:

    - Either remove editing permissions for ALL_USERS of the shape of the object. If your end user would not be able to update the details of the application once it is submitted. In case the desire of the user to change the data, then it can send an email to manager to do. But the end user cannot do itself. See tab the form designer to apply permissions to objects of. It must have an entry for ALL_USERS. It is an immediate solution to your question with 0 effort.

    - Or if you specifically want that after approval only, the form data should not be updated. Then create an adapter of the entity that verifies whether or not the request is currently underway with the Manager. If this request is not with the Manager then this entity adapter throws an error shows that the application has been approved by the Manager, so it can not be changed. This would require changes as follows.

    a. you must include 2 additional fields hidden in your application form which contains the requestId and UserID. Once the end user submitted the application, you must assign this form requestID requestId field generated at the time and the other IOM userID field. You can do this with a task in the approval process by using the API of IOM.

    b. now create this map of the entity. It will have 2 variable reqId and userID. You get these attributes and IOM API check is pending with the Manager of the user request. This adapter returns true or false. False, add an error handler task.

    c. attach this adapter on the event before update of your form in the object data manager.

    Now if after approval of level 1, the final user tries to update the form, it displays an error in the format of the IOM ' as the request was approved by the Manager, so it is not editable '

    This should solve your problem.

    Thank you

    Sunny

  • I use to manage my DSL modem via an ip address. When I enter FF8 I wonder where to save the file. Why and how can I prevent the FF8 to do this?

    I use to manage my DSL modem via an ip address. When I enter FF8 I wonder where to save the file. Why and how can I prevent the FF8 to do this?

    And now, whenever I'm in an ip address that I wonder if I want to download the file.

    This happens when the modem server does not send the file in text/html, but with a different MIME type.

    I tried adding index.html in the event that the server can send this file as text/html.

    If your DSL modem has a support Web site, then you can try asking it there advice on how to configure the server modem.

  • a problem is preventing the resolution of problems starting

    My Lenovo P500 was working fine until yesterday morning.
    Since the opening of my pc yesterday morning, there is a problem. I could not connect to the network and audio system was also not working.
    'Network and sharing Center' in the Control Panel indicates "dependency service or group was able to start.
    I tried to solve the problems, but the problems said "a problem is preventing the troubleshooting tool to start.

    My system is Windows 8.1 64 - bit. Never formatted the system since I bought it in 2012

    razendra wrote:
    I remember the command, it does not work. Same mistake. "Error: 87.
    Cleaning-image option is unknown.
    I think it is a malware attack. The event log service is also unavailable.

    I suggested in post 4 on this subject and you answered that it is clean.

    For a quick solution, rather analyze what happens, try to back up your data and initiate the restore of the system through the key NOVO OKR. It should restore your unit to factory default. Note: after this, you will have to reinstall all the third-party program that you understand your data.

Maybe you are looking for

  • Power supply drive hard 320 is death - where to find replacement?

    Hello The power supply for my 320 GB external hard drive (PX1223E - 1 32) that I bought a year ago died. I'm a little annoyed that the player has been barely used and only just out of storage after a move of the House! Can anyone help to track down a

  • Title iMovie speed

    I use iMovie 10.1 on my Mac. I would use the title theme "far far away", but it goes too fast for an average man to read everything. I would like to slow down, but no speed choices appear to be available in the menus. Am I out of luck? Can't slow dow

  • Satellite P30 closing

    I got my 30 P for about a year now and after a game or watching a DVD for an hour it stops. After reading a lot of posts in this forum, it is clear that Toshiba laptops are prone to overheating and this is how the system protects itself from total ex

  • Scripting: Can drop us a control of the money?

    It is possible to drop a new money controls uses VI Scripting? The ID of the Style of a classic Cluster is 3400 and a modern Cluster is 21607, but when I read the property ID of Style of a cluster of disengaged manually money I see 21607. I also try

  • Message of support HP _re old version of windows

    I managed enhanced W8 to 8.1 W on my new HP Pavilion Touchsmart 15 laptop PC. Now I'm in a quandry on a message that appears in the HP Support Assistant. What what can make this old version of windows be on my C drive? I certainly don't want to delet