带有PageFragments的Oracle ADF openPopUp

时间:2013-10-21 10:36:01

标签: popup oracle-adf page-fragments

我有一个在执行查询时打开的弹出窗口。我有一个处理查询的bean,然后打开了我的弹出窗口。

问题是我现在将页面从.jsf更改为.jsff(片段),并且它已不再有效。

有谁能解释我如何解决这个问题?

这是我的Bean类:

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);");
    }

}

这是我的弹出式代码,里面有一个表格来显示查询结果:

<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:为了没有为我删除的表格提供非常广泛的代码,在这里发布一些表值,希望我没有犯错。

同样在查询中我将QueryListner定义为:#{managedBean1.processSomeQuery}

非常感谢你。 最诚挚的问候

1 个答案:

答案 0 :(得分:2)

您不应该直接使用PopupId,在newBean类中为弹出窗口创建绑定并使用此绑定和方法getClientId();

例如,更改newBean并在类的顶部添加以下内容

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

然后更改openPopup函数中的代码,以便:

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

取代

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

不要忘记将弹出窗口绑定在jsff中,如下所示:

<af:popup childCreation="deferred" autoCancel="disabled" id="p1" contentDelivery="lazyUncached" bindings="#{pageFlowScope.newBean.myPopup}">