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!

Cannot access AdfFacesContext. AdfFacesContext returns null

Tarek FathyNov 21 2017

Hi

In my ADF application , I have created a managed bean that implements MessageListener

the onMessage method recivies the JMS message from the server and print it correctly.

I need to refresh a RichCommandNavigationItem , the problem is that AdfFacesContext returns null.

I wonder why the AdfFacesContext returns null when trying to access it from the onMessage method.

public class OcsHome implements MessageListener {

private RichCommandNavigationItem notificationLnk;

   private TopicSession session;

private TopicSubscriber subscriber;

private TopicPublisher tpub;

TopicConnection tCon;

ActionEvent evnt;

public OcsHome() {

initJms();

}

@Override

public void onMessage(Message message) {

  String msgText = null;

   if (message instanceof TextMessage) {

try {

msgText = ((TextMessage) message).getText();

String m = message.getStringProperty("MSG");

System.out.println(m);

AdfFacesContext context = AdfFacesContext.getCurrentInstance(); // here is the problem. the context is always null

if (context != null) {

context.addPartialTarget(getNotificationLnk());

}

} catch (JMSException e) {

e.printStackTrace();

}

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 19 2017
Added on Nov 21 2017
0 comments
182 views