我使用Expression Language的(EL)myUnmanagedBean.fn()
来计算Java类链接标签的文本。其中myUnmanagedBean是bean的名称。
功能是,
private static String s="vijay";
static String fn()
{
return s;
}
我已经向xpage添加了数据上下文,相应的代码是:
<xp:this.dataContexts>
<xp:dataContext var="myUnmanagedBean"
value="${javascript:new com.kkmsoft.vijay.Invoke1()}">
</xp:dataContext>
</xp:this.dataContexts>
错误页面显示:
Exception:
myUnmanagedBean.fn()
Encountered "(", expected one of ["}", ".", ">", "gt", "<", "lt", "==", "eq", "<=", "le", ">=", "ge", "!=", "ne", "[", "+", "-", "*", "/", "div", "%", "mod", "and", "&&", "or", "||", "?"]
Encountered "(" at line 1, column 21. Was expecting one of: "}" ... "." ... ">" ... "gt" ... "<" ... "lt" ... "==" ... "eq" ... "<=" ... "le" ... ">=" ... "ge" ... "!=" ... "ne" ... "[" ... "+" ... "-" ... "*" ... "/" ... "div" ... "%" ... "mod" ... "and" ... "&&" ... "or" ... "||" ... "?" ...
在堆栈跟踪中,
javax.faces.el.ReferenceSyntaxException: myUnmanagedBean.fn()
com.sun.faces.application.ApplicationImpl.checkSyntax(Unknown Source)
该datacontext仅用于测试目的;我知道这不是一个理想的方法。 有什么问题?
答案 0 :(得分:1)
答案 1 :(得分:1)
斯文是对的。您的代码不是Bean(它看起来非常像VBScript)。豆子:
您将使用的EL表达式为myUnmanagedBean.fn
package com.kkmsoft.vijay;
//Import statements omitted
public class Invoke1 implements Serializable {
private String s="vijay";
public String getFn() {
return this.s;
}
// Optional
public String setFn(String newS) {
this.s = newS;
}
}
注意:EL中的fn很小,但getFn需要大写字母F.