Generic Way to Catch Backing Bean Exceptions Possible ?

For customizing the way errors are shown to the user I already have:
- Override the method reportErrors(PageLifecycleContext) as described in the section "20.8.1 How to Change Exception Handling"
- Created a custom subclass of DCJboDataControl (as example#55 on Steve blog) and override the beginRequest() for exceptions like a JDBC connection error.
However I have one more situation I would like to have a generic solution and that is for the backing action methods that can throw exceptions not being handled by a try {} catch {} statement. Ex: NullPointerException. Currently what happens in that case is that a 500 Internal Server Error page is shown to the user.
I was thinking of having a servlet filter, but I am not sure if that is the best way to achieve it.
Any thought is welcomed.
Thanks,
Claudio.

Sure, but I warn you, that example won't be portable directly from a JSF implementation to another (RI vs. MyFaces mainly) as you have to use directly an implementation class. It's really a minor change from one implementation to another though.
There's a portable way, but it implies rewriting the full Lifecycle class on your own (which I did to add new features as well, but you should do that until you're fully comfortable with the specification). Anyway, here's the simple example
In faces-config.xml
<factory>
  <lifecycle-factory>mypackage.MyLifecycleFactory</lifecycle-factory>
</factory>In MyLifecycleFactory class
public class MyLifecycleFactory extends LifecycleFactoryImpl
  private Map<String, Lifecycle> cache;
  public MyLifecycleFactory()
    cache = new HashMap<String, Lifecycle>(3);
  public Lifecycle getLifecycle(String lifecycleId)
    Lifecycle lifecycle = cache.get(lifecycleId);
    if (lifecycle == null)
      lifecycle = super.getLifecycle();
      if (lifecycle == null)
        return null;
      lifecycle = new LifecycleDecorator(lifecycle);
      cache.put(lifecycleId, lifecycle);
    return lifecycle;
}Where LifecycleFactoryImpl is com.sun.faces.lifecycle.LifecycleFactoryImpl in JSF RI and org.apache.myfaces.lifecycle.LifecycleFactoryImpl in MyFaces (that's the only change you have to do for it to work in an implementation or another).
In LifecycleDecorator class
public class LifecycleDecorator extends Lifecycle
  private Lifecycle wrapped;
  public LifecycleDecorator(Lifecycle wrapped)
    this.wrapped = wrapped;
  public void execute(FacesContext context)
    try
      wrapped.execute(context);
    catch (Exception e)
      // Do something
  public void render(FacesContext context)
    try
      wrapped.render(context);
    catch (Exception e)
      // Do something
  public void addPhaseListener(PhaseListener listener)
    wrapped.addPhaseListener(listener);
  public void removePhaseListener(PhaseListener listener)
    wrapped.removePhaseListener(listener);
  public PhaseListener[] getPhaseListeners()
    return wrapped.getPhaseListeners();
}Regards,
~ Simon

