Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ADF Faces showDetailItem seems to "load" child elements twice on tab select

568967Mar 26 2007 — edited Mar 27 2007

Problem Summary:
Child elements of showDetailItem are being loaded/executed twice. The parent of the showDetailItem is a showOneTab, and the child of showDetailItem is an af:objectImage, which calls a servlet I have written that outputs an image.

The problem I am having is that when I click on a tab (showDetailItem) my servlet is called twice. It is as if the af:objectImage line of my JSP is executed twice.

I have proven this with breakpoints in the servlet and printing a message to the console. The doGet() method of my servlet is called twice. Using breakpoints in the JSP I see the JSP is executed/read only once.

Details:

I am requesting help with this problem as I cannot solve it one my own. I have tried the following, but have had no success.

1. Searched the web for a similar problem.
2. Searched this forum for a similar problem.
3. Consulted the ADF Developer Guide version 10.1.3.0
4. Upgraded my version of JDeveloper to 10.1.3.2.0, which has ADF Faces (oracle.faces.dt) version 10.1.3.40.66.
5. Debugging with print statements and stepping through JSP and servlet code.
6. Created the simplest JSP possible that I could still produce the problem with.

The Scenario:

My goal is to use the ADF Faces showOneTab and showDetailItem tags to create two tabbed panels that will contain a blank tab (tab one) and an image (on tab 2).

I have written a servlet, BrowserImage, which takes and ID as a parameter retrieves a BLOB from view object and then outputs a jpeg image to the browser. This is done by using the af:objectImage tag and specifying my servlet in the source parameter. The image is displayed fine, but I don't want the servlet to be called twice for performance reasons.

Here is the simplest JSP that contains the problem.
Note: I tried to simplify even more by calling the servlet in different ways (jsp:include etc..), but was unable to produce the problem. I think it is key that I call the servlet using an ADF Faces tag (af:objectImage).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces/html" prefix="afh"%>
<%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>

<%@ page import="javax.faces.context.FacesContext"%>
<%@ page import="javax.faces.el.ValueBinding"%>
<%@ page import="oracle.adf.model.BindingContext"%>
<%@ page import="oracle.adf.model.binding.DCDataControl"%>
<%@ page import="oracle.jbo.ApplicationModule"%>

    <%! FacesContext fc = FacesContext.getCurrentInstance(); %>
    <%! ValueBinding vb = fc.getApplication().createValueBinding("#{data}"); %>
    <%! BindingContext bc = (BindingContext)vb.getValue(fc); %>
    <%! DCDataControl dc = bc.findDataControl("AdSearchAppModuleDataControl"); %>
    <%! ApplicationModule am = (ApplicationModule)dc.getDataProvider();%>
    <% session.setAttribute("theAm", am); %>   
<f:view>
  <afh:html>
    <afh:head title="showOneTest">
      <meta http-equiv="Content-Type"
            content="text/html; charset=windows-1252"/>
    </afh:head>
    <afh:body>
      <af:form>
        <af:showOneTab position="above">
          <af:showDetailItem text="showDetailItem 1">
          
          </af:showDetailItem>
          
          <af:showDetailItem text="showDetailItem 2"> 
            <af:objectImage source="/BrowserImage?imgId=1"/>
          </af:showDetailItem>
          
        </af:showOneTab>
      </af:form>
    </afh:body>
  </afh:html>
</f:view>

Note: The Java Script code included in the JSP is used to get an application module instance and pass it to my servlet in the session scope, so my servlet can access a view object, which contains the BLOB to output. I thought I should explain this as it may look confusing.

Any help would be appreciated.

Thanks,
Mark

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 24 2007
Added on Mar 26 2007
2 comments
636 views