This discussion is archived
6 Replies Latest reply: Nov 20, 2003 9:05 PM by 55663 RSS

DataProvider not called on every render?

4996 Newbie
Currently Being Moderated
I'm using JDev 10g preview. In the documentation for Data Binding, it says that a <method> specified in a <provider> tag "will be called once each time the page renders", but I don't think this is what I'm seeing.

I will post my page code and the provider method below. What I'm trying to accomplish is that, if the 'pageId' parameter is not present or has an invalid value, and the bean has not already been initialized, an error message displays. If the 'pageId' is present, it should be used to (re)initialize the bean.

I've put an output line ('Informant') at the top of the method call that returns the bean, but it's only printing when I first call the page (when I generally have not yet specified a 'pageId' parameter), not when I issue subsequent requests with a 'pageId' parameter. That is, I right-click on the page in JDev and run; debug line is printed and the page comes up with no parameter in the URL and prints the error message. Then, I add the '?pageId=1' and resubmit the request (hit enter) and the debug line is not printed and the page still renders with the error message.
<?xml version="1.0" encoding="windows-1252"?>
<page xmlns="http://xmlns.oracle.com/uix/controller"
      xmlns:ui="http://xmlns.oracle.com/uix/ui"
      xmlns:ctrl="http://xmlns.oracle.com/uix/controller"
      xmlns:html="http://www.w3.org/TR/REC-html40" expressionLanguage="el">
    <content>
        <dataScope xmlns="http://xmlns.oracle.com/uix/ui">
            <provider>
                <data name="pageBean">
                    <method class="com.avega.portlets.view.BeanProvider"
                            method="getPageBean"/>
                </data>
            </provider>
            <contents>
                <document>
                    <metaContainer>
                        <head title="Key Indicators Portlet"/>
                    </metaContainer>
                    <contents>
                        <body>
                            <contents>
                                <tableLayout borderWidth="1"
                                             rendered="${ not pageBean.inErrorState }">
                                    <contents>
                                        <rowLayout>
                                            <contents>
                                                <include node="${ctrl:parsePage(uix,'controlView')}"/>
                                                <include node="${ctrl:parsePage(uix,'displayLayout')}"/>
                                            </contents>
                                        </rowLayout>
                                    </contents>
                                </tableLayout>
                                <styledText text="${ pageBean.errorString }"
                                            rendered="${ pageBean.inErrorState }"/>
                            </contents>
                        </body>
                    </contents>
                </document>
            </contents>
        </dataScope>
    </content>
    <handlers>
        <event name="hide show">
            <set target="${uix.pageState}" property="${param.source}"
                 value="${param.event}"/>
        </event>
    </handlers>
</page>
Here is the method:
     public static Object getPageBean( RenderingContext context, String namespace, String name ) {

          Informant.debug( "BeanProvider.getPageBean" );

          BajaContext bajaContext = BajaRenderingContext.getBajaContext( context );
          HttpSession httpSession = bajaContext.getServletRequest().getSession();
          
          boolean newPageBean = false;
          
          PageBean pageBean = (PageBean)httpSession.getAttribute( PAGE_BEAN_ATTRIBUTE );
          if ( pageBean == null ) {
               pageBean = new PageBean();
               pageBean.setHttpSession( httpSession );
               httpSession.setAttribute( PAGE_BEAN_ATTRIBUTE, pageBean );
               newPageBean = true;
          }

          HttpServletRequest request =  bajaContext.getServletRequest();
          String pageId = request.getParameter(ViewConstants.PARAM_PAGEID);
          if ( newPageBean || !Strings.isNullOrEmpty( pageId ) ) {
          
               pageBean.setPageId( pageId );
               
               try {

                    pageBean.initialize();
                    pageBean.setControlViewBean( 
                         (PanelBean)pageBean.getPanelBeansByPortletPanel().get( 
                              pageBean.getPortletPage().getDisplayedControl()  ));

               } catch ( NullPointerException npe ) {
                    pageBean.setInErrorState(true);
                    pageBean.setErrorString("Unable to initialize PageBean. "+
                         "'pageId' is probably null or specified a non-existant Page.");
               }
          }

          
          return pageBean;
     }
Here is the server log:

