0

What is the best way to bind a non-managed bean to an xPage? We use xPages controller classes in java, and would like to limit some classes to a specific xPage without using managed bean in faces-config.

Tried to use dataContext and some of the methods work, but we are not able to get the document data source, using resolveVariable method. It always returns doc=null. The same java class as a managed bean returns the data source correct.

Are there better ways to connect a bean to a specific xPage?

4

1 回答 1

2

beforePageLoad您可以在事件中将您的 Java 控制器与 XPage 连接:

    <xp:this.beforePageLoad><![CDATA[#{javascript:
        viewScope.controller = new com.yourdomain.controller.MyController();
        controller.beforePageLoad()}]]>
    </xp:this.beforePageLoad>

然后您可以使用 EL 调用控制器的方法,如下所示:

#{controller.save}

或者您可以将某些事件与您的控制器连接:

<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
    afterPageLoad="#{controller.afterPageLoad}"

您的控制器有权访问文档数据源。

    public void save() throws Exception {
        DominoDocument doc = (DominoDocument) JsfUtil.resolveVariable("currentDocument");
        System.out.println("save(" + doc.getDocument().getUniversalID() + ")");
    }
于 2013-04-19T07:27:19.477 回答