Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 2 oracle adf运行时UI生成_Jsf 2_Oracle11g_Oracle Adf - Fatal编程技术网

Jsf 2 oracle adf运行时UI生成

Jsf 2 oracle adf运行时UI生成,jsf-2,oracle11g,oracle-adf,Jsf 2,Oracle11g,Oracle Adf,我正在使用有界taskflow处理oracle adf,并在运行时动态生成ui,但问题是ui组件不可单击,我无法单击ui组件,代码如下 public String testMethod() { // Add event code here... FacesContext facesContext = FacesContext.getCurrentInstance(); UIViewRoot root = facesContext.getViewRoot();

我正在使用有界taskflow处理oracle adf,并在运行时动态生成ui,但问题是ui组件不可单击,我无法单击ui组件,代码如下

public String testMethod() {
    // Add event code here...

    FacesContext facesContext = FacesContext.getCurrentInstance();
    UIViewRoot root = facesContext.getViewRoot();


    RichPanelGroupLayout panelGrpLayout = new RichPanelGroupLayout();
    panelGrpLayout.setId( "pgl1" );
    panelGrpLayout.setLayout( "scroll" );

    RichMenuBar menuBar = new RichMenuBar();
    menuBar.setId( "rmb1" );
    menuBar.setVisible( true );

    panelGrpLayout.getChildren().add( menuBar );

    RichCommandButton button = new RichCommandButton();

    button.setId( "cmi1" );
    button.setVisible( true );
    button.setText( "First" );
    button.setPartialSubmit( true );
    button.setRendered( true );

    String method = "#{backingBeanScope.CLBean.testMethod}";
    Application app = facesContext.getApplication();
    ExpressionFactory elFactory = app.getExpressionFactory();
    ELContext elContext = facesContext.getELContext();
    MethodExpression methExp = elFactory.createMethodExpression(elContext, method, Object.class, new Class[0]);

    button.addActionListener( new MethodExpressionActionListener(methExp) );


    root.addComponentResource( facesContext, button );

    return "product";

}
UI组件显示正确,但不可单击。我们将非常感谢您的帮助。谢谢

问候,,
Furqan Ahmed在ADF/JSF中动态添加组件是脆弱的。您必须注意JSF生命周期和创建新组件的“正确”时间(即,在从上一个请求恢复viewstate之后,但在序列化任何新viewstate之前)

我已与MyFaces和Mojarra团队进行了详细沟通,以确定“正确”的方法(经各方同意),并将其记录在此处:

这也在我的开源库Metawidget()中实现,以节省您的辛苦工作:)