0

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

问题是我现在将我的页面从 .jsf 更改为 .jsff(Fragments),它不再工作。

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

这是我的豆类:

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}

非常感谢。此致

4

1 回答 1

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}">
于 2013-10-22T10:39:43.297 回答