Forum Stats

  • 3,827,359 Users
  • 2,260,763 Discussions
  • 7,897,218 Comments

Discussions

ADF table ContextualEvent not working

CesarH
CesarH Member Posts: 5 Red Ribbon

Hi,

I created a sample ADF project with a page and a data control.

The page has a table with 3 rows, when I run the project in Integrated Weblogic and click on a row (any row) for the first time nothing happens. When I click the second time, and following, the ContextualEvent is triggered.

Can you help me?

Thanks

Answers

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,461 Red Diamond

    User, tell us your exact JDev version, please!

    Which context event are you talking about?

    Have you defined one?

    Show us some of the page UI code and java code if you have done anything in java.


    Timo

  • CesarH
    CesarH Member Posts: 5 Red Ribbon

    Hi,

    I'm using the Jdev version 12.2.1.4.0.


    Page UI

    <?xml version='1.0' encoding='UTF-8'?>

    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">

      <af:panelGroupLayout id="pgl0" layout="vertical">

       <af:table value="#{bindings.list.collectionModel}" 

            var="row" 

            rows="#{bindings.list.rangeSize}" 

            contentDelivery="immediate"

            rowBandingInterval="0"

            selectionListener="#{managedBean.selectionListener}"

            rowSelection="single"

            fetchSize="#{bindings.list.rangeSize}" id="t1">

        <af:column headerText="#{bindings.list.hints.first.label}" id="c1">

         <af:outputText value="#{row.bindings.first.inputValue}" id="ot1"/>

        </af:column>

        <af:column headerText="#{bindings.list.hints.second.label}" id="c2">

         <af:outputText value="#{row.bindings.second.inputValue}" id="ot2"/>

        </af:column>

       </af:table>

      <af:spacer id="s1" height="20px"/>

      <af:separator id="s2"/>

      <af:spacer id="s3" height="20px"/>

      <af:outputLabel value="Selected Row:" id="ol1"/>

      <af:panelFormLayout id="pfl1">

       <af:inputText value="#{bindings.first.inputValue}" 

              label="#{bindings.first.hints.label}"

              readOnly="true"

              id="it3"/>

       <af:inputText value="#{bindings.second.inputValue}" 

              label="#{bindings.second.hints.label}"

              readOnly="true"

              id="it4"/>

      </af:panelFormLayout>

     </af:panelGroupLayout>

    </jsp:root>


    Contextual event configuration


    <tree IterBinding="listIterator" id="list">

       <nodeDefinition DefName="view.Pojo" Name="list0">

        <AttrNames>

         <Item Value="first"/>

         <Item Value="second"/>

        </AttrNames>

            <events xmlns="http://xmlns.oracle.com/adfm/contextualEvent">

         <event name="ShowDetail" customPayLoad="#{bindings.listIterator.currentRow.dataProvider}"

             eventType="Currency Change Event"/>

        </events>

       </nodeDefinition>

      </tree>

    .....

    <eventMap xmlns="http://xmlns.oracle.com/adfm/contextualEvent">

      <event name="ShowDetail">

       <producer region="list0">

        <consumer region="" handler="loadDetail">

         <parameters>

          <parameter name="customPayload" value="#{payLoad}"/>

         </parameters>

        </consumer>

        <consumer region="" handler="Execute"/>

       </producer>

      </event>

     </eventMap>


    Data Control

    public class DataControlClass {

      private List<Pojo> list = null;

      private Pojo payload;

      public DataControlClass() {

        super();

        list = new ArrayList<Pojo>();

        Pojo obj = new Pojo();

        obj.setFirst("F1");

        obj.setSecond("S1");

        list.add(obj);

      

      obj = new Pojo();

        obj.setFirst("F2");

        obj.setSecond("S2");

        list.add(obj);

             

        obj = new Pojo();

        obj.setFirst("F3");

        obj.setSecond("S3");

        list.add(obj);

      }


      public void setList(List<Pojo> list) {

        this.list = list;

      }


      public List<Pojo> getList() {

        return list;

      }


      public void setPayload(Pojo payload) {

        this.payload = payload;

      }


      public Pojo getPayload() {

        return payload;

      }


      public void loadDetail(Pojo payload) {

        System.out.println("Consumer event!");

        this.payload = payload;

      }

       

    }


    Request bean

    ....

      public void selectionListener(SelectionEvent selectionEvent) {

        // Add event code here...

        //selectionListener="#{managedBean.selectionListener}" 

        System.out.println("selection event!");

        invokeMethodExpression("#{bindings.list.collectionModel.makeCurrent}", Object.class, SelectionEvent.class, selectionEvent);

      }

         

      public Object invokeMethodExpression(String expr, Class returnType,

                            Class argType,

                            Object argument) {

        FacesContext fc = FacesContext.getCurrentInstance();

        ELContext elctx = fc.getELContext();

        ExpressionFactory elFactory =

          fc.getApplication().getExpressionFactory();

        MethodExpression methodExpr =

          elFactory.createMethodExpression(elctx, expr, returnType,

                           new Class[] { argType });

        return methodExpr.invoke(elctx, new Object[] { argument });

      }

    ....


    Please, see attached application.


    Thanks


  • CesarH
    CesarH Member Posts: 5 Red Ribbon
    edited May 11, 2022 3:47PM

    (Update)

    The error ocurrs only for the first time I select the first row of the list.

    If I click other row than the first the contextual event is fired.

    However, in any case, the selectionListener event is always fired.

  • dvohra21
    dvohra21 Member Posts: 14,578 Gold Crown

    Are the first and second clicks in quick succession?

  • CesarH
    CesarH Member Posts: 5 Red Ribbon

    Only first click on first row.

    Second and following runs ok.

  • dvohra21
    dvohra21 Member Posts: 14,578 Gold Crown

    May be the first row is already selected by default. Is it? If so, clicking on it may not be generating the contextual event.

  • CesarH
    CesarH Member Posts: 5 Red Ribbon
    edited May 12, 2022 2:58PM

    The table selectionListener is always fired, that means there is no row selected (on first click).

  • dvohra21
    dvohra21 Member Posts: 14,578 Gold Crown

    Doesn't seem like contextual events are used properly.

    Two regions are needed, a producer, and a consumer region. As example, one region contains the first-task-flow task flow which utilizes the first.jsff page fragment. The second region contains the second-task-flow task flow which utilizes the second.jsff page fragment.

    The main page index.jsff includes both regions.

    The sample application in SampleAPP.zip has only one page fragment.