1
votes

My dialog of type "okCancel" does not trigger any event on the server when the ok button is clicked.

The cancel button is working fine, just hiding the popup.

I'm using Oracle ADF Faces 12.1.3 and JBoss seam 2.3 for injecting beans.

Here is the popup and dialog code :

<af:form id="mainForm">
        <af:panelStretchLayout id="psl1">
            <!-- page layout -->
        </af:panelStretchLayout>
        <af:popup id="myPopup"
          binding="#{bkBean.myPopup}"
          contentDelivery="lazyUncached">
          <af:dialog id="myDialog" closeIconVisible="true"
            modal="true" okVisible="true" cancelVisible="true"
            title="Import from server to #{bkBean.file.name}"
            type="okCancel"
            dialogListener="#{bkBean.doSomething}">
            <af:panelFormLayout id="pfl1">
              <!-- Several input text here -->
            </af:panelFormLayout>
          </af:dialog>
      </af:popup>
    </af:form>

Here is the code for the dialogListener. I set a debug point at the if statement:

import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

@Name("exportImportServer")
@Scope(ScopeType.SESSION)
public class ExportImportServerBean implements Cleanable {
    public void importFromServer(DialogEvent event) {
        if (event.getOutcome() == DialogEvent.Outcome.ok) {
        }
    }
}

The exportImportServer backing bean is in session scope.

If I toggle a break point in the first code line inside the exportImportServer backing bean importFromServer method it does not stop inside. This method does not get called. It seems that nothing happens (even I have no errors) except that the main form is submitted.

In debug mode after a click on the ok button I'm able to stop inside a PhaseListener beforePhase(PhaseEvent phaseEvent) method. But I don't really know if the backing bean method should be called after the PhaseListener beforePhase(PhaseEvent phaseEvent) method.

I'm searching for any hint on how could I debug it ?
Is there any javascript called when Ok button is clicked on dialog ?


UPDATE: it seems that the problem comes from the fact that the popup is called from a region of the page and defined in another page (the main page containing the region) as seen in the code below :

Inside main.xthml:

<af:document>
  <af:form id="mainForm">
    <af:panelStretchLayout id="psl1" topHeight="auto" bottomHeight="0">
      <f:facet name="center">
        <af:region id="myRegion" showHeader="never"
                   value="#{main.regionModel}" />
      </f:facet>
    </af:panelStretchLayout>
  </af:form>
  <af:popup id="myPopup"
    binding="#{bkBean.myPopup}"
    contentDelivery="lazyUncached">
    <af:dialog id="myDialog" closeIconVisible="true"
      modal="true" okVisible="true" cancelVisible="true"
      title="Import from server to #{bkBean.file.name}"
      type="okCancel"
      dialogListener="#{bkBean.doSomething}">
      <af:panelFormLayout id="pfl1">
       <!-- Several input text here -->
      </af:panelFormLayout>
    </af:dialog>
  </af:popup>
</af:document>

Inside myRegion.xhtml:

    <?xml version='1.0' encoding='UTF-8'?>
    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
              xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:trh="http://myfaces.apache.org/trinidad/html"
              xmlns:tr="http://myfaces.apache.org/trinidad"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
      <af:tree ...>
      </af:tree>
      <!-- Contextual Menu -->
      <af:popup id="pp1" contentDelivery="lazyUncached">
        <af:menu>
          <af:commandMenuItem text="Do something" immediate="true"
 rendered="#{bkBean2.isRendered}" icon="icon.png" actionListener="#{bkBean2.showMyPopup}" />
        </af:menu>
      </af:popup>
    </ui:composition>

It works if I define the popup inside myRegion.xhtml but not if I define the popup inside main.xhtml.

Thank you for any hints on how to make it work with the popup defined inside main.xhtml ?

1
Does it hit your method when clicking cancel?User404
Shouldn't the Dialog listener be dialogListener="#{ExportImportServerBean.importFromServer}"> May be its a spell mistake. You can test if the method to be called is right if you press 'ctrl' and click on the method name in your jsff page. Does the navigation take you to the Method? written in your bean?Soumya R
Yes it does take me to the method in my bean if I ctrl-click on it in my xhtml page. There are no way to debug it ? For exemple I tried to put dialogListener="#{bla bla}" and it does not show any error, nothing. Is this behavior normal ?jerome

1 Answers

0
votes

You have two options:

  1. Try mapping your bean in your adfc-config.xml instead of using annotations.

  2. Leave annotations in place and make sure you use enable CDI in your ADF application as below:

http://www.jobinesh.com/2014/08/enabling-cdi-in-adf-applications.html

Worth mentioning that CDI (annotation-based beans) is not being used very often with ADF - at least there is little info about people following CDI approach - so you might be walking on uncharted territory .