Xpages - 如何在我的页面上找到组件的 ID?

Xpages - How do I find the id of a component on my page?

我的 openLog 数据库中出现很多错误:

Expression Language Interpret Exception Error:'compositeData' not found - Error on _id773:

Interpret exception

Error:'compositeData' not found

多次,每次都有不同的ID。如果我查看源代码并搜索任何 ID,我将无法在任何地方找到它们……我现在变得狭隘了!有什么东西跳出来暗示方向吗?我假设的错误是因为我在某个不存在的地方引用了一个 compositeData 属性,但是我有太多带有自定义控件负载的自定义属性,所以很难查明。即使有人可以在堆栈跟踪中看到字段类型或其他内容,它也会帮助我缩小范围。谢谢

堆栈跟踪:

Stack Trace com.ibm.jscript.InterpretException: Interpret exception at com.paulwithers.openLog.OpenLogErrorHolder.getInterpretException(OpenLogErrorHolder.java:114) at com.paulwithers.openLog.OpenLogErrorHolder.addError(OpenLogErrorHolder.java:216) at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55) at java.lang.reflect.Method.invoke(Method.java:508) at com.ibm.jscript.types.JavaAccessObject.call(JavaAccessObject.java:322) at com.ibm.jscript.types.FBSObject.call(FBSObject.java:161) at com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:197) at com.ibm.jscript.ASTTree.ASTTry.interpretCatch(ASTTry.java:150) at com.ibm.jscript.ASTTree.ASTTry.interpret(ASTTry.java:113) at com.ibm.jscript.ASTTree.ASTProgram.interpret(ASTProgram.java:119) at com.ibm.jscript.ASTTree.ASTProgram.interpretEx(ASTProgram.java:139) at com.ibm.jscript.JSExpression._interpretExpression(JSExpression.java:435) at com.ibm.jscript.JSExpression.access(JSExpression.java:424) at com.ibm.jscript.JSExpression.run(JSExpression.java:414) at java.security.AccessController.doPrivileged(AccessController.java:686) at com.ibm.jscript.JSExpression.interpretExpression(JSExpression.java:410) at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:251) at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:234) at com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:222) at com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:194) at com.ibm.xsp.binding.javascript.JavaScriptValueBinding.getValue(JavaScriptValueBinding.java:78) at com.ibm.xsp.component.xp.XspOutputLabel.getFor(XspOutputLabel.java:158) at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55) at java.lang.reflect.Method.invoke(Method.java:508) at javax.faces.component.UIComponentBase$AttributesMap.put(UIComponentBase.java:1863) at com.ibm.xsp.stylekit.StyleKitImpl.applyProperties(StyleKitImpl.java:391) at com.ibm.xsp.stylekit.StyleKitImpl.applyStyle(StyleKitImpl.java:240) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:196) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl._applyStyles(StyleKitImpl.java:203) at com.ibm.xsp.stylekit.StyleKitImpl.applyStyles(StyleKitImpl.java:192) at com.ibm.xsp.application.ViewHandlerEx.applyStyles(ViewHandlerEx.java:137) at com.ibm.xsp.application.ViewHandlerEx.createView(ViewHandlerEx.java:93) at com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:250) at com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:157) at com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:159) at com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138) at com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103) at com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:588) at com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1335) at com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:865) at com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:808) at com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:577) at com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1319) at com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:662) at com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:482) at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:357) at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:313) at com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272) Caused by: java.lang.Throwable: Error:'compositeData' not found at com.paulwithers.openLog.OpenLogErrorHolder.getInterpretException(OpenLogErrorHolder.java:113) ... 67 more

