丰富的 javascript 函数 findComponent
我正在尝试使用 rich:findComponent
添加动态 onclick 事件:
<font class="topFirstTablehdCategory2" style="font-size: 12px; cursor: pointer;" onclick="#{rich:findComponent('benchmarkEndDate').value = channelPerformanceController.resetDate}">
RESET
</font>
但我得到了
com.sun.el.parser.ParseException: Encountered "=" at line 1, column 48.
我愿意做的,是将字符串值设置为 rich:calender
其 id 是从 ChannelPerformanceController
类的 resetDate
字段提供的 benchmarkEndDate
。
我还在jsp页面中写了一个javascript方法:
function setResetDate(id, date) {
#{rich:findComponent('benchmarkEndDate').value} = date;
}
不起作用。它被称为: onclick="setResetDate('benchmarkEndDate', '#{channelPerformanceController.resetDate}')"
它在浏览器中呈现为:
function setResetDate(id, date) {
2011-03-24 00:00:00.0 = date;
}
此方法:
function setResetDate(id, date) {
document.getElementById(#{rich:clientId(id)}) = date;
}
更改为:
function setResetDate(id, date) {
document.getElementById() = date;
}
我做错了什么?我怎样才能实现这个目标?
I am trying to add a dynamic onclick event using rich:findComponent
as:
<font class="topFirstTablehdCategory2" style="font-size: 12px; cursor: pointer;" onclick="#{rich:findComponent('benchmarkEndDate').value = channelPerformanceController.resetDate}">
RESET
</font>
But I am getting
com.sun.el.parser.ParseException: Encountered "=" at line 1, column 48.
What I am willing to do, is to set string value to a rich:calender
whose id is benchmarkEndDate
supplied from the field resetDate
of ChannelPerformanceController
class.
I also write a javascript method in the jsp page:
function setResetDate(id, date) {
#{rich:findComponent('benchmarkEndDate').value} = date;
}
is not working. It is called as: onclick="setResetDate('benchmarkEndDate', '#{channelPerformanceController.resetDate}')"
It is rendering in browser as:
function setResetDate(id, date) {
2011-03-24 00:00:00.0 = date;
}
This method:
function setResetDate(id, date) {
document.getElementById(#{rich:clientId(id)}) = date;
}
is change into :
function setResetDate(id, date) {
document.getElementById() = date;
}
What I am doing wrong? How can I achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
#{foo = bar}
不是有效的 EL 表达式。=
不是 EL 中的有效运算符。 EL 没有赋值运算符。通过 EL 分配值的唯一方法是在支持它们的属性中使用值绑定(几乎完全通过 JSF 输入控件)。如果计算此表达式:
此表达式将搜索 请求,会话和 应用程序范围使用
getAttribute("id")
查找,使用托管bean机制来创建这样的bean(如果它是用这个id定义的)。当它被求值并返回 null 时,将不会渲染任何内容。如果不计算此表达式:
则它被放置在模板文本中(可能在 JSP 2.0/J2EE 1.4 中)。EL
表达式有两种类型:
#{foo}
- 延迟表达式:仅在允许它们的属性中计算${foo}
- 立即表达式:在模板文本中允许从 JSP 2.1 开始,这是模板文本中存在延迟表达式的翻译错误。来自 JSP 2.1 规范:
通常,
#{foo}
表达式必须仅出现在 JSF 控件属性中(对于 JSP 视图)。如果要更改服务器端值,请使用表单提交和操作绑定。这可以通过 AJAX 来完成丰富的面孔。
#{foo = bar}
is not a valid EL expression.=
is not a valid operator in EL. EL does not have an assignment operator. The only way to assign values via EL is using a value binding in attributes that support them (almost exclusively via JSF input controls).If this expression is evaluated:
This expression will search the request, session and application scopes looking using
getAttribute("id")
, using managed bean mechanisms to create such a bean if it is defined with this id. When this is evaluated and returns null, nothing will be rendered.If this expression is not evaluated:
Then it is being placed in template text (probably in JSP 2.0/J2EE 1.4.)
There are two types of EL expression:
#{foo}
- deferred expression: only evaluated in attributes that allow them${foo}
- immediate expression: allowed in template textBeginning with JSP 2.1, it is a translation error to have a deferred expression in template text. From the JSP 2.1 specification:
Generally,
#{foo}
expressions must be in JSF control attributes only (for JSP views).If you want to change a server-side value, use a form submit and action binding. This can be done via AJAX in RichFaces.