Discussions
Categories
- 196.7K All Categories
- 2.2K Data
- 235 Big Data Appliance
- 1.9K Data Science
- 449.8K Databases
- 221.5K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 549 MySQL Community Space
- 477 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 532 SQLcl
- 4K SQL Developer Data Modeler
- 186.8K SQL & PL/SQL
- 21.3K SQL Developer
- 295.4K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.1K Development Tools
- 104 DevOps
- 3.1K QA/Testing
- 645.9K Java
- 27 Java Learning Subscription
- 37K Database Connectivity
- 153 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 17 Java Essentials
- 158 Java 8 Questions
- 85.9K Java Programming
- 79 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.2K Java SE
- 13.8K Java Security
- 203 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 392 LiveLabs
- 37 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.6K Other Languages
- 2.3K Chinese
- 170 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 230 Portuguese
ADF table ContextualEvent not working

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 Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,270 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
-
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
-
(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.
-
Are the first and second clicks in quick succession?
-
Only first click on first row.
Second and following runs ok.
-
May be the first row is already selected by default. Is it? If so, clicking on it may not be generating the contextual event.
-
The table selectionListener is always fired, that means there is no row selected (on first click).
-
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 thefirst.jsff
page fragment. The second region contains thesecond-task-flow
task flow which utilizes thesecond.jsff
page fragment.The main page
index.jsff
includes both regions.The sample application in SampleAPP.zip has only one page fragment.