7 Replies Latest reply on Oct 28, 2003 5:28 PM by 236613

    Get aplication module from an event


      I need get the aplication module from an event:

      public static EventResult handleLovValidateEvent(
      BajaContext context,
      Page page,
      PageEvent event)
      System.out.println("[LovEvents]Lov Validate Event");

      ConsultasAppMod am= (ConsultasAppMod)ServletBindingUtils.getApplicationModule(context);
      ViewObject vo = am.findViewObject("EntidadesExternasView");

      String searchText = event.getParameter("searchText");

      EventResult result = new EventResult();

      result.setProperty("showWindow", Boolean.TRUE);
      result.setProperty("fieldText", "xpto");

      return result;

      but the variable "am" have null value, so when i try findViewObject i have a error :
      Unhandled Exception thrown: class javax.servlet.ServletException.
      What's wrong ??

      Eliseu Cartaxo
        • 1. Re: Get aplication module from an event

          For this to work, in your UIX XML file, in the event handler, you need to surround the call to your <method> handler with a findRootAppModule tag. Note also that you can put a findViewObject inside there in the handler in XML so that you can then use ServletBindingUtils.getViewObject directly instead of getting the AM first.

          An example, from the UIX Developer's Guide, is:
           <event name="goto" >
             <bc4j:findRootAppModule name="root" >
               <bc4j:findViewObject name="alpha" >
          For more information, see the UIX Developer's Guide in the JDeveloper help system or at http://helponline.oracle.com/uix/help/. (Click developer's guide, Integration with External Technologies, 16. Business Components for Java Integration.)

          If you continue having problems with this issue, please include the <handlers> section of your .uix file.

          UIX Team
          • 2. Re: Get aplication module from an event
            Sorry i forget to tell, i'm using Jdev10 with struts, bc4j and uix.

            Eliseu Cartaxo
            • 3. Re: Get aplication module from an event
              You may refer to http://otn.oracle.com/products/jdev/collateral/tutorials/9050/adfuix_tut.html

              Hope the following code snippet my help your question.

              protected void processGoSearchEvents(DataActionContext actionContext) throws IOException, ServletException
              HttpServletRequest request = actionContext.getHttpServletRequest();
              String search = request.getParameter("SearchInput");
              BindingContext myctx = actionContext.getBindingContext();
              DCDataControl mydc = myctx.getContext(request).getDefaultDataControl();

              Object mydata = mydc.getDataProvider();
              HRService myAM = (HRService)mydata;
              • 4. Re: Get aplication module from an event
                Another sample:

                import oracle.adf.model.BindingContext;
                import oracle.adf.model.binding.DCBindingContainer;
                import oracle.adf.model.binding.DCUtil;
                import oracle.cabo.servlet.*;
                import oracle.cabo.servlet.event.*;
                import oracle.jbo.uicli.binding.JUCtrlActionBinding;

                public class Class1 {
                public static EventResult handleLastEvent(BajaContext context,
                Page page,
                PageEvent event)
                String name = event.getName();
                if (name != null && name.equals("Last")) {
                HttpServletRequest request = context.getServletRequest();
                BindingContext bctx = DCUtil.getBindingContext(request);
                String modelRef = "untitled1UIModel";
                DCBindingContainer bc = DCUtil.findBindingContainer(bctx,
                if (bc != null)
                JUCtrlActionBinding action = (JUCtrlActionBinding)bc.findCtrlBinding("Last");
                return new EventResult(page);
                • 5. Re: Get aplication module from an event

                  Thanks for your help.
                  The first example it's good, and do what i want. But, i real need a second example.
                  But on this, hi can't get application module, i only get uiModel that belongs to a page event, i'm rigth?!

                  Eliseu Cartaxo
                  • 6. Re: Get aplication module from an event
                    You are almost there.
                    See bellow:

                    JUCtrlActionBinding action = (JUCtrlActionBinding)bc.findCtrlBinding("Last");
                    ApplicationModule am = action.getApplicationModule();
                    • 7. Re: Get aplication module from an event
                      If you reach the application modules, view objects, row set iterators... directly in your control layer, you violate the spirit of ADF data controls because ADF data controls abstract the implementation of a business service.

                      You had better use control action bindings, control value bindings.

                      You may refer to http://www.geocities.com/smuench/adfprimer/