Question

I have a popup that was opened when a query was performed. I had a bean that processed the query and then opened my popup.

The problem is that I now changed my page from .jsf to .jsff(Fragments), and it is no longer working.

Can anyone explain me how to solve this problem?

This is my Bean Class:

package view;

import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.MethodExpression;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;

import javax.faces.event.ComponentSystemEvent;

import oracle.adf.view.rich.component.rich.RichPopup;
import oracle.adf.view.rich.event.QueryEvent;

import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;

public class newBean {

    public newBean() {
        super();
    }

    public void processSomeQuery(QueryEvent queryEvent) {   

     /** Manipulate ViewCriteria, if you want and 
      *  then invoke query,optionally 
      */   
     System.out.println("INNNNNNNNNNNNNNNNN");   
         invokeQueryEventMethodExpression("#{bindings.ImplicitViewCriteriaQuery.processQuery}",   
            queryEvent);   

     openPopup("p1");
     }   
     /**
      * Gets ViewCriteria used by the QueryModel
      */     

     private void invokeQueryEventMethodExpression(String expression,   
                  QueryEvent queryEvent) {   

     FacesContext fctx = FacesContext.getCurrentInstance();   
     ELContext elctx = fctx.getELContext();   
     ExpressionFactory efactory =   
      fctx.getApplication().getExpressionFactory();   
     MethodExpression me =   
      efactory.createMethodExpression(elctx, expression, Object.class,   
                new Class[] { QueryEvent.class });   
     me.invoke(elctx, new Object[] { queryEvent });  
     } 

    public void openPopup (String popupId) {
        ExtendedRenderKitService erkService =
        Service.getService(FacesContext.getCurrentInstance().getRenderKit(),
        ExtendedRenderKitService.class);
        erkService.addScript(FacesContext.getCurrentInstance(),
        "var hints = {autodismissNever:true}; " +
        "AdfPage.PAGE.findComponent('" + popupId +
        "').show(hints);");
        System.out.println("POPUP INNNNN");
    }

    public void closePopup (String popupId) {
        ExtendedRenderKitService erkService =
        Service.getService(FacesContext.getCurrentInstance().getRenderKit(),
        ExtendedRenderKitService.class);
        erkService.addScript(FacesContext.getCurrentInstance(),
        "var hints = {autodismissNever:true}; " +
        "AdfPage.PAGE.findComponent('" + popupId +
        "').hide(hints);");
    }

}

This is my popup Code which has a table inside to show results from a query:

<af:panelGroupLayout layout="vertical" id="pgl2">
                    <af:popup childCreation="deferred" autoCancel="disabled" id="p1" contentDelivery="lazyUncached">
                        <af:panelWindow id="pw1">
                            <af:panelCollection id="pc1">
                                <f:facet name="menus"/>
                                <f:facet name="toolbar"/>
                                <f:facet name="statusbar"/>
                                <af:table value="#{bindings.NameView1_1.collectionModel}" var="row"
                                          rows="#{bindings.NameView1_1.rangeSize}"
                                          emptyText="#{bindings.NameView1_1.viewable ? 'No data to display.' : 'Access Denied.'}"
                                          rowBandingInterval="0"
                                          selectedRowKeys="#{bindings.NameView1_1.collectionModel.selectedRow}"
                                          selectionListener="#{bindings.NameView1_1.collectionModel.makeCurrent}"
                                          rowSelection="single" fetchSize="#{bindings.NameView1_1.rangeSize}"
                                          id="resId1">
                                    <af:column headerText="#{bindings.NameView1_1.hints.IdNo.label}" id="resId1c1">
                                        <af:outputText value="#{row.IdNo}"
                                                       shortDesc="#{bindings.NameView1_1.hints.IdNo.tooltip}" id="ot1">
                                            <af:convertNumber groupingUsed="false"
                                                              pattern="#{bindings.NameView1_1.hints.IdNo.format}"/>
                                        </af:outputText>
                                    </af:column>
                                    <af:column headerText="#{bindings.NameView1_1.hints.Title.label}" id="resId1c2">
                                        <af:outputText value="#{row.Title}"
                                                       shortDesc="#{bindings.NameView1_1.hints.Title.tooltip}"
                                                       id="ot2"/>
                                    </af:column>
                                    <af:column headerText="#{bindings.NameView1_1.hints.Name.label}" id="resId1c3">
                                        <af:outputText value="#{row.Name}"
                                                       shortDesc="#{bindings.NameView1_1.hints.Name.tooltip}" id="ot3"/>
                                    </af:column>
                                    <af:column headerText="#{bindings.NameView1_1.hints.Rowid1.label}" id="resId1c28">
                                        <af:outputText value="#{row.Rowid1}"
                                                       shortDesc="#{bindings.NameView1_1.hints.Rowid1.tooltip}"
                                                       id="ot28"/>
                                    </af:column>
                                </af:table>
                            </af:panelCollection>
                        </af:panelWindow>
                    </af:popup>

PS: To not had very extensive code for the table I deleted to post here some of the table values, hope I did not made mistake.

Also on the query I defined the QueryListner to be: #{managedBean1.processSomeQuery}

Thanks you so much. Best Regards

Was it helpful?

Solution

You should not use PopupId directly, create binding for your popup in your newBean Class and use this binding and method getClientId();

for instance, change the newBean and add the following inside of the top of the class

private RichPopup myPopup=new RichPopup();
public RichPopup getMyPopup(){ return this.myPopup; }
public void setMyPopup(RichPopup myPopup) { this.myPopup = myPopup; }

Then change the code inside openPopup function so that:

        erkService.addScript(FacesContext.getCurrentInstance(),
    "var hints = {autodismissNever:true}; " +
    "AdfPage.PAGE.findComponent('" + popupId +
    "').show(hints);");
    System.out.println("POPUP INNNNN");

get replaced by

    myPopup.show(hints);
    System.out.println("POPUP INNNNN");

Don't forget to bind your popup inside the jsff like the following:

<af:popup childCreation="deferred" autoCancel="disabled" id="p1" contentDelivery="lazyUncached" bindings="#{pageFlowScope.newBean.myPopup}">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top