Execute java script in action listener before action

Hi, I have af:commandButton on my page , in its actionListener method I call java script
which displays af:popup with two buttons, I want to execute af:commandButton's action method with some program logic in depend of which button in the af:popup is clicked. The problem is that action method is execute before my java script to show the af:popup.

Hi,
the reason is that the JavaScript that you execute from the ActionListener is not executed before the page (or page section) is rendered, which is in the lifecycle is then after the action method is invoked.
However, I am observing on this forum that users think of JavaScript as a silver bullet, whereas it should really be seen as second choice only. If you want to execute logic in respect to which button a user clicks, then the code should be assigned to the button and not handled by some JavaScript. If - in combination with popups - you need to use JavaScript, then have a look at using the client listener for this (af:clientListener). Idealy you use the server side af:showPopupBehavior.
As a rule of thumb: always try to go with best practices and not with the easy catch
Frank

Similar Messages

  • Executing Java script while dragging a component

    Hi,
    Is there a way to execute Java script while dragging a component, I have noticed only following events mouseMove, mouseOut, mouseDown mouseUp for clientListener tag. could not find anything related to dragging event.
    My scenario is, I have componentDragSource to a component and I want fire a java script event on drag of that component.
    Please suggest. TIA.
    Thanks,
    Siva G.

    Hi Frank,
    Thanks for your response.
    Could you please give me some sample on that like what type of event and on which component I have to set clientListener.
    Thanks,
    Siva G.

  • In pdf file need java script to clear cache before launch of web link

    using adobe acrobat XI - have pdf file with link to external web site.
    When creating the link in the link properties selected action Run a JavaScript  the following java script was added to ensure will open in new window. app.launchURL("http://google.com", true)
    this works most of the time except with some users - if those users clear their browser cache first then it works
    Is there anything that could be added to the java script to ensure the browser cache is cleared or not used before the launch action? or any other suggestion to ensure the link will always open in new window?
    Thanks,
    Jackie

    thanks for your prompt reply.
    Was hoping maybe there would be someway to clear the cache for the users
    without them having to do anything.
    Appreciate your help.
    Jackie
    Thanks,
    Jackie
    276.783.6991 x 326

  • How to add action listener to internal frame?

    I have frame Main where I am trying to add action listener.
    Action listener should be listening button in frame Menu.
    I think it should be:
    Menu frame = new Menu();
    frame.btn_start.addActionListener(this);but it seems to be doing absolutely nothing.
    If I try to add in menu:
    btn_start.addActionListener(new Main());it generates: java.lang.StackOverflowError
    What should I do? Please help noob :)

    To get better help sooner, post a [_Short, Self Contained, Compilable and Executable, Example Program (SSCCE)_|http://mindprod.com/jgloss/sscce.html] that clearly demonstrates your problem.
    You're quite possible adding the ActionListener to the wrong component. And constructing a new instance of a class within the constructor is likely the cause of your StackOverflowError.
    db

  • Getting tha java script error while calling OAF forms in ADF

    Hi ,
    I am trying to get/access the Oracle forms in ADF page.
    I am following http://static.commit-consulting.com/oraformsfaces developers guide for guidlines.
    while runnign my page getting the error in popup look like java script error.
    the pop up contente is :
    Failed to execute java script
    Check for JavaScript errors, if the Forms server is running and if your browser can download a javaScript from http://bdc6oracle001.gdnindia.com:8005/forms/frmservlet?config=OraFormsFaces
    http://bdc6oracle001.gdnindia.com:8005/forms/frmservlet?config=OraFormsFaces is my server EBS server where oracle forms exist.
    Please help me on this.
    Thanks,
    MadhavaReddy

    You're probably better off asking the OraFormsFaces people for help

  • Calling action listener for a BUTTON component in java bean page

    Hi,
    I have made it like this.
    public void handleButtonPressed(ActionEvent event){
    System.out.println("success!!!!!");
    //code for calling actionlistener
    FacesContext fctx = FacesContext.getCurrentInstance();
    ELContext elctx = fctx.getELContext();
    Application application = fctx.getApplication();
    ExpressionFactory exprFactory = application.getExpressionFactory();
    MethodExpression methodExpr = null;
    methodExpr = exprFactory.createMethodExpression(elctx, "#{exbean.handleButtonPressed}",null,new Class[] { ActionEvent.class });
    MethodExpressionActionListener actionListener = null;
    actionListener = new MethodExpressionActionListener(methodExpr);
    button.addActionListener(actionListener);
    Even after making the listener Function as Void wHen i click the button i m getting the error saying."ARGUMENTS MISMATCH,ADF_FACES60097"??
    can you help me out?
    and in the msg log i m getting this
    "SkinFactoryImpl> <getSkin> Cannot find a skin that matches family portal and version v1.1. We will use the skin portal.desktop.
    <MethodExpressionActionListener> <processAction> Received 'javax.el.PropertyNotFoundException' when invoking action listener '#{exbean.handleButtonPressed}' for component 'null'
    <MethodExpressionActionListener> <processAction> javax.el.PropertyNotFoundException: Target Unreachable, identifier 'custombean' resolved to null"
    I Have tried with this giving Void TYPE as an argument
    methodExpr = exprFactory.createMethodExpression(elctx, "#{exbean.handleButtonPressed},Void.TYPE,new Class[] { ActionEvent.class });
    I M getting the same error.
    Edited by: chaya on Dec 22, 2011 2:47 PM

    yeah but i m creating button itself dynamically by java code....
    //code
    UIComponent button;
    button = findComponentInRoot("cb1");
    RichPanelGroupLayout pgl;
    pgl = (RichPanelGroupLayout)button.getParent();
    List<UIComponent> children;
    children = pgl.getChildren();
    RichPanelGroupLayout pgll;
    pgll = new RichPanelGroupLayout();
    RichInputText it;
    it = new RichInputText();
    it.setLabel("New textbox " + (children.size()));
    RichCommandButton but = new RichCommandButton();
    but.setPartialSubmit(true);
    but.setText("Delete");
    /*calling actionevent*/
    FacesContext fctx = FacesContext.getCurrentInstance();
    ELContext elctx = fctx.getELContext();
    Application application = fctx.getApplication();
    ExpressionFactory exprFactory = application.getExpressionFactory();
    MethodExpression methodExpr = null;
    methodExpr = exprFactory.createMethodExpression( elctx,"#{inbean.actionPerformed}",null, new Class[] {ActionEvent.class});
    MethodExpressionActionListener actionListener = null;
    actionListener = new MethodExpressionActionListener(methodExpr);
    but.addActionListener(actionListener);
    /*end of call*/
    children.add(pgll);
    children.add(it);
    children.add(but);
    AdfFacesContext.getCurrentInstance().addPartialTarget(pgl);
    //code to call method
    public void actionPerformed(ActionEvent event) {
    System.out.println("entered sec bean");
    return " ";}
    this way i m trying to create a button programatically and tryin to add actionlistener which is not working.
    the actionlistener is throwing error.... with the line
    methodExpr = exprFactory.createMethodExpression( elctx,"#{inbean.actionPerformed}",null, new Class[] {ActionEvent.class});

  • Trigger Backing Bean Action from Java script

    Hello
    I'm quite new to JSF, Would like to know how we can trigger a bcaking bean action method using java script as part of form submit.
    Already I added one commandbutton with an action method defined in backing bean, But our requiremnt is to trigger the same action even if the user submits form by pressing Enter key.
    Targeted device is Windows Mobile IE ( In IE Mobile, we can't track onkeydown, onkeyup, onkeypress, onmousemove, onmousedown and onmouseup event. )
    1. How the JSF binds a backing bean method with JSF commandButton control on runtime. I didn't find any hidden value corresponding to this commandButton.
    2.How we can trigger a bcaking bean action method using java script as part of form submit
    Thanks
    Jobinesh

    thanks a lot for the replies. I'll try it out.
    But one question, just because of curiosity
    1. How the JSF binds a backing bean method with JSF commandButton control on runtime. I didn't find any hidden value/or any other flag corresponding to this commandButton from the genarted html for the correspondant jsf soure.

  • Error message: "Java Script turned off, Enable Java Script" How to do this? I have gone into "Tools--then Options--Then checked Java Script--Then the "OK/Save" Button but this has not helped. What is the right course of action?

    Java Script is disabled on my HP laptop. I have done the obvious things. It still will not enable Java Script. What do I try next?

    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]
    * [[Troubleshooting plugins]]
    If it does work in Safe-mode then disable all extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    * Use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    * Close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")

  • Transaction Posting Confirmation Message and Action Listener behaviour

    Hi, I have a scenario that a user is Posting a Transaction and when he press the “Post” Button a, confirmation dialog box should popup asking “Do you really want to Post the record ?”. If the user press “Yes” the record is further process and If the user press “No” then the transaction should not proceed.
    I have implemented the main screen(PostTransaction.java) and the popup confirmation window(ConfirmationWindow.java)
    Question 1 ) Why the code is not stoping in the Post Button Action listener as in JOptionPane, then how do i know that the user has selected "Yes" or "No" ?
    Question 2) Do I have to write the code for posting of a Transaction(postTransaction() method) in the “ConfirmationWindow”? or it should be in “PostTransaction”.
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.application.Application;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.scene.control.TextField;
    import javafx.scene.layout.GridPane;
    import javafx.stage.Stage;
    public class PostTransaction extends Application{
           public void start(final Stage stage) throws Exception {
                  Group root = new Group();
                  Scene scene = new Scene(root, 300,300);
                  stage.setScene(scene);
                  stage.setTitle("Transaction Post Screen");
                  GridPane gp = new GridPane();
                  Label lblName = new Label("Name");
                  Label lblAmount = new Label("Amount");
                  TextField txtName = new TextField();
                  TextField txtAmount = new TextField();
                  Button btnPost = new Button("Post Record");
                  gp.add(lblName, 1, 1);
                  gp.add(lblAmount, 1, 2);
                  gp.add(txtName, 2, 1);
                  gp.add(txtAmount, 2, 2);
                  gp.add(btnPost, 2, 3);
                  btnPost.setOnAction(new EventHandler<ActionEvent>() {
                        @Override
                        public void handle(ActionEvent arg0) {
                             //The code does not stop here as in JOptionPane, then how do i know that the user has selected "Yes" or "No" ??
                             boolean popupResult = ConfirmationWindow.confirmTranactionPosting(stage, "Please Confirm");
                             if(popupResult==true){
                                  //This line is printed before the user selects yes or no
                                  System.out.println("Proceeding with Tranaction Posting");
                                  //postTransaction();
                             if(popupResult==false){
                                  //This line is printed before the user selects yes or no
                                  System.out.println("Do not Proceed with Tranaction Posting");
                 root.getChildren().add(gp);
                stage.show();
                public static void main(String[] args) {
                  launch(args);
              private void postTransaction(){
                   //write the code for posting here
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.layout.HBox;
    import javafx.stage.Modality;
    import javafx.stage.Stage;
    import javafx.stage.StageStyle;
    public class ConfirmationWindow extends Stage {
         Stage owner;
         Stage stage;
         BorderPane root;
         static boolean postStatus = false;
      public ConfirmationWindow( Stage owner, String title){
        root = new BorderPane();
        stage = this;
        this.owner = owner;
        initModality( Modality.APPLICATION_MODAL );
        initOwner( owner );
        initStyle( StageStyle.UTILITY );
        setTitle( title );
        setContents();
      public void setContents(){
        Scene scene = new Scene(root,250,150);
        setScene(scene);
        Group groupInDialog = new Group();
        groupInDialog.getChildren().add( new Label("Do you really want to Post this record ?") );
        root.setCenter( groupInDialog );
        Button yes = new Button( "Yes" );
        yes.setOnAction(new EventHandler<ActionEvent>() {
              @Override
              public void handle(ActionEvent e) {
                   postStatus =true;
                   stage.close(); // Close the pop up. Transfer control to PostTransaction.java and execute the PostTransaction() method.
        Button no  = new Button( "No" );
        no.setOnAction(new EventHandler<ActionEvent>() {
              @Override
              public void handle(ActionEvent e) {
                   postStatus =false;
                   stage.close(); // Close the pop up only
        HBox buttonPane = new HBox();
        buttonPane.setSpacing(10);
        buttonPane.getChildren().addAll(yes,no);
        root.setBottom(buttonPane);
        stage.show();
      public static boolean confirmTranactionPosting(Stage owner, String title) {
           new ConfirmationWindow(owner, title);
           return postStatus;
    }

    The MII Message listener is a queue. But when I understand you correctly, you do not want to process the messages immediately after arriving in the Listener.
    Maybe the categorization of messages is an option for you (see [Sap Help: Processing Rule Editor - Category|http://help.sap.com/saphelp_mii121/helpdata/en/43/e80b59ad40719ae10000000a1553f6/frameset.htm]. You can enter a category for the control recipe messages. The messages will then be placed in the Listener queue. You can use the [Message Services|http://help.sap.com/saphelp_mii121/helpdata/en/43/e80b59ad40719ae10000000a1553f6/frameset.htm] actions to read the categorized messages and process them as you need.
    In addition to Manoj, you may also use the [Queueing actions|http://help.sap.com/saphelp_mii121/helpdata/en/43/e80b59ad40719ae10000000a1553f6/frameset.htm] of MII, where you can queue xml contents.
    Hope this helps.
    Michael

  • Export collection action listener error after second call

    Hi all,
    I am using the operation export collection action listener to export to excel the content of a table. The first time I clicked the button to export, Microsoft Excel open with the table  information correctly but if  I want to export again then I got the following error:
    <08-ago-2013 21H54' VET> <Error> <oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter> <BEA-000000> <ADF_FACES-60096:Excepción del Servidor durante PPR, #1
    java.lang.IllegalStateException: ADF_FACES-60003: Component with ID: pt1:r8:4:b1 not registered for Active Data.
      at oracle.adfinternal.view.faces.activedata.PageDataUpdateManager.unregisterComponent(PageDataUpdateManager.java:615)
      at oracle.adfinternal.view.faces.context.RichPhaseListener.handleStartAndStopActiveData(RichPhaseListener.java:478)
      at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:540)
      at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:225)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
      at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
      at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
      at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
      at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341)
      at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:192)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
      at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:478)
      at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
      at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:478)
      at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:303)
      at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:208)
      at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:202)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:137)
      at java.security.AccessController.doPrivileged(Native Method)
      at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
      at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:460)
      at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:120)
      at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:217)
      at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:81)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:225)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3367)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3333)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
      at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
      at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2220)
      at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2146)
      at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2124)
      at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1564)
      at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
      at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
      at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)
    Any Idea?
    Jhon Carrillo
    Jdev 12c

    Hi,
    there is a bug filed for this that has been fixed for the first (upcoming) Patch Set of 12c. Until then the solution seems to be to get the current row before exporting the table and then to set it back afterwards. So what you can try is to create a hidden button for the export of the table. Say you name the button "expBut". Then have another button with a action reference to a managed bean. This button now will invoke the following code
    1. read the current row from the table iterator (bindings --> (DCIteratorBinding) bindings.get("iteratorName") --> (Row) dcIterator.getCurrentRow()
    2. invoke the hidden button: ActionEvent ae = new ActionEvent(expBut); ae.queue();
    3. Set current row back to where it was: dcIterator.setCurrentRowWithKey(row.getKey().toStringFormat(true));
    At least this seems to be the internal bug fix.
    Alternatively, disable PPR on the binding layer (ChangeEventPolicy=None on the iterator) and set the same on the PartialTrigger property of the component.
    Frank

  • Action listener activation in many phases

    I need action listener (methods) to be activated in many phases. I.e., when the user clicks a submit button, I want code to be executed (in my case) after the validation phase and after (during) the invoke application phase. In earlier version of the standard, I would just register 2 listeners, returning the appropriate getPhaseId() value. Since this method is removed from the current standard, things get more complicated.
    QUESTION: Why in heavens name was this method removed from the standard? I suppose, because it is difficult to support with listener methods (in contrast to instances)? Bit of a rough solution, no? Or am I missing something?
    I have a solution now, I think, that is based on getting the action event immediate, and requeuing the event again and again.
    In the JSP, in the JSF form, I have a submit button as follows:
    <h:commandButton id="buttonId" value="ButtonText"
                     actionListener="#{handler.buttonListener}"
                     immediate="true"/>The method Handler.buttonListener is:
      public final void buttonListener(ActionEvent ae) {
        LOG.debug("Handler. buttonListener called ("
                  + "ActionEvent.getPhaseId() = " + ae.getPhaseId()
                  + "; ActionEvent.getComponent() = " + ae.getComponent()
                  + ")");
        PhaseId phaseId = ae.getPhaseId();
        if (phaseId.equals(PhaseId.APPLY_REQUEST_VALUES)) {
          LOG.debug("-- processing during " + ae.getPhaseId());
          // meaningful stuff here
          // prepare for execution in next phase
          ae.queue();
            /* this sets phase id to the current phase, so it is extremely important that
             * we set the necessary phase id AFTER queuing the event */
          ae.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
          LOG.debug("-- ActionEvent (getPhaseId() = " + ae.getPhaseId() + ") queued");     
        else if (phaseId.equals(PhaseId.PROCESS_VALIDATIONS)) {
          LOG.debug("-- processing during " + ae.getPhaseId());
          // meaningful stuff here
          // prepare for execution in next phase
          ae.queue();
          /* this sets phase id to the current phase, so it is extremely important that
           * we set the necessary phase id AFTER queuing the event */
          ae.setPhaseId(PhaseId.INVOKE_APPLICATION);
          LOG.debug("-- ActionEvent (getPhaseId() = " + ae.getPhaseId() + ") queued");     
        else if (phaseId.equals(PhaseId.INVOKE_APPLICATION)) {
          LOG.debug("-- processing during " + ae.getPhaseId());
          // meaningful stuff here
        LOG.debug("Handler. buttonListener done");
      }The /* */ comment in the code is there because the queue methods (on the event as well as the component) set the phase id of the event to the current phase. If I set the phase id of the event before queuing it, that setting is undone, and I get an infinite loop! This is weird, and my solution is at least shaky: it doesn't feel stable across JSF implementations and future releases. I could not find a queue method that leaves the phase id alone.
    QUESTION: am I missing something?
    The output however is:
    Mar 21, 2005 12:51:11 PM org.exadel.jsf.PhaseTracker beforePhase
    INFO: BEFORE RESTORE_VIEW 1
    Mar 21, 2005 12:51:11 PM org.exadel.jsf.PhaseTracker afterPhase
    INFO: AFTER RESTORE_VIEW 1
    Mar 21, 2005 12:51:11 PM org.exadel.jsf.PhaseTracker beforePhase
    INFO: BEFORE APPLY_REQUEST_VALUES 2
    12:51:12,119 DEBUG Handler:550 - Handler.buttonListener called
          (ActionEvent.getPhaseId() = APPLY_REQUEST_VALUES 2;
           ActionEvent.getComponent() = javax.faces.component.html.HtmlCommandButton@33b99a)
    12:51:12,171 DEBUG Handler:556 - -- processing during APPLY_REQUEST_VALUES 2
    12:51:12,184 DEBUG Handler:564 - -- ActionEvent (getPhaseId() = PROCESS_VALIDATIONS 3) queued
    12:51:12,189 DEBUG Handler:580 - Handler.buttonListener done
    12:51:12,220 DEBUG Handler:550 - Handler.buttonListener called
         (ActionEvent.getPhaseId() = PROCESS_VALIDATIONS 3;
          ActionEvent.getComponent() = javax.faces.component.html.HtmlCommandButton@33b99a)
    12:51:12,255 DEBUG Handler:567 - -- processing during PROCESS_VALIDATIONS 3
    12:51:12,256 DEBUG Handler:574 - -- ActionEvent (getPhaseId() = INVOKE_APPLICATION 5) queued
    12:51:12,257 DEBUG Handler:580 - Handler.buttonListener done
    12:51:12,265 DEBUG Handler:550 - Handler.buttonListener called
        (ActionEvent.getPhaseId() = INVOKE_APPLICATION 5;
         ActionEvent.getComponent() = javax.faces.component.html.HtmlCommandButton@33b99a)
    12:51:12,267 DEBUG Handler:577 - -- processing during INVOKE_APPLICATION 5
    12:51:12,268 DEBUG Handler:580 - Handler.buttonListener done
    Mar 21, 2005 12:51:12 PM org.exadel.jsf.PhaseTracker afterPhase
    INFO: AFTER APPLY_REQUEST_VALUES 2
    Mar 21, 2005 12:51:12 PM org.exadel.jsf.PhaseTracker beforePhase
    INFO: BEFORE RENDER_RESPONSE 6
    Mar 21, 2005 12:51:12 PM org.exadel.jsf.PhaseTracker afterPhase
    INFO: AFTER RENDER_RESPONSE 6The info is generated by a phase listener I found somewhere (sorry for the lack of reference here to the author). As you can see, I get 3 consecutive calls of my listener method, but they are all during the apply request values phase, and we jump from the apply request values phase immediately to the render response phase, skipping all the other phases, although my listener is actually called 3 times.
    QUESTION: what the fuck? What is happening here, and more important, how can I fix it?

    I am in touch with IBM about any patch they might have for this. I just thought I'd post details from what I researched.
    Basically I found that if I had CommandButton and/or CommandLink components on my page and clicked them for a total greater than 15 times, the application just quit reacting to any of the clicks. After writing a PhaseListener I discovered that after 15 clicks the JSF lifecycle was going straight from the Restore View (1) to Render Response (6) phase instead of going through the ones in between.
    I downloaded the JSF source code and tracked down the magic number 15. As mentioned earlier in this forum it has to do with the number of views per session. In the Sun JSF-RI com.sun.faces.application.StateManagerImpl class
    the number of views is defaulted to 15. When the number of views hits the max the oldest view is deleted. Somehow I don't think they are deleting the oldest view or else why my app quits after 15 clicks I do not know. Anyway this is a known issue with the Sun JSF-RI and documented in their Release Notes.
    Depending on the JSF implementation there may or may not be a workaround. I mean to say the the workaround is not part of the JSF spec but Sun's implementation has a feature where you can configure the com.sun.faces.NUMBER_OF_VIEWS_IN_SESSION value in the web.xml file under the <context-param> tag. If you set the value sufficiently high you lower the risk of the app quitting on you (like a user may be unlikely to make 100 or even 50 clicks on the same page). You might also want to set the state to be saved on the server by setting javax.faces.STATE_SAVING_METHOD to server in another <context-param> tag. Somehow setting this state to client caused errors (NullPointerException) in our app in one of the Faces classes itself.
    Hope this helps someone out there.

  • Executing shell scripts before the war is loaded

    I want to execute some shell scripts before my web application starts. I am using struts. One way is to execute these shell scripts is by executing them in a startup servlet which is loaded before action servlet is loaded. Am I right? Is there some other way. I am using Tomcat 5.0. Is there some way by which i can execute these shell scripts before my war is loaded in the tomcat. Actually it is possible that tomorrow i might have more shell scripts than i have today. In that case i do not want to modify the code. Thats the reason I am wondering if there is a way i can do this with the help of tomcat.

    thats right. So out of two ways, one, being having a startup servlet and second being the tomcat shell script change, which is the preferred way? Is there any other third way to achieve this?

  • Property on Backing Bean is Not set when Action Listener is Fired

    Why is it that when my action listener is invoked, the property for my other component on the page has not been reflected in model yet?
    Here is what I have:
    My JSP has the following two components:
    <h:inputText value="#{manageQuestionBean.newStory}"></h:inputText>
    <h:commandButton value="add" actionListener="#{manageQuestionBean.onAddStory}"></h:commandButton> My Java code has the following:
    public void onAddStory(ActionEvent event) {
           //This always prints out 'null'
           System.out.println("The value of 'newStory' is: " + newStory);
          //TO DO: this is where the logic would go for creating a new story object.
        } When I put logging statements inside my setter for the newStory property, I see that it is being set to the right value, but then it being reset to empty string. Why is that? During what phase do the action listeners get invoked?

    Which JSF implementation/version are you using?
    mczauz wrote:
    When I put logging statements inside my setter for the newStory property, I see that it is being set to the right value, but then it being reset to empty string. Why is that? When exactly happens when exactly?
    During what phase do the action listeners get invoked?The invoke application phase, after the update model values phase.
    You may find this article useful to learn about phases and how to add a 'phase debugger' yourselfl: [http://balusc.blogspot.com/2006/09/debug-jsf-lifecycle.html].

  • Problem with action listener

    hello
    the problem in my code is that i defined
    actionlistener for a button but it does not
    do what it should do . it throws an error in the console
    and i think my code is 100% correct what is the problem
    please help me this is the codewith
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    class Library extends JFrame implements ActionListener     {
         private JMenuBar jmb      = new JMenuBar();
         private JMenu books      = new JMenu("Books",true);
         private JMenu members      = new JMenu("Members",true);
         private JMenu loans      = new JMenu("Loans",true);
         private JMenuItem addNb = new JMenuItem("Add New Book");
         private JMenuItem listB = new JMenuItem("List All Books");
         private JMenuItem listAb = new JMenuItem("List Available Books");
         private JMenuItem listBb = new JMenuItem("List Borrowed Books");
         private JMenuItem addNm = new JMenuItem("Add New Member");
         private JMenuItem removeM = new JMenuItem("Remove a Member");
         private JMenuItem listAm = new JMenuItem("List All Members");
         private JMenuItem loanB = new JMenuItem("Loan A Book");
         private JMenuItem returnB = new JMenuItem("Return A Book");
         private JTextField bNumber = new JTextField(14);
         private JTextField bAuthor = new JTextField(14);
         private JTextField bTitle = new JTextField(14);
         private JTextField mId = new JTextField(14);
         private JTextField mName = new JTextField(14);
         private JTextField idB = new JTextField(14);
         private JTextField nBToB = new JTextField(14);
         private JTextField nBTor = new JTextField(14);
         private JTextArea dispaly = new JTextArea();
         private JButton oKb1 = new JButton("OK");
         private JButton okb2 = new JButton("OK");
         private JButton cloaseb = new JButton("Close");
         private JButton oKm1 = new JButton("OK");
         private JButton oKm2 = new JButton("OK");
         private JButton cancelM = new JButton("Cancel");
         private JButton oKm3 = new JButton("OK");
         private JButton oKm4 = new JButton("OK");
         private JButton cancelM2 = new JButton("Cancel");
         private JButton oKl = new JButton("OK");
         private JButton oKr = new JButton("OK");
         private JButton yes = new JButton("Yes");
         private JButton no = new JButton("No");     
         private JLabel bN = new JLabel("Book Number");
         private JLabel bA = new JLabel("Book Author");
         private JLabel bT = new JLabel("Book Title");
         private JLabel iN          = new JLabel("ID Number");
         private JLabel mN          = new JLabel("Member's Name");
         private JLabel     iNb          = new JLabel("ID number of the borrower");
         private JLabel nBb          = new JLabel("Number of the books to borrow");
         private JLabel nBr          = new JLabel("Number of the books to return");
         private JLabel mIdl     = new JLabel("ID number of the stuednt");
         private JPanel tempoIPanel= new JPanel(new FlowLayout());
         Container cp;
         JFrame mainFrame;
         JInternalFrame tempoI;
    Library()     {
         //LibraryClass lClass = new LibraryClass();/*
         mainFrame = new JFrame();
         mainFrame.setJMenuBar(jmb);
         mainFrame.setSize(800,550);
         mainFrame.getContentPane().setLayout(new FlowLayout());
         jmb.add(books);
         jmb.add(members);
         jmb.add(loans);
         books.add(addNb);
         addNb.addActionListener(this);
         books.add(listB);
         listB.addActionListener(this);
         books.add(listAb);
         listAb.addActionListener(this);
         books.add(listBb);
         listBb.addActionListener(this);
         members.add(addNm);
         addNm.addActionListener(this);
         members.add(removeM);
         removeM.addActionListener(this);
         members.add(listAm);
         listAm.addActionListener(this);
         loans.add(loanB);
         loanB.addActionListener(this);
         loans.add(returnB);
         returnB.addActionListener(this);
         //actions listeners
         oKb1.addActionListener(this);
         mainFrame.setVisible(true);
    public void actionPerformed(ActionEvent ae)     {
         if(ae.getSource() == addNb)     {
              tempoI = new JInternalFrame("Add new Book",true,true);
              mainFrame.getContentPane().add(tempoI);
              tempoI.getContentPane().setLayout(new FlowLayout());
              tempoI.getContentPane().add(bN);
              tempoI.getContentPane().add(bNumber);
              tempoI.getContentPane().add(bA);
              tempoI.getContentPane().add(bAuthor);
              tempoI.getContentPane().add(bT);
              tempoI.getContentPane().add(bTitle);
              tempoI.getContentPane().add(oKb1);//add action listener here
              tempoI.setVisible(true);
         if(ae.getSource() == listB)     {
              //LibraryClass.listBooks();
         if(ae.getSource() == listAb){}
         if(ae.getSource() == listBb){}
         if(ae.getSource() == addNm)     {
              tempoI = new JInternalFrame("Add new Member",true,true);
              mainFrame.getContentPane().add(tempoI);
              tempoI.getContentPane().setLayout(new FlowLayout());
              tempoI.getContentPane().add(iN);
              tempoI.getContentPane().add(mId);
              tempoI.getContentPane().add(mN);
              tempoI.getContentPane().add(mName);
              tempoI.getContentPane().add(oKm1);//add action listener
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == removeM)     {
              tempoI = new JInternalFrame("Rmove member",true,true);
              mainFrame.getContentPane().add(tempoI);
              tempoI.getContentPane().setLayout(new FlowLayout());
              tempoI.getContentPane().add(mIdl);
              tempoI.getContentPane().add(mId);
              tempoI.getContentPane().add(oKm2);//add action listener
              //LibraryClass.removeM(Double.parseDouble(mId.getText()));
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == listAm)     {
              //LibraryClass.listMembers();
         if(ae.getSource() == loanB)     {
              tempoI = new JInternalFrame("Loan book",true,true);
              mainFrame.getContentPane().add(tempoI);
              tempoI.getContentPane().setLayout(new FlowLayout());
              tempoI.getContentPane().add(iNb);
              tempoI.getContentPane().add(idB);
              tempoI.getContentPane().add(nBb);
              tempoI.getContentPane().add(nBToB);
              tempoI.getContentPane().add(oKl);
              //LibraryClass.borrowBook(Book bk,Member m);
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == returnB)     {
              tempoI = new JInternalFrame("Return Book",true,true);
              mainFrame.getContentPane().add(tempoI);
              tempoI.getContentPane().setLayout(new FlowLayout());
              tempoI.getContentPane().add(iNb);
              tempoI.getContentPane().add(idB);
              tempoI.getContentPane().add(nBr);
              tempoI.getContentPane().add(nBTor);
              tempoI.getContentPane().add(oKr);
              tempoI.getContentPane().setSize(400,300);
              tempoI.setVisible(true);
              //Book.addBook(bNumber.getText(),bAuthor.getText(),bTitle.getText());
    class ClubLibrarySystem     {
         public static void main(String[] args)     {
         new Library();
    }

    hello
    the problem in my code is that i defined
    actionlistener for a button but it does not
    do what it should do . it throws an error in the
    consoleWhat error?
    and i think my code is 100% correct what is theWell, but it isn't.
    Have you tried using a debugger?
    problem
    please help me this is the codewith
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    class Library extends JFrame implements
    ActionListener     {
         private JMenuBar jmb      = new JMenuBar();
         private JMenu books      = new JMenu("Books",true);
    private JMenu members      = new
    JMenu("Members",true);
    private JMenu loans      = new
    JMenu("Loans",true);
    private JMenuItem addNb = new JMenuItem("Add New
    Book");
    private JMenuItem listB = new JMenuItem("List All
    Books");
    private JMenuItem listAb = new JMenuItem("List
    Available Books");
    private JMenuItem listBb = new JMenuItem("List
    Borrowed Books");
    private JMenuItem addNm = new JMenuItem("Add New
    Member");
    private JMenuItem removeM = new JMenuItem("Remove a
    Member");
    private JMenuItem listAm = new JMenuItem("List All
    Members");
    private JMenuItem loanB = new JMenuItem("Loan A
    Book");
    private JMenuItem returnB = new JMenuItem("Return A
    Book");
         private JTextField bNumber = new JTextField(14);
         private JTextField bAuthor = new JTextField(14);
         private JTextField bTitle = new JTextField(14);
         private JTextField mId = new JTextField(14);
         private JTextField mName = new JTextField(14);
         private JTextField idB = new JTextField(14);
         private JTextField nBToB = new JTextField(14);
         private JTextField nBTor = new JTextField(14);
         private JTextArea dispaly = new JTextArea();
         private JButton oKb1 = new JButton("OK");
         private JButton okb2 = new JButton("OK");
         private JButton cloaseb = new JButton("Close");
         private JButton oKm1 = new JButton("OK");
         private JButton oKm2 = new JButton("OK");
         private JButton cancelM = new JButton("Cancel");
         private JButton oKm3 = new JButton("OK");
         private JButton oKm4 = new JButton("OK");
         private JButton cancelM2 = new JButton("Cancel");
         private JButton oKl = new JButton("OK");
         private JButton oKr = new JButton("OK");
         private JButton yes = new JButton("Yes");
         private JButton no = new JButton("No");     
    private JLabel bN = new JLabel("Book
    Number");
    private JLabel bA = new JLabel("Book
    Author");
    private JLabel bT = new JLabel("Book
    Title");
         private JLabel iN          = new JLabel("ID Number");
    private JLabel mN          = new JLabel("Member's
    Name");
    private JLabel     iNb          = new JLabel("ID number of the
    borrower");
    private JLabel nBb          = new JLabel("Number of the
    books to borrow");
    private JLabel nBr          = new JLabel("Number of the
    books to return");
    private JLabel mIdl     = new JLabel("ID number of
    the stuednt");
    private JPanel tempoIPanel= new JPanel(new
    FlowLayout());
         Container cp;
         JFrame mainFrame;
         JInternalFrame tempoI;
    Library()     {
         //LibraryClass lClass = new LibraryClass();/*
         mainFrame = new JFrame();
         mainFrame.setJMenuBar(jmb);
         mainFrame.setSize(800,550);
    mainFrame.getContentPane().setLayout(new
    FlowLayout());
         jmb.add(books);
         jmb.add(members);
         jmb.add(loans);
         books.add(addNb);
         addNb.addActionListener(this);
         books.add(listB);
         listB.addActionListener(this);
         books.add(listAb);
         listAb.addActionListener(this);
         books.add(listBb);
         listBb.addActionListener(this);
         members.add(addNm);
         addNm.addActionListener(this);
         members.add(removeM);
         removeM.addActionListener(this);
         members.add(listAm);
         listAm.addActionListener(this);
         loans.add(loanB);
         loanB.addActionListener(this);
         loans.add(returnB);
         returnB.addActionListener(this);
         //actions listeners
         oKb1.addActionListener(this);
         mainFrame.setVisible(true);
    public void actionPerformed(ActionEvent ae)     {
         if(ae.getSource() == addNb)     {
    tempoI = new JInternalFrame("Add new
    w Book",true,true);
              mainFrame.getContentPane().add(tempoI);
    tempoI.getContentPane().setLayout(new
    w FlowLayout());
              tempoI.getContentPane().add(bN);
              tempoI.getContentPane().add(bNumber);
              tempoI.getContentPane().add(bA);
              tempoI.getContentPane().add(bAuthor);
              tempoI.getContentPane().add(bT);
              tempoI.getContentPane().add(bTitle);
    tempoI.getContentPane().add(oKb1);//add action
    n listener here
              tempoI.setVisible(true);
         if(ae.getSource() == listB)     {
              //LibraryClass.listBooks();
         if(ae.getSource() == listAb){}
         if(ae.getSource() == listBb){}
         if(ae.getSource() == addNm)     {
    tempoI = new JInternalFrame("Add new
    w Member",true,true);
              mainFrame.getContentPane().add(tempoI);
    tempoI.getContentPane().setLayout(new
    w FlowLayout());
              tempoI.getContentPane().add(iN);
              tempoI.getContentPane().add(mId);
              tempoI.getContentPane().add(mN);
              tempoI.getContentPane().add(mName);
    tempoI.getContentPane().add(oKm1);//add action
    n listener
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == removeM)     {
    tempoI = new JInternalFrame("Rmove
    e member",true,true);
              mainFrame.getContentPane().add(tempoI);
    tempoI.getContentPane().setLayout(new
    w FlowLayout());
              tempoI.getContentPane().add(mIdl);
              tempoI.getContentPane().add(mId);
    tempoI.getContentPane().add(oKm2);//add action
    n listener
              //LibraryClass.removeM(Double.parseDouble(mId.getText
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == listAm)     {
              //LibraryClass.listMembers();
         if(ae.getSource() == loanB)     {
              tempoI = new JInternalFrame("Loan book",true,true);
              mainFrame.getContentPane().add(tempoI);
    tempoI.getContentPane().setLayout(new
    w FlowLayout());
              tempoI.getContentPane().add(iNb);
              tempoI.getContentPane().add(idB);
              tempoI.getContentPane().add(nBb);
              tempoI.getContentPane().add(nBToB);
              tempoI.getContentPane().add(oKl);
              //LibraryClass.borrowBook(Book bk,Member m);
              tempoI.getContentPane().setSize(300,400);
              tempoI.setVisible(true);
         if(ae.getSource() == returnB)     {
    tempoI = new JInternalFrame("Return
    n Book",true,true);
              mainFrame.getContentPane().add(tempoI);
    tempoI.getContentPane().setLayout(new
    w FlowLayout());
              tempoI.getContentPane().add(iNb);
              tempoI.getContentPane().add(idB);
              tempoI.getContentPane().add(nBr);
              tempoI.getContentPane().add(nBTor);
              tempoI.getContentPane().add(oKr);
              tempoI.getContentPane().setSize(400,300);
              tempoI.setVisible(true);
              //Book.addBook(bNumber.getText(),bAuthor.getText(),bT
    tle.getText());
    class ClubLibrarySystem     {
         public static void main(String[] args)     {
         new Library();

  • Action Listener Method called multiple times

    I have a page (fragment .jsff), containing a simple input text and a button called "search". When I click on "Search" the action listener is triggered multiple times. (The results are displayed in a table inside a panel collection).
    The results are actually coming back ok.
    When I debug the code, I can see the action listener method called twice.
    Do you know why is that?
    What should I be taking care of?
    This is my code :
    *** Fragment ****
    <af:commandButton text="#{identityBundle.search_label}" id="cb1"
    actionListener="#{UserDetailsBean.searchUsersListener}"
    disabled="#{!bindings.searchUsers.enabled}"/>
    *** Managed bean ***
    public void searchUsersListener(ActionEvent actionEvent) {
    // Add event code here...
    DCBindingContainer bindings = (DCBindingContainer)getBindings();
    DCIteratorBinding iter = bindings.findIteratorBinding("userIterator");
    DCDataRow row = (DCDataRow)iter.getCurrentRow();
    User user = (User)row.getDataProvider();
    boolean isSearchCriteriaPresent = false;
    if(user != null){
    String fn = user.getFirstname();
    if(fn != null && !fn.trim().equals("")){
    isSearchCriteriaPresent = true;
    user.setLastname(fn);
    user.setNonMTUserLogin(fn);
    try {
    Map <Object, Object> userMap = PropertyUtils.describe(user);
    for(Map.Entry<Object, Object> entry: userMap.entrySet()){
    if(entry.getKey() != null && entry.getValue() != null && !entry.getKey().toString().equalsIgnoreCase("class")){
    isSearchCriteriaPresent = true;
    break;
    } catch (IllegalAccessException e) {
    e.printStackTrace();
    } catch (InvocationTargetException e) {
    e.printStackTrace();
    } catch (NoSuchMethodException e) {
    e.printStackTrace();
    if(!isSearchCriteriaPresent){
    user.setFirstname("*");
    OperationBinding opBinding = (OperationBinding)bindings.getOperationBinding("searchUsers");
    opBinding.getParamsMap().put("user", user);
    opBinding.execute();
    AdfFacesContext adfFacesCtx = AdfFacesContext.getCurrentInstance();
    Map<String, Object> scopePageFlowScopeVar= adfFacesCtx.getPageFlowScope();
    scopePageFlowScopeVar.put("userSearchCriteria", user);
    ADFContext adfCtx = ADFContext.getCurrent();
    Map sessionScope = adfCtx.getSessionScope();
    sessionScope.put("userSearchCriteria", user);
    setUserSearchCriteria(user);
    if(selectedUserID != null){
    selectedUserID.setValue(null);
    RichTable table = getUserResultsTable();
    DCIteratorBinding searchUsersIterator = (DCIteratorBinding)bindings.get("searchUsersIterator");
    Row[] rows = searchUsersIterator.getAllRowsInRange();
    if(rows.length > 0){
    RowKeySetImpl rks = new RowKeySetImpl();
    ArrayList keyList = new ArrayList();
    keyList.add(rows[0].getKey());
    rks.add(keyList);
    table.setSelectedRowKeys(rks);
    table.setDisplayRowKey(keyList);
    refreshState(table);
    if(!isSearchCriteriaPresent){
    user.setFirstname(null);
    else{
    deleteUserButton.setDisabled(true);
    resetPasswordButton.setDisabled(true);
    enableUserButton.setDisabled(true);
    disableUserButton.setDisabled(true);
    Thanks in advance for your help

    Hi,
    Can you try this?
    1. set partialSubmit=true for the "search" button
    2. set "search" button id as partialTrigger in your result table
    -Prasad

Maybe you are looking for