This discussion is archived
9 Replies Latest reply: Sep 18, 2013 2:15 AM by a0f79af3-2922-488a-a9c6-2383456786ed RSS

Databound Carousel spin not refreshing data

a0f79af3-2922-488a-a9c6-2383456786ed Newbie
Currently Being Moderated

Hi,

 

We are using JDeveloper 11.1.2.4

 

On left part of page, we want to show carousel component showing photos of employees (fetched from PER_IMAGES.IMAGE BLOB column).

On right hand side, we want to show details of employee shown in carousel.

 

We referred Oracle documentation "32.3.1 How to Create a Databound Carousel Component":

Using More Complex Databound ADF Faces Components - 11g Release 2 (11.1.2.4.0)

When we run the page it shows first record. However carousel spin does not refresh employee details to show subsequent employees.

Also employee image is also not shown.

 

Any help/suggestion in this regard is appreciated.

 

Thanks

  • 1. Re: Databound Carousel spin not refreshing data
    Timo Hahn Oracle ACE
    Currently Being Moderated

    Question is how you setup the carousel and the images?  The sample uses an url for the images so I guess they are referring to static data.  If you want to use blobs the Dame way you can use the approach from my blog http://wp.me/pcBZk-bU

     

    Timo

  • 2. Re: Databound Carousel spin not refreshing data
    a0f79af3-2922-488a-a9c6-2383456786ed Newbie
    Currently Being Moderated

    Hi Timo,

     

    Thanks for helping me showing employee image from DB into the carousel. I had missed creating JDBC data source in the WLS Console.

     

    I would really appreciate if you can help us with the other issue as well:

    When we run the page it shows first record. However carousel spin does not refresh employee details to show subsequent employees.

     

    Thanks,

    Vivek

  • 3. Re: Databound Carousel spin not refreshing data
    Timo Hahn Oracle ACE
    Currently Being Moderated

    Adf a partial trigger to the form pointing to the carousel.  This should update the detail.

     

    Timo

  • 4. Re: Databound Carousel spin not refreshing data
    a0f79af3-2922-488a-a9c6-2383456786ed Newbie
    Currently Being Moderated

    Hi Timo,

     

    2nd issue is also resolved

    I had set partial trigger.. but there was small issue in Carousel spin handler method (in managed bean).

     

    There is still a small issue..

    After carousel spin, although the form shows next employee, employee image in carousel is not refreshed. It still shows the first employee image.

    Any idea how to refresh employee image on carousel spin?

     

    I tried setting partial trigger on image.. but it does not work.

     

    (I can share ImageServlet and handleCarouselSpin code, if you want me to.)

     

    Thanks,

    Vivek

  • 5. Re: Databound Carousel spin not refreshing data
    a0f79af3-2922-488a-a9c6-2383456786ed Newbie
    Currently Being Moderated

    Hi Timo and other ADF experts,

     

    Please help us  resolve the issue with refreshing carousel image on carousel spin.

    Do we need to explicitly call ImageServlet on carousel spin? Or can it be set to called automatically (e.g. using PPR)?

     

    Thanks,

    Vivek

  • 6. Re: Databound Carousel spin not refreshing data
    Timo Hahn Oracle ACE
    Currently Being Moderated

    Please post the carousel code, so that we see how the image url looks like and the code you use to handle the spin.

     

    Timo

  • 7. Re: Databound Carousel spin not refreshing data
    a0f79af3-2922-488a-a9c6-2383456786ed Newbie
    Currently Being Moderated

    The carousel code (XML) is as follows:

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    <af:carousel currentItemKey="#{bindings.EmpDetailsVO1.treeModel.rootCurrencyRowKey}"

                                                             value="#{bindings.EmpDetailsVO1.treeModel}" var="item" id="c1"

                                                             binding="#{pageFlowScope.CarouselBean.carousel}"

                                                             carouselSpinListener="#{pageFlowScope.CarouselBean.handleCarouselSpin}">

                                                    <f:facet name="nodeStamp">

                                                        <af:carouselItem id="ci1" text="#{bindings.FullName}"

                                                                         binding="#{pageFlowScope.CarouselBean.carouselItem}">

                                                            <af:image

                                                                      id="i1"

                                                                      source="/imageservlet?id=#{bindings.PersonId.inputValue}"

                                                                      partialTriggers="::c1"/>

                                                        </af:carouselItem>

                                                    </f:facet>

                                                </af:carousel>

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     

    CarouselBean.handleCarouselSpin() code:

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        public void handleCarouselSpin(CarouselSpinEvent carouselSpinEvent)

        {

         

          //get the selected item key - an instance of java.util.List

          List currentSelectedKey = (List) carouselSpinEvent.getNewItemKey();

         

          //get a handle to the carousel component instance. We need this to

          //generically access the binding layer

          RichCarousel carousel = (RichCarousel) carouselSpinEvent.getSource();

         

          //get the Trinidad CollectionModel for this component

          CollectionModel componentModel = (CollectionModel) carousel.getValue();

         

          //get the ADF tree binding from the CollectionModel. This code also

          //works with tables and trees and thus is worth to remember

          JUCtrlHierBinding carouselTreeBinding = (JUCtrlHierBinding) componentModel.getWrappedData();

         

          //get the selected node

          JUCtrlHierNodeBinding selectedCarouselItemNode = carouselTreeBinding.findNodeByKeyPath(currentSelectedKey);

         

          //get the row key to make it the current key in the ADF iterator

          Key currentCarouselItemKey = selectedCarouselItemNode.getRowKey();

          //You can access the iterator binding from the tree binding so that

          //you don't need any knowledge about the namings in the PageDef file

          DCIteratorBinding dcIterBinding = carouselTreeBinding.getIteratorBinding();

         

          //make the row the current row

          dcIterBinding.setCurrentRowWithKey (currentCarouselItemKey.toStringFormat(true));

        }

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     

    ImageServlet.doGet() code:

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            response.setContentType(CONTENT_TYPE);
            String detailPersonId = request.getParameter("id");

            String thumbnailPersonId = request.getParameter("thumbnail");
            boolean thumbnail = true;
            String personId = null;

            OutputStream os = response.getOutputStream();
            Connection conn = null;


            try {
                Context ctx = new InitialContext();
                DataSource ds = (DataSource)ctx.lookup("jdbc/Stephano");

                conn = ds.getConnection();
                PreparedStatement statement =
                    conn.prepareStatement("SELECT pi.image FROM per_all_people_f ppf, per_images pi " +
                        "WHERE ppf.business_group_id = 202 AND pi.parent_id = ppf.person_id " +
                        "AND pi.table_name = 'PER_PEOPLE_F' AND sysdate BETWEEN ppf.effective_start_date AND ppf.effective_end_date " +
                        "AND ppf.person_id = ?");

                if (detailPersonId != null) {

                    personId = detailPersonId;
                    thumbnail = false;

                } else {
                    personId = thumbnailPersonId;


                }

                statement.setInt(1, new Integer(personId));
                ResultSet rs = statement.executeQuery();


                if (rs.next()) {
                    Blob blob = rs.getBlob("IMAGE");

                    BufferedInputStream in = new BufferedInputStream(blob.getBinaryStream());
                    int b;
                    byte[] buffer = new byte[10240];

                    while ((b = in.read(buffer, 0, 10240)) != -1) {
                        os.write(buffer, 0, b);
                    }
                    os.close();

                }
            } catch (Exception e) {
                e.printStackTrace();

            } finally {
                try {
                    if (conn != null) {

                        conn.close();
                    }

                } catch (SQLException sqle) {
                    sqle.printStackTrace();

                }
            }
        }

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

     

    Thanks,

    Vivek

  • 8. Re: Databound Carousel spin not refreshing data
    Timo Hahn Oracle ACE
    Currently Being Moderated

    Looks like your carousel mark upis not correct.  Look at the code below

    <af:carousel id="c1"

                               currentItemKey="#{bindings.HrImageTableView1.treeModel.rootCurrencyRowKey}"

                               value="#{bindings.HrImageTableView1.treeModel}"

                               var="item" orientation="horizontal"

                               inlineStyle="height:500px;">

                    <f:facet name="nodeStamp">

                      <af:carouselItem id="ci1">

                        <af:image source="/imageservlet?id=#{item.ImageId}"

                                  shortDesc="#{item.ImageDescription}" id="i1"/>

                      </af:carouselItem>

                    </f:facet>

                  </af:carousel>

    Add you see the image id is read from the var property "item" and not from the current dejected row.

    Change your code in a way that you use the item instead of the binding.

     

    Timo

  • 9. Re: Databound Carousel spin not refreshing data
    a0f79af3-2922-488a-a9c6-2383456786ed Newbie
    Currently Being Moderated

    Thanks so much Timo! After passing the id from "item" property (instead of normal data bindings), image is correctly refreshing on carousel spin.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points