Similar Messages

  • Is there any way to create backing bean, After page gets created?

    Hi
    Any one can please answer to my quick question !!!
    Is there any way to create the backing bean ,after a jsf page gets created using ADF ..?
    When i first time created the jsf jppx page i unchecked the option to generate backing bean, but later some time I would like to have backing bean for the newly created page. so is there any way to create backing bean ...?
    Thanks in Advance

    Have your page in the visual design mode then go to the Design->Page Properties menu and you'll be able to select auto-bind on the second tab.

  • Blank page on backing bean exception

    When there is exception in the backing bean, a blank page is displayed. I was expecting response with status code 500. When I debug the http response the status code is 200. I have configured the webapp to display error page on status code 500. Since it is not returning status code 500, this page is not displayed.
    In web.xml
    <error-page>
    <error-code> 500 </error-code>
    <location>/500.jsf</location>
    </error-page>
    I am using Sun RI Implementation of JSF on weblogic 10.3
    Please some one help me.
    Here's a stack trace.
    Note :I purposely introduced devide by zero exception in my backing bean action.
    ####<Mar 11, 2009 10:57:16 AM PDT> <Error> <HTTP> <KOLCHK1-D1> <AdminServer> <[ACTIVE] ExecuteThread: '21' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1236794236482> <BEA-101107> <[weblogic.servlet.internal.WebAppServletContext@1943319 - appName: 'sam', name: 'hcp', context-path: '/hcp', spec-version: '2.5'] Problem occurred while serving the error page.
    javax.servlet.ServletException: / by zero
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
         at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:502)
         at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:251)
         at weblogic.servlet.internal.ForwardAction.run(ForwardAction.java:22)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
         at weblogic.servlet.internal.ErrorManager.handleException(ErrorManager.java:144)
         at weblogic.servlet.internal.WebAppServletContext.handleThrowableFromInvocation(WebAppServletContext.java:2244)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2093)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

    Then the problem lies somewhere else. I can't determine it based on the as far given information.

  • JSF Backing bean / JSP interaction questions

    A few questions about JSF beans and JSP page interactions. Bear in mind that I'm new to both JSP and JSF, so a solution that might be obvious to the rest of the world may be new to me.
    1. Can I pass a parameter to the backing bean method from an "action" attribute:
    <h:commandLink action="#{TableData.SortRec}">
    <h:outputText value="#{msgs.selectedHeader}"/>
    </h:commandLink>
    I'd like to call the same method from several controls, but pass it a parameter to determine which field to sort on.
    2) Is there a way for a backing bean method to determine which control invoked it?
    3) Is there a way to access JSF backing bean methods from JSP tags. I'd like to do some conditional page assembly based on a JSF bean property... JSF doesn't appear to have a conditional like JSP's <c:if>, but I could use JSP's if it could access the JSF bean.

    Could you pl tell me how to pass parameter thru CommandButton
    I have the following situation
    1) greetingList.faces which list the Ids & greeting Text
    Id Text
    1 Hello World
    2 Hello World
    2) Pl note Ids are h:commandLink. A click on the Id will render greetingForm.faces with data pertaining to that Id and with Update h:CommandButton
    3) When i click Update button it results in the following error
    javax.faces.FacesException: Error calling action method of component with id greetingForm:_id4
    Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{greetingForm.update}
    Caused by: java.lang.NullPointerException
    So i verified with h:message that Id is passed as Null when click on Update button. I also checked greetingForm.faces has a not null value by printing <h:outputText value="#{greetingForm.message.id}"/>
    So i guess the Id value is overwriteen with null. Also i have defined Id as property in managed bean
    <managed-bean-name>greetingForm</managed-bean-name>
    <managed-bean-class>com.mycompany.GreetingForm</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
    <property-name>id</property-name>
    <value>#{param.id}</value>
    </managed-property>
    Any pointers/suggestions at the earliest on how to pass the value of Id on a click of update button from greetingForm.faces to greetingForm.java will be highly appreciated
    I am willing to upload my war file
    Regards
    Bansi

  • Catch all uncaught exceptions in GUI

    Is there a way to catch any uncaught exceptions within my GUI so that I can do some special handling instead of it being echoed to the console?

    It's actually an AWT class that's catching the errors: EventDispatchThread. There is a way to override that mechanism, but it's unsupported, and the only place it's documented is in the source code of that class. Here's an example.
    public class MyApp
      public static void main(String[] args)
        System.setProperty("sun.awt.exception.handler",
                           "MyApp$EDTErrorHandler");
        // create and show the GUI
       * This class will be instantiated by the
       * EventDispatchThread the first time it
       * encounters an exception or error.
      public static class EDTErrorHandler
         * This method is invoked by the AWT event
         * dispatch mechanism when an unexpected
         * exception or error is thrown during
         * event dispatching.
        public void handle(Throwable t)
          // handle the error
    }

  • Can I catch the resulting TopLink query in the JSF backing bean?

    Hello!
    I'm using a JSF in my application. In my case, data on the JSF Pages is based on a TopLink queries, which usually have some parameters. Such a construction works fine except one moment.
    For export data purposes, I need to catch the generated text of query evidently, suppose, in a Page's backing bean.
    Is it possible to perform this action and how to?
    Thanks.

    generally speaking, you can just throw one exception a time. you can throw your own application but you can't throw both SQLException and your own.

  • Best way to retreive an attributeValue from the bindings in a backing bean?

    What is the best way to retreive a value from an interator in your data bindings inside a backing bean?
    I can come up with a way were i resolve the value of an expression like #{bindings.myAttribute.value}
    Is this the best way or is there an easier?
    I can also place a hidden inputField were i bind the value to the attribute in my bindings and set the bindings of the input field to my backing so i can just call the .getValue in my backing bean...

    Yannick
    What is the best way to retreive a value from an interator in your data bindings inside a backing bean? Using JDeveloper 11.1.1.3.0 I created an example application
    at http://www.consideringred.com/files/oracle/2010/Thread1665841AttributeValuesApp-v0.01.zip
    It illustrates the behaviour for 3 different approaches to get an attribute value in a managed bean:
    public class WithAttributeValues
      public int getMyIdFromEL()
        return (Integer)ELHelper.get("#{bindings.myId.inputValue}");
      public int getMyIdFromAttributeBinding()
        BindingContainer vBindingContainer =
           BindingContext.getCurrent().getCurrentBindingsEntry();
        ControlBinding vControlBinding = vBindingContainer.getControlBinding("myId");
        AttributeBinding vAttributeBinding = (AttributeBinding)vControlBinding;
        return (Integer)vAttributeBinding.getInputValue();
      public int getMyIdFromIterator()
        BindingContainer vBindingContainer =
           BindingContext.getCurrent().getCurrentBindingsEntry();
        DCBindingContainer vDCBindingContainer = (DCBindingContainer)vBindingContainer;
        DCIteratorBinding vDCIteratorBinding =
           vDCBindingContainer.findIteratorBinding("findSomeMyRowsIterator");
        Row vRow = vDCIteratorBinding.getCurrentRow();
        return (Integer)vRow.getAttribute("myId");
    }For some reason the approach using getMyIdFromIterator() does not behave as intended when navigating the current row.
    see screencast at http://www.screencast.com/t/nIJ3DpsNE9Y
    Maybe John Stegeman can explain why that is because it is basically the same approach as he suggested in this forum thread.
    But if you don't have an attribute binding because you only use the iterator... Is it an option to create an attributeValue and bind it to the iterator so you can use it in your backing bean that way? Based on my findings above, using attributeValues bindings seems to be preferable.
    or is it only possible when you realy have an inputField bound to the attributeValue? The example application in Thread1665841AttributeValuesApp-v0.01.zip does not have any af:inputText components.
    Your question about "the best way" made me wonder if that wouldn't require JSR 227 API, so I posted that question in another forum thread, "How to get an attribute value using JSR 227 API ?"
    at How to get an attribute value using JSR 227 API ?
    regards
    Jan Vervecken

  • How to handle exception on a backing bean constructor ?

    Hello,
    I would like to handle the exceptions throw on the constructor of a backing bean, and redirect the user to a "service not available" page.
    When I use "request.sendRedirect()" method to redirect the user to such page, I logically got an "IllegalStateException: Cannot forward a response that is already committed".
    Do you have any idea how can I redirect or forward a user to a page when the response is already commited? Is it possible to use servlet filter and do a forward after the doFilter()?
    Thank you.

    Just throw the exception and map an error page in the web.xml.
    <error-page>
        <exception-type>java.lang.Exception</exception-type>
        <location>error.jsp</location>
    </error-page>

  • 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

  • Any way to catch exceptions from asynchronous call that short dumps?

    Hi,
    We have a requirement for a program that we know will occasionally short dump under normal conditions. We want to use an asynchronous call to let it plow ahead. To that end I've created a test program that calls a divide by zero func that short dumps. It tests fine because it proceeds afterward. Better yet would be a way to capture some information from the function where the dump happens and raise it to the calling program. Any ideas?
    Thanks,
    Doug
    Example:
    REPORT  ZJUNK2
    data: junkdone TYPE c VALUE space,
    write: / 'before'.
    CALL FUNCTION 'ZJUNK2'
      STARTING NEW TASK 'z_junktask'
      PERFORMING junk ON END OF TASK
          EXCEPTIONS
             communication_failure = 1
             system_failure        = 2
             other_exception = 3.
    Receive remaining asynchronous replies
      wait until junkdone = 'X'.
    write: / 'after'.
    FORM junk  USING taskname.
    RECEIVE RESULTS FROM FUNCTION 'ZJUNK2'
          EXCEPTIONS
             communication_failure = 1
             system_failure        = 2
             other_exception = 3.
      junkdone = 'X'.
    ENDFORM.
    FUNCTION ZJUNK2.
    ""Local Interface:
    data: i type i.
    i = 1 / 0.
    ENDFUNCTION.

    Hey Doug.  You need to catch the class exception cx_root in your function, then pass back the message.  This will catch a lot of system exceptions, but probably not all.
    DATA: junkdone TYPE c VALUE space.
    DATA: lv_message TYPE char255.
    WRITE: / 'before'.
    CALL FUNCTION 'ZJUNK2'
      STARTING NEW TASK 'z_junktask'
      PERFORMING junk ON END OF TASK
      EXCEPTIONS
        communication_failure = 1
        system_failure        = 2
        other_exception       = 3.
    * Receive remaining asynchronous replies
    WAIT UNTIL junkdone = 'X'.
    WRITE: / 'after'.
    IF lv_message IS NOT INITIAL.    "<-- Check for error and write message
      WRITE:/ lv_message.
    ENDIF.
    *&      Form  junk
    FORM junk USING taskname.
      RECEIVE RESULTS FROM FUNCTION 'ZJUNK2'
           IMPORTING
                e_message = lv_message   "<-- Import the message
           EXCEPTIONS
                communication_failure = 1
                system_failure = 2
                other_exception = 3.
      junkdone = 'X'.
    ENDFORM.                    "junk
    FUNCTION zjunk2.
    *"*"Local Interface:
    *"  EXPORTING
    *"     VALUE(E_MESSAGE) TYPE  CHAR255
      DATA: lo_exception TYPE REF TO cx_root.
      DATA: i TYPE i.
      TRY.
          i = 1 / 0.
        CATCH cx_root INTO lo_exception.
          e_message = lo_exception->get_text( ).
      ENDTRY.
    ENDFUNCTION.
    Regards,
    Rich Heilman

  • Is it possible to call a custom method in App Module from a backing bean?

    I would like to know if a custom method in App Module can be called from inside a backing bean.
    I am not sure if it is logically right to call, from a backing bean, a custom method in App Module. But would like to know if that makes sense or if it is possible.

    Hi..
    Yes it is possible.You have to add that method for client interface of AppModule.Now you can see that method in Data Controls(Refresh the data control). To call this method using bean it should add as method action to bindings(Click Bindings>+>methodAction>and Create action binding).
    Now you can call this method in bean class.
    Check following example use this concept to execute view criteria
    http://adf-lk.blogspot.com/2011/05/oracle-adf-create-view-criteria-and_4727.html

  • TP4 / AF:REGION / What is the way to work with af:region and Backing Beans?

    Hello,
    I would be able to use the "af:region" component with a Backing Bean, but all examples I can found googling are with pageDef.
    So, I have been trying with different classes the way to solve this problem and I arrive to this:
    oracle.adf.controller.internal.binding.TaskFlowRegionModel
    Some code:
    task-flow-definition.xml
    <?xml version="1.0" encoding="windows-1252" ?>
    <adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
      <task-flow-definition id="taskDestinationA">
        <default-activity>destinationA</default-activity>
        <view id="destinationA">
          <page>/regionDestinationA.jsff</page>
        </view>
        <use-page-fragments/>
      </task-flow-definition>
    </adfc-config>
    adfc-config.xml
    <?xml version="1.0" encoding="windows-1252" ?>
    <adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
      <managed-bean>
        <managed-bean-name>backing_regionTest</managed-bean-name>
        <managed-bean-class>backing.RegionTest</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
        <!--oracle-jdev-comment:managed-bean-jsp-link:1regionTest.jspx-->
      </managed-bean>
    </adfc-config>
    regionTest.jspx
    <?xml version='1.0' encoding='windows-1252'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=windows-1252"/>
    <f:view>
    <af:document binding="#{backing_regionTest.document1}" id="document1">
    <af:form binding="#{backing_regionTest.form1}" id="form1">
        <af:region binding="#{backing_regionTest.region1}" id="region1"
                   value="#{backing_regionTest.regionModel}"/>
    </af:form>
    </af:document>
    </f:view>
    <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_regionTest-->
    </jsp:root>
    RegionTest.java
    import oracle.adf.controller.internal.binding.DCTaskFlowBinding;
    import oracle.adf.controller.internal.binding.TaskFlowRegionModel;
    import oracle.adf.view.rich.component.rich.RichDocument;
    import oracle.adf.view.rich.component.rich.RichForm;
    import oracle.adf.view.rich.component.rich.fragment.RichRegion;
    import oracle.adf.view.rich.model.RegionModel;
    public class RegionTest {
        private RichForm form1;
        private RichDocument document1;
        private RichRegion region1;
        private RegionModel regionModel;
        public RegionTest () {
            /*Here I try to put the same values as the constructor of TaskFlowId*/
            /*THERE IS NO DOCUMENTATION ANYWHERE :P*/
            DCTaskFlowBinding dctfb = TaskFlowRegionModel.getCurrentTaskFlowBinding("/WEB-INF/task-flow-definition.xml","taskDestinationA");
            //And here, dctfb is always NULL.
            /*I try removing the '.xml' extension of the name, but still not works*/
            //Fill the value of regionModel
            this.regionModel = new TaskFlowRegionModel(dctfb);
            /*Perhaps is better create a method to acquire the value,
              but I try in constructor first*/
        public void setForm1(RichForm form1) { this.form1 = form1; }
        public RichForm getForm1() { return form1; }
        public void setDocument1(RichDocument document1) { this.document1 = document1; }
        public RichDocument getDocument1() { return document1; }
        public void setRegion1(RichRegion region1) { this.region1 = region1; }
        public RichRegion getRegion1() { return region1; }
        public void setRegionModel(RegionModel regionModel) { this.regionModel = regionModel; }
        public RegionModel getRegionModel() { return regionModel; }
    regionDestinationA.jsff
    <?xml version='1.0' encoding='windows-1252'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <af:outputText value="Hello World!"/>
    </jsp:root>So, my problem is in Backing Bean class (RegionTest.java). I don't know how I can acquire 'DCTaskFlowBinding' instance value; well, I don't know if that is the way to acquire the value of TaskFlowRegionModel, and even I don't know if this is the way to set the value of RegionModel. I don't know all of this because there isn't documentation yet :P
    Some oracle-java-guru can help me, please?
    JVN
    PD: Environment: JDev TP4.

    Hi,
    your biggest problem is the use of internal classes that probably will change without further notice and lead to a broken application then
    I don't think that the region model is supposed to work without ADF binding in this release. If you need a page region then the Trinidad region should be helpful (though it doesn't support you with navigation cases as the taskflow does)
    I'l check internally if there is an option to do what you are trying to do. However, as mentioned, if you need to use internal classes then the answer probably is no.
    Frank

  • Centralized way of catching unexpected Exceptions in Java?

    Hi Guys,
    Is there a centralized way to catch unexpected Exceptions in Java?
    Here's an example:
    public static void main(String[] args)
        try
          new Thread()
         public void run()
           String s = null;
              //NullPointerException is thrown here
           s.indexOf(12);
          }.start();
        catch (Exception ex)
          System.err.println("This is not called");
          ex.printStackTrace();
      }Think about a program error, that the program is not prepared for, i.e. NullPointerException or an ArrayIndexOutOfBounds exception.
    What I'm after is not like "put critical block in try-catch", but something like registering a global ExceptionListener in java.lang.Runtime, a monitoring MBean or something that I could use in my program to do a simple exception logging.
    Any idea, help would be greatly appreciated!
    peter

    NullPointerException , IOException ....all are subclasses of the base class Exception, so catch(Exception) will catch any exception in the current thread. So modify ur code a bit
    public static void main(String[] args)
          new Thread()
         public void run()
           try{
           String s = null;
              //NullPointerException is thrown here
           s.indexOf(12);
    catch (Exception ex)
          System.err.println("This is not called");
          ex.printStackTrace();
          }.start();
    .....

  • Is there a way to get a (return) value back after running Javascript statements in the backing bean?

    I have a usecase  where I need to run a javascript function from within the backing bean and get the value returned by the function.
    Example:
              In Java I have two variables  x and y, I want the javascript to return the larger value z.
              This is what I'm doing, but I have no means to get the values of variable z.
              StringBuilder script = new StringBuilder();
              script.append("var  z;");
              script.append("var  x = " + x + ";");
              script.append("var  y = " + y + ";");
              script.append("if  (x > y)  z = x  else z = y");
              FacesContext fctx = FacesContext.getCurrentInstance();
              ExtendedRenderKitService erks = Service.getRenderKitService(fctx,
              ExtendedRenderKitService.class); erks.addScript(fctx, script);
         The actual usecase is a bit complicated. It's a dragNdrop paradigm.
         I cannot capture the muse Release event (DropEvent ?) in the client side as (most likely) it is captured by ADF.
         The drop target is a RichTextEditor. I need to convert the DropEvent.getDropX() and DropEvent.getDropY() to get the caret position in the text editor.
    Any other solution to the issue is highly appreciated.
    Thanks,
    -ab

    you can try it!
    erks.addScript(fctx, js_funcation_name("'"+x+"'","'"+y+"'","'"+x+"'","'"+x+"'",.....));//bean-> javaScript
    add javascript:
                   AdfCustomEvent.queue(p, 'XXXXX', {parameter:parameter_value},true);
    add:
    <af:serverListener type="XXXXX" method="#{ManageBean.funcation}"/>//js->bean

  • What is the best way to submit an ADF Faces form from a backing bean?

    I would like to submit a JSF form at the end of a backing bean method (actually a ReturnEvent), and wonder if someone could supply an example of the "best practices" approach.
    Thanks!!
    Jeffrey

    Thanks for the reply Frank!
    Actually, what I want would be the equivalent of a resetActionListener.
    After performing "bindings.getOperationBinding("DeleteTrip").execute()" I would like the page to redraw itself with empty controls.
    I have included a resetActionListener in my commandLink, but the page is not redrawn after the operation.
    If I hit the reload button on my browser (after the operation has completed), I get the desired behavior.
    I've just added this comment to someone else's question you replied to on the following thread:
    Re: How to programatically resetAction after rollback?
    Thanks again!!
    Jeffrey