正如 Sven 所说,包含 com.ibm.xsp.component 的行是要检查的行,在本例中为 com.ibm.xsp.component.xp.XspOutputLabel.getFor(XspOutputLabel.java:158) at。这实际上应该为您提供大量信息来解决问题。 XspOutputLabel 表示它是一个标签组件 - 在 local 文件夹中的 Package Explorer 中查看内置的 Java 类,你会看到什么 Java 类 为 XPage 创建(选择一个简单的 XPage!)。 get.... 位还告诉您触发了哪个 属性 错误,在本例中 getFor 表示它是 for 属性。该错误表明它在设置 compositeData 的计算中失败。因此,寻找具有使用 compositeData.

计算的 for 属性 的标签

通常,如果您得到一个模糊的“_id...”,这意味着该组件没有设置 id 属性,所以只需 <xp:label value="My Label"></xp:label> 而不是 <xp:label id="myLabel" value="My Label"></xp:label>.

下次,您可以执行以下操作:

创建一个Javaclass"JavaScriptDebugBindingFactory"

package ch.hasselba.xpages;

import com.ibm.xsp.binding.BindingFactory;
import com.ibm.xsp.util.ValueBindingUtil;
import javax.faces.application.Application;
import javax.faces.el.MethodBinding;
import javax.faces.el.ValueBinding;

public class JavaScriptDebugBindingFactory implements BindingFactory {
    public static final String JAVASCRIPT = "javascript";

    public String getPrefix() {
        return "javascript";
    }

    public MethodBinding createMethodBinding(Application app, String str,
            Class[] arr) {
        String tmpStr = ValueBindingUtil.parseSimpleExpression(str);
        return new JavaScriptDebugMethodBinding(tmpStr, arr);
    }

    public ValueBinding createValueBinding(Application app, String str) {
        String tmpSttr = ValueBindingUtil.parseSimpleExpression(str);
        return new JavaScriptDebugValueBinding(tmpStr);
    }
}

添加方法绑定class

package ch.hasselba.xpages;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.el.EvaluationException;
import javax.faces.el.MethodNotFoundException;

import com.ibm.xsp.binding.javascript.JavaScriptMethodBinding;
import com.ibm.xsp.exception.EvaluationExceptionEx;

public class JavaScriptDebugMethodBinding extends JavaScriptMethodBinding {

    public JavaScriptDebugMethodBinding() {
        super(null, null);
    }

    public JavaScriptDebugMethodBinding(String str,
            Class[] arr) {
        super(str, arr);
    }

    public Object invoke(FacesContext fc, Object[] obj)
            throws EvaluationException, MethodNotFoundException {
        UIComponent cmp = getComponent();
        try {
            return super.invoke(fc, obj);
        } catch (EvaluationExceptionEx e) {
            System.out.println("COMPONENT: " + cmp.getId());
            throw e;
        }
    }
}

添加classJavaScriptDebugValueBinding

package ch.hasselba.xpages;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.el.EvaluationException;
import javax.faces.el.PropertyNotFoundException;

import com.ibm.xsp.binding.javascript.JavaScriptValueBinding;
import com.ibm.xsp.exception.EvaluationExceptionEx;

public class JavaScriptDebugValueBinding extends JavaScriptValueBinding {

    public JavaScriptDebugValueBinding() {
        super();
    }

    public JavaScriptDebugValueBinding(String str) {
        super(str);
    }

    public Object getValue(FacesContext fc) throws EvaluationException,
            PropertyNotFoundException {
        UIComponent cmp = getComponent();
        try {
            return super.getValue(fc);
        } catch (EvaluationExceptionEx e) {
            System.out.println("COMPONENT: " + cmp.getId());
            throw e;

        }
    }
}

覆盖 beforePageLoad 中的 JavaScript Handler

<xp:this.beforePageLoad>
    <![CDATA[#{javascript:
        importPackage( ch.hasselba.xpages );
        var facts = facesContext.getApplication().getFactoryLookup();
        facts.setFactory("javascript", new ch.hasselba.xpages.JavaScriptDebugBindingFactory())

    }]]>
</xp:this.beforePageLoad>

出现错误时,组件的 id 会打印到服务器控制台。