03/11/18 16:52:32 Requested page = Page[name=page]
03/11/18 16:52:36 Rendering page = Page[name=page]
03/11/18 16:52:38 BeanProvider.getPageBean
03/11/18 16:52:47 Requested page = Page[name=page]
03/11/18 16:52:47 Event = null
03/11/18 16:52:47 Parameter pageId=1
03/11/18 16:52:47 Rendering page = Page[name=page]

  • 1. Re: DataProvider not called on every render?
    55663 Newbie
    Currently Being Moderated
    My tests seem to indicate that the method is getting
    called on every request (at least in IE 5.5). If I add a
    parameter to the URL my println happens. Also if I do
    a refresh page it happens as well. So I'm not sure
    what the problem is. What browser are you using?

    Also do you need to reset your inErrorState flag in
    the try section if things succeed?
  • 2. Re: DataProvider not called on every render?
    4996 Newbie
    Currently Being Moderated
    My tests seem to indicate that the method is getting
    called on every request (at least in IE 5.5). If I
    add a
    parameter to the URL my println happens. Also if I
    do
    a refresh page it happens as well. So I'm not sure
    what the problem is. What browser are you using?
    I've used both Mozilla 1.1 and IE 6.0, and I never see the println after the initial request.
    Also do you need to reset your inErrorState flag in
    the try section if things succeed?
    Yeah, I realized that after I posted the code, but that should have just left me seeing the error message /and/ the println. I've fixed the errorFlag, but I never see the println after the initial request.
  • 3. Re: DataProvider not called on every render?
    55663 Newbie
    Currently Being Moderated
    thats very strange, I just tried with IE 6.0 and Netscape
    7.1 and still my method data provider is getting called
    on every render. Are there any exeptions in the log
    file? Did you try quitting oc4j and restarting it?
  • 4. Re: DataProvider not called on every render?
    4996 Newbie
    Currently Being Moderated
    Hmmm... I tried a simple experiment with the code provided below, and in this case I /do/ see the println for every request. So there must be something in the code I posted above that is keeping the provider from being called. Any idea what it might be?
    <?xml version="1.0" encoding="windows-1252"?>
    <page xmlns="http://xmlns.oracle.com/uix/controller"
          xmlns:ui="http://xmlns.oracle.com/uix/ui"
          xmlns:ctrl="http://xmlns.oracle.com/uix/controller"
          xmlns:html="http://www.w3.org/TR/REC-html40"
          expressionLanguage="el">
        <content>
            <dataScope xmlns="http://xmlns.oracle.com/uix/ui">
                <provider>
                    <data name="testBean">
                        <method class="uix.test.BeanProvider"
                                method="getTestBean"/>
                    </data>
                </provider>
    
                <contents>
                    <document>
                        <contents>
                            <body>
                                <contents>
                                            <styledText text="${ testBean }" />
                                </contents>
                            </body>
                        </contents>
                    </document>
                </contents>
            </dataScope>
        </content>
    
        <handlers>
            <!-- Add EventHandlers (<event> elements) here  -->
        </handlers>
    
    </page>
    
    
    package uix.test;
    
    import oracle.cabo.ui.RenderingContext;
    
    public class BeanProvider  {
    
         public BeanProvider() {
         }
         
         public static Object getTestBean( RenderingContext context, String namespace, String name ) {
              
              System.out.println( "BeanProvider.getTestBean" );
              
              return new Object() {
                   public String toString() {
                        return "message";
                   }
              };
         }
    }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  • 5. Re: DataProvider not called on every render?
    4996 Newbie
    Currently Being Moderated
    Are there any exeptions in the log
    file? Did you try quitting oc4j and restarting it?
    No, I've got the debug flag set to true in the uix-config, but there are no errors in the log. I'm running all of this in the embedded OC4J, which I terminate before each trial.

    What's odd is that you can see from the log I posted at the top that the subsequent requests are resulting in 'Requested page...' and 'Rendering page' entries from the UIX framework, so the request is definitely getting back to the server, but still the provider is not called.
  • 6. Re: DataProvider not called on every render?
    55663 Newbie
    Currently Being Moderated
    OK, I'm guessing here but how about either changing
    the name of your event to not have a space in its name,
    ie instead of "hide show" how about "hide show".

    if that doesn't work and it probably won't then try changing
    the rendered flag of the tableLayout to just be true always
    and see if that works.

    and then you can try putting a flowLayout around the
    contents of your body tag to see if that helps.

    Basically the method should get called if your provider
    is going to be used in a rendered section of the page
    so I'm trying to figure out what is happening that
    would prevent that.