Maybe you are looking for

  • Dodgy connection down to the exchange being overlo...

    can anyone tell me why i get this happen to me 20 + times a week, it lasts for anythign up to 2 hours before finally connecting me to the internet, some days it doesnt happen but most days it happens at least 5 times last week it must have happened 4

  • Why does scaling distort objects?

    I can't get certain graphics to scale down correctly correctly. Take a look at the 2 jpegs enclosed - one solid, the other with 1px outline. The graphic men were originally 40mm tall. In each case the one on the left is the original. The one on the r

  • Can't print photos from iphoto

    Am running snow leopard 10.6.2 and iphoto 09 version 8.1.1 When i try to print a photo an alert pops up saying "no available themes- there were no themes located. until at least one theme has been installed this feature will be unavailable" Help plea

  • Utilisation process In CIN

    Hi Experts, Here we are not using CIN fully,But planned to use CIN fully. Now our present condition is that, we done Capturing and  Posting excise invoice with RG23 A1ad A2 register in Purchase /stores.In sale, we create Excise invoice in Local,also

  • UWL RFC destination

    Hi expert, UWL is using FM SWN_UWL_GET_WORKLIST to retrieve data from backends. This function module is valid for ECC systems (NW 7.x>), do you know which FM is used by UWL when connecting to old R/3 System (NW 6.40<)? I saw that SWN_UWL_GET_WORKLIST