Executing Javascript AFTER the action in Backing Bean

I have a commandButton on my JSP which is bound to a method in my backing bean by the action attribute. However, I also have a Javascript function call in onClick. But, the Javascript function call is always executed first and then my action method is executed. Is there a way to execute the action method first and THEN the Javascript call? I simply just want to popup a message that says 'Save successful' or something to that effect.

put a onload on your body.
The javascript function reads a form value and if a certain condition is true you show the alert.
For example, i've this to clean up error messages. (JavaScript)
// Cleans the application error messages if there are jsf errors
function cleanErrorMessages(){
    if(document.getElementById('form1:jsfErrorMessages') != null){
        document.getElementById('form1:applicationErrorMessages').innerText='';
}

Similar Messages

  • Is it possible to trigger action in backing bean on page unload event?

    Hi,
    There is a RichPopup in my page which has a Listener to save data or not by user choice "Data change detected, do you want to save those changes?"
    I've tried with the javascript event 'window.onbeforeunload', but this way must be fit with a Servlet function which I am not allowed to use.
    The attibute 'onunload' in the tag '<af:document>' seems useless. Even there is few description or example in the 'Tag Reference'.
    So, is it possible to trigger action in backing bean on page unload event? Thanks in advance for helping.
    Viva

    Hi Frank
    Thanks for helping, I've tried in your way. My codes are like below:
    Page codes:
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
      <jsp:directive.page contentType="text/html;charset=UTF-8"/>
      <f:view>
        <af:document id="d1" clientComponent="true" title="viva test">
          <af:resource type="javascript">
            if (!window.addEventListener) {
                // alert('window.addEventListener is not supported in IE8. Override it!');
                window.addEventListener = function (type, listener, useCapture) {
                    window.attachEvent('on' + type, function() {listener(event)});
            window.addEventListener('beforeunload', function (){performUnloadEvent()}, false);
            function performUnloadEvent() {
              var eventSource = AdfPage.PAGE.findComponentByAbsoluteId('d1');
              //var x and y are dummy variables obviously neeed to keep the page
              //alive for as long it takes to send the custom event to the server
              var x = AdfCustomEvent.queue(eventSource, 'handleOnUnload', {args:'noargs'}, false);
              var y = 0;
          </af:resource>
          <af:serverListener type="handleOnUnload" method="#{vivaTestBean.testOnUnload}"/>
          <!--
          <af:form id="f1">
            <af:commandButton text="Unload" id="cb1" action="unload"/>
          </af:form>
          -->
        </af:document>
      </f:view>
    </jsp:root>The backing bean codes:
    public class VivaTestBean {
        public VivaTestBean() {
        public void testOnUnload(ClientEvent clientEvent) {
            System.out.println("Thanks God");
    }The first way which triggers a 'unload' event by clicking a button DO WORKS. :)
    But when I changed the triggered way by changing the <af:document> to clientComponent as what you did, the 'onbeforeunload' event won't come out when I refreshed or closed the page.
    That doesn't make sence, since I think the two ways to trigger a 'unload' event are the same.
    Edited by: 841766 on 2011-3-7 上午1:13

  • Execute javascript after update and submit in Skillbuilders Modal Page

    Hi,
    I'm editing, say, list of my employees in a tabular form opened in Skillbuilders Modal Page.
    I have to execute same javascript code after the changes in the tabular form have been submitted.
    I've tried using a Dynamic Action fired on Page Load, but that gets executed before the update is completed.
    Does anyone have an idea how to accomplish this?
    Thank you!

    Thank you for your answers.
    Yes, I'm trying to execute javascript code on the child page, the modal one.
    Basically, there's a button on my parent page which opens the modal page. The modal page has buttons Cancel, Delete and Save. Clicking Save button submits the changes and if there are errors, errors are shown and we stay on the modal page.
    My modal pages are all of fixed dimensions and if there are errors, I have to adjust the other regions (adjust their height, add a scrollbar, etc) in order to show everything in the modal page.
    I have written a function that does exactly that, but I have to execute the function after the page is loaded and the regions are shown. But, if I execute it using onload attribute, or setting a dynamic action which fires on page load, the function gets executed during the submit, before the regions are shown.
    I hope I have managed to clear up the problem.
    As always, thank you.

  • Execute Javascript after *.jspx page rendered

    I have a page with controls and a subform with a servlet, rendering a jasper report:
                   <af:panelFormLayout id="pfl1" partialTriggers="cbReportHTML">
                    <af:subform id="sfRep">
                      <jsp:include page="/jasperservlet" flush="true"/>
                    </af:subform>
                  </af:panelFormLayout>
    I want the page to be rendered before the subform (so that user can see controls on page before the report).
    "/jasperservlet" generates the report in about half a minute.
    I want to have a JavaScript that runs after the page is rendered (and the user sees the controls) and then it starts to generate report.
    I tried to put a frame with such javascript, but the javascript is executed before user can see controls.
    How can it be done?

    Thank you for your answers.
    Yes, I'm trying to execute javascript code on the child page, the modal one.
    Basically, there's a button on my parent page which opens the modal page. The modal page has buttons Cancel, Delete and Save. Clicking Save button submits the changes and if there are errors, errors are shown and we stay on the modal page.
    My modal pages are all of fixed dimensions and if there are errors, I have to adjust the other regions (adjust their height, add a scrollbar, etc) in order to show everything in the modal page.
    I have written a function that does exactly that, but I have to execute the function after the page is loaded and the regions are shown. But, if I execute it using onload attribute, or setting a dynamic action which fires on page load, the function gets executed during the submit, before the regions are shown.
    I hope I have managed to clear up the problem.
    As always, thank you.

  • CommandButton doesn't invode the function in backing bean.

    I have a jsp page which contains three buttons, and based on a session level state, only one shown at the beginning. Once this button is clicked, the other two are shown and the first one is hidden.
    When the first button (add) is clicked, the other two are shown correctly. But when I clicked any one of them, none of their backing bean methods are called. I checked the log, no exception.
    Then I tried to show all buttons at begining, and click them. Both backing bean methods are invoked.
    Did I miss something in the life cycle of JSF?
    Here is the part of jsp page:
    <h:commandButton action="#{manageBranches.doAddBranches}" image="/images/add.gif" rendered="#{!manageBranches.isAdd}"
    styleClass="toolbaricon" title="#{messages['branches.dropdown.add.branches']}"
    onmouseover="swapImage( this, 'add.gif', 'add_down.gif' );"
    onmouseout="swapImage( this, 'add.gif', 'add_down.gif' );" />
    <h:commandButton action="#{manageBranches.doEditBranches}" image="/images/edit_icon.gif" rendered="#{manageBranches.isAdd}"
    styleClass="toolbaricon" title="#{messages['branches.dropdown.edit.branches']}"
    onmouseover="swapImage( this, 'edit_icon.gif', 'edit_icon_down.gif' );"
    onmouseout="swapImage( this, 'edit_icon.gif', 'edit_icon_down.gif' );" immediate="true" />
    <h:commandButton action="#{manageBranches.doSaveBranches}" image="/images/save.gif" rendered="#{manageBranches.isAdd}"
    styleClass="toolbaricon" title="#{messages['branches.dropdown.save.branches']}"
    onmouseover="swapImage( this, 'save.gif', 'save_down.gif' );"
    onmouseout="swapImage( this, 'save.gif', 'save_down.gif' );" />
    Here are corresponding backing bean methods:
         public String doAddBranches()
              Logger.logEnterPublic(MY_CLASS, "doAddBranches()");
              setIsAdd(true);
              return null;
         public String doSaveBranches()
              Logger.logEnterPublic(MY_CLASS, "doSaveBranches()");
              String forward = null;
              if(addedBranchIds ==null || addedBranchIds.length()==0)
    MessageFactory.addErrorMessage( null, "branches.selectAtLeastOneBranch", null );
    this.successMsg = false;
    return forward;
              else
                   String[] branchIdArray = addedBranchIds.split(":");
              this.successMsg = true;
              //TODO: add save logic
              return forward;
         public String doEditBranches()
              Logger.logEnterPublic(MY_CLASS, "doEditBranches()");
              String forward = null;
              setIsAdd(false);
              return forward;
    The add button worked fine. But when save and edit button were shown and add button was hidden. Both save and edit button can't access the backing bean methonds. I put a break point on the constructor of the backing bean, it WAS accessed!
    Very confusing!
    Thanks for any helps.
    jm.

    Ok, I'm not 100% on this, but it's something you can try. In your action methods, you often return null when you want the page to just be reloaded. I believe in JSF, returning null and returning a string that represents the same page is quite different. I think this is because the component tree will get re-initialized when you return a proper string. It's quite possible that you need to have the component tree re-initialized for everything to work properly.
    Therefore, whenever you want to reload "pageA" then return an abbreviation called "A" (or whatever you want). In your faces-config.xml set up a rule that when outcome "A" is received (while on pageA) then load pageA.jsp.
    Hope that makes some sense! Let me know if it works.
    CowKing

  • Removing the vertical divider after the actions view format menu.

    Hi,
    i have a table in a applications table component on my UI. i've a UX requirement to remove the Actions, View, format menu along with the vertical divider next to these menus that comes with the applications table component. i could get rid of the three menus but have not been able to get rid of the vertical divider. so the apps table looks a li'l odd now. Any suggestions on how to get rid of the divider?

    Hi ,
    We the world outside Oracle donot use the Applications Table which is a purely ApplCore component.
    Please post this question on the internal ADF Frontend forum @ myforums.oracle.com

  • Re: JDeveloper debugger crashes the JRE in backing bean of a jsff.

    Have you find a solution for this problem ?
    I face the same problem , I noticed the problem occurred when you change the code in previous written method in managed bean
    Regards,

    fine,
    thanks for your replay Timo,
    first of all I'm working in the following environment:
    OS Windows 7 Ultimate Service Pack 1 64 bit
    JDeveloper 11.1.2.4.0
    Using the embedded  JDK 6.0_24-b50
    Also I tried to solve the problem So I change the JDK to another Installed in my device 6.0_41 , but with no benefit.
    Problem Description :
    I create an ADF page fragment , create a manged bean (Request scope) , and create Some action listeners in the managed bean, also I change the "Hot class reload policy" from Tools -- Preferences -- Run -- WebLogic and make it Fast Swap, after that I run my application in debug mode. the page work properly but sometimes If you change the code at run-time in the manged bean and recompile the managed bean and try put break point , The embedded Weblogic application Server automatically shut down!! and raise the following in stack trace:
    # A fatal error has been detected by the Java Runtime Environment:
    #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6da61294, pid=1216, tid=6860
    # JRE version: 6.0_24-b50
    # Java VM: Java HotSpot(TM) Client VM (19.1-b02 mixed mode windows-x86 )
    # Problematic frame:
    # V  [jvm.dll+0x1c1294]
    # An error report file with more information is saved as:
    # C:\Oracle\Middleware\system11.1.2.4.39.64.36.1\DefaultDomain\hs_err_pid1216.log
    # If you would like to submit a bug report, please visit:
    #   http://java.sun.com/webapps/bugreport/crash.jsp
    [Server Instance IntegratedWebLogicServer is shutting down.  All applications currently running will be terminated and undeployed.]
    [Application termination requested.  Undeploying application AppointmentApp.]
    Debugger connection to debuggee process has been lost.
    Process exited.
    Debugger disconnected from local process.
    [04:35:25 PM] [J2EE Deployment SPI:260010]Unable to connect to 't3://localhost:7101' as user, 'weblogic'. Error received: null
    [04:35:25 PM] [J2EE Deployment SPI:260010]Unable to connect to 't3://localhost:7101' as user, 'weblogic'. Error received: null
    [04:35:25 PM] [J2EE Deployment SPI:260010]Unable to connect to 't3://localhost:7101' as user, 'weblogic'. Error received: null
    [04:35:25 PM] t3://localhost:7101: Destination unreachable; nested exception is:
      java.net.ConnectException: Connection refused: connect; No available router to destination
    [04:35:25 PM] Destination unreachable; nested exception is:
      java.net.ConnectException: Connection refused: connect; No available router to destination
    #### Cannot terminate application AppointmentApp due error undeploying from IntegratedWebLogicServer.
    [Application AppointmentApp stopped and undeployed from Server Instance IntegratedWebLogicServer]
    [sending request to shutdown server...]
    C:\Oracle\Middleware\system11.1.2.4.39.64.36.1\DefaultDomain\bin\stopWebLogic.cmd
    Stopping Weblogic Server...
    Initializing WebLogic Scripting Tool (WLST) ...
    Welcome to WebLogic Server Administration Scripting Shell
    Type help() for help on available commands
    Connecting to t3://localhost:7101 with userid weblogic ...
    This Exception occurred at Thu Jul 11 16:35:34 EEST 2013.
    javax.naming.CommunicationException [Root exception is java.net.ConnectException: t3://localhost:7101: Destination unreachable; nested exception is:
      java.net.ConnectException: Connection refused: connect; No available router to destination]
      at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:40)
      at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLInitialContextFactoryDelegate.java:788)
      at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:366)
      at weblogic.jndi.Environment.getContext(Environment.java:315)
      at weblogic.jndi.Environment.getContext(Environment.java:285)
      at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:117)
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
      at javax.naming.InitialContext.init(InitialContext.java:223)
      at javax.naming.InitialContext.<init>(InitialContext.java:197)
      at weblogic.management.scripting.WLSTHelper.populateInitialContext(WLSTHelper.java:520)
      at weblogic.management.scripting.WLSTHelper.initDeprecatedConnection(WLSTHelper.java:573)
      at weblogic.management.scripting.WLSTHelper.initConnections(WLSTHelper.java:313)
      at weblogic.management.scripting.WLSTHelper.connect(WLSTHelper.java:203)
      at weblogic.management.scripting.WLScriptContext.connect(WLScriptContext.java:61)
      at weblogic.management.scripting.utils.WLSTUtil.initializeOnlineWLST(WLSTUtil.java:147)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.python.core.PyReflectedFunction.__call__(Unknown Source)
      at org.python.core.PyMethod.__call__(Unknown Source)
      at org.python.core.PyObject.__call__(Unknown Source)
      at org.python.core.PyObject.invoke(Unknown Source)
      at org.python.pycode._pyx4.connect$1(<iostream>:16)
      at org.python.pycode._pyx4.call_function(<iostream>)
      at org.python.core.PyTableCode.call(Unknown Source)
      at org.python.core.PyTableCode.call(Unknown Source)
      at org.python.core.PyFunction.__call__(Unknown Source)
      at org.python.pycode._pyx15.f$0(C:\Oracle\Middleware\system11.1.2.4.39.64.36.1\DefaultDomain\shutdown.py:6)
      at org.python.pycode._pyx15.call_function(C:\Oracle\Middleware\system11.1.2.4.39.64.36.1\DefaultDomain\shutdown.py)
      at org.python.core.PyTableCode.call(Unknown Source)
      at org.python.core.PyCode.call(Unknown Source)
      at org.python.core.Py.runCode(Unknown Source)
      at org.python.util.PythonInterpreter.execfile(Unknown Source)
      at weblogic.management.scripting.WLST.main(WLST.java:124)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at weblogic.WLST.main(WLST.java:29)
    Caused by: java.net.ConnectException: t3://localhost:7101: Destination unreachable; nested exception is:
      java.net.ConnectException: Connection refused: connect; No available router to destination
      at weblogic.rjvm.RJVMFinder.findOrCreateInternal(RJVMFinder.java:216)
      at weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:170)
      at weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:153)
      at weblogic.jndi.WLInitialContextFactoryDelegate$1.run(WLInitialContextFactoryDelegate.java:345)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
      at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:340)
      ... 38 more
    Caused by: java.rmi.ConnectException: Destination unreachable; nested exception is:
      java.net.ConnectException: Connection refused: connect; No available router to destination
      at weblogic.rjvm.ConnectionManager.bootstrap(ConnectionManager.java:470)
      at weblogic.rjvm.ConnectionManager.bootstrap(ConnectionManager.java:321)
      at weblogic.rjvm.RJVMManager.findOrCreateRemoteInternal(RJVMManager.java:254)
      at weblogic.rjvm.RJVMManager.findOrCreate(RJVMManager.java:197)
      at weblogic.rjvm.RJVMFinder.findOrCreateRemoteServer(RJVMFinder.java:238)
      at weblogic.rjvm.RJVMFinder.findOrCreateRemoteCluster(RJVMFinder.java:316)
      at weblogic.rjvm.RJVMFinder.findOrCreateInternal(RJVMFinder.java:205)
      ... 44 more
    Problem invoking WLST - Traceback (innermost last):
      File "C:\Oracle\Middleware\system11.1.2.4.39.64.36.1\DefaultDomain\shutdown.py", line 6, in ?
      File "<iostream>", line 22, in connect
      File "<iostream>", line 646, in raiseWLSTException
    WLSTException: Error occured while performing connect : Error getting the initial context. There is no server running at t3://localhost:7101
    Use dumpStack() to view the full stacktrace
    Done
    Stopping Derby Server...
    So how can I solve This problem?

  • ADF BC/Faces - Order of validation / backing bean action problem

    Hello,
    I want the user to enter the same "operation date" into all adf faces table rows created in one batch (one transaction).
    So I removed operation date field from the table and added "unbound" date field above the table. The date field value is then copied into all new rows in background. This process is invoked from backing bean from Commit button actionListener method.
    The problem is the validation of the operation date in entity is executed before a new date value is copied into the date attribute (validation of model is in JSF lifecycle executed prior invoking actions in backing beans).
    It means the user can enter dead lock when he enters invalid date (for example date higher then a valid value).
    Then after commit:
    1. First validation is ok (wrong date value haven't been copied into model yet)
    2. backing bean copy action is executed - model now contains wrong date value
    3. Validation before commit isn't successfult - error message is displayed
    4. User corrects the date value and presses commit again but:
    5. First validation is not successful - model still contains recent wrong date value - error message is displayed again
    6.There is no way out from this situation
    I'm going to override lifecycle to be able to invoke copy method before validation cycle. Is this solution acceptable? Do you have any other suggestion?
    Thank you.
    Rado

    hi Rado
    Would it make sense to design your ADF BC View Objects in some kind of master-detail shape that fits your data?
    View Object : OperationMaster (OperationDateAttr, ...)
    View Object : OperationDetail (OperationAttr1, OperationAttr2, ...)
    View Link : OperationDetailForMasterVL (based on some attribute that keeps the detail rows together)
    You would need some Application Module method that does the "row batch setup", but it look like your already have something like this.
    A change to OperationMaster.OperationDateAttr could update all its detail rows date attribute.
    I think that building a UI on this would be less "view layer dependant".
    Just a suggestion.
    regards
    Jan Vervecken

  • How to track PropertyChangeEvent for the backing beans?

    Hello
    I'm working on JSF 1.2 + JDK 1.6. Would like to know wether any direct support for tacking the PropertyChangeEvent for the backing bean. Objective is to keep track of the modified entities ( backing bean) and update the corresponding Database records at later stage with the modified attribute/record.
    E.g:
    Assume a datatable is populated with list, and 3 rows alone is modified, So the DB update is supposed to happen only for those rows. I prefer to have the PropertyChange tracking logic in one place. Dont want to add PropertyChangeListener for all backing beans.
    Can anybody help me on this.
    Thanks in advance
    Jobinesh
    Edited by: JobineshP on Jun 20, 2008 6:52 AM

    This is no direct support in JSF for PropertyChangeEvents.
    As for other solutions to your problem, first looking specifically at the database updates, Hibernate tracks modifications to fields and can be configured to only update the needed columns (see the dynamic-update attribute). So perhaps Hibernate can suit your needs or you could use their techniques to solve your problem.
    Taking a wider view of the general problem of adding PropertyChangeListeners to managed beans, I would be inclined to use Spring and AOP to add the PropertyChangeEvents to all the setters. Spring might also help the configuration of the PropertyChangeListeners. Although I have to say that I think that PropertyChangeEvents are of limited use in a web application.
    Another approach might be to hook into the JSF EL expression engine. You could add a special ELResolver whose purpose is to discover when the property changes happen. The drawback is that all the setting must be done via the EL in order for this to work.

  • We should NEVER use the session back bean?

    Because the user can open a new window by right click the link, and the session scope back bean is not thread-safe.
    So we should forget it?

    Your concern makes really no sense, or you must be storing request scoped data in a session scoped bean instead of a request scoped bean, which can indeed lead to undesireable behaviour in multiple requests on the same session.

  • How to show popup from backing bean code immediately?

    Hi,
    I'm using JDeveloper 11.1.2.1.0 and have problems with showing popups. I have a button with an action on my page and a method in backing bean.
    I want to rise up few popups from this method in backing bean (for example just an anouncement that something will happen) or a dialog
    (for example a question if you want to continue).
    I understand how to get a dialog response to deal with it in code, but the problem is that the popup doesn't show up immediately, but only when
    this method called on button finishes. I'd like to handle dialog responses in the middle of the action and then the code to continue with the execution.
    Here is my backing bean code:
    private RichPopup popup;
    public String test() {
    //Some code...
    RichPopup.PopupHints hints = new RichPopup.PopupHints();
    popup.show(hints);
    //Here is the place for code which I want to be executed after popup closes,
    //but is executed before the popup shows...
    return null;
    And here is part of my jssf:
    <af:commandButton text="Test" id="cb1"
    action="#{popupBean.test}"/>
    <af:popup id="popup" binding="#{popupBean.popup}">
    <af:dialog id="dialog" type="yesNo"
    title="Dialog"
    dialogListener="#{popupBean.onDialogAction}"
    binding="#{popupBean.dialog}" clientComponent="true">
    <af:outputText value="Do you want to continue?" id="ot1"/>
    <af:clientListener method="onDialogCancel" type="dialog"/>
    <af:serverListener type="DialogCancelHandlerEvent" method="#{popupBean.onDialogCancel}"/>
    </af:dialog>
    </af:popup>
    Can someone give me some answer how to show the popup from backing bean code immediately?
    Thanks in advance,
    Tina

    If you want to execute code after popup closes, then put this code in PopupCanceledListener or in DialogListener(you can't block method execution).
    Dario

  • Web services and ADF 11g- get Result from backing bean

    I'm executing an action from backing bean (call Web service that returns complex data types)
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("unesiPonudu");
    Object result = operationBinding.execute();
    result is instance of oracle.adf.model.adapter.dataformat.XMLHandler$DataCollection but DataCollection is not accessible.
    How to get results from method?
    Tnx,
    Andreja

    Hi,
    there should be a result iterator in the Executables section which cotnains the result. If not, create it from the WS result entry in the DC palette. Once this iterator gets updated, you get the data from this iterator as it would be the case of a table accesses the WS
    Frank

  • 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

  • About backing bean method's invokation

    Hi,
    I have a backing bean method binded to a component:
    <af:selectOneChoice value="#{bindings.managerId.inputValue}"
    label="Manager" valign="middle"
    binding="#{backing_searchDocuments.managersList}"
    valuePassThru="true" immediate="false"
    rendered="#{bindings.ListManagersIterator.estimatedRowCount > 1}">
    <f:selectItems value="#{bindings.managerId.items}"/>
    When page refreshes component executes his binding method. But in some cases, actually when I press the commandMenuItem leading to the same page where I am it seems that it doesn't get invoked.. how can I manage the invocation of backing bean's methods? I need it invoked every time any request is made.. How to do that?

    Mario,
    this method is executed when the component re-draws. So anything other than a PPR request makes this binding method being called.
    If PPR is used with your commandMenuItem, them make sure the PPR trigger is set to refresh the component.
    I don't know what code it is that you need to execute each time, but maybe putting this on a action listener is a better idea
    Frank

  • Backing bean properties not getting updated

    I have an input text in my JSP page and it is component-bound to backing bean. The problem is that when I change value of the InputText in the JSP, the value is not getting updated in the backing bean.
    Here is the InputField definition in JSP page.
    <h:inputText binding="#{backing_employeeEdit.firstName}"
    id="firstName"/>
    and here is the setter in backing bean
    public void setFirstName(HtmlInputText inputText1) {
    this.firstName = inputText1;
    Pls note that there is no validation errors because the page navigates successfully. The only problem is that new value is not updated.

    I don't know, wht exactly u wants to do... Here is java code and is working fine for me...
    Emp.java
    public void action() {
         System.out.println(inputText.getValue());
         Emp tt = new Emp();
         inputText.setValue(inputText.getValue().toString()+"bilal");
         tt.setInputText(inputText);
         System.out.println(inputText.getValue());
    JSP...
    <f:view>
    <h:form>
    <h:inputText binding="#{emp.inputText}" />
    <h:commandButton value="submit" action="#{emp.action}" />
    </h:form>
    </f:view>
    faces-config file contents....
    <managed-bean>
              <managed-bean-name>emp</managed-bean-name>
              <managed-bean-class>
                   com.nous.application.Emp
              </managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    Here scope has to be session, otherwise u will lose old value...

Maybe you are looking for

  • Reflashing Nokia C6-00

    Please Help. How to reflash Nokia C6-00? Thank you in advance

  • HT1498 I am having trouble renting tonight from Apple TV

    I am having trouble renting tonight from Apple TV

  • MSI GT683DXR - HOW TO SWITCH TO RAID?

    Hi everyone, I'm inclined to switch to RAID 0 on my MSI GT683DXR. (It's the French model but I've put an English Keyboard in). I have 2x 750GB Hard Drives inside. I would very much appreciate if somebody could guide me on how to go about the process.

  • PDF application that can copy and paste

    Hi, is there a PDF reader that I can use to read iBooks and then be able to copy and paste certain sections? I have PDF reader pro but it does not have the copy/paste feature and I'm not able to find anything else suitable. Please can you advise? Tha

  • How to confirm if Bug 5709504 fixed in 10.2.0.4

    Hello , trying to delete node from 10.2.0.2 rac , failed due to Bug 5709504 closed as duplicate of 4727330 mentioned bug marked as fixed in 11.1 , and not included in bugs fixed in Note 401436.1 However , deleting the node completed successfully on 1