0

I am working on oracle adf with bounded taskflow and generating the ui dynamically on run time but the problem is that the UI components are not clickable and I am unable to click on the ui components, the code is as follows.

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

}

The UI components showed up properly but they are not clickable any help will be highly appreciated.Thanks

Regards, Furqan Ahmed

4

1 回答 1

0

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

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

http://blog.kennardconsulting.com/2010/10/safely-manipulating-component-tree-with.html

这也在我的开源库 Metawidget ( http://metawidget.org ) 中实现,以节省您的辛勤工作:)

于 2013-07-22T11:58:47.690 回答