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?
#{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.