Hi
I write the javascript in velocity file like
"#if($document.form.userNameContains.value == ($element.getName()));"
when i run this i got the following error , please tell me the solution to this error
($document.form.userNameContains.value) of '==' operation has null value. If a reference, it may not be in the context. Operation not possible. templates/allusers.vm [line 24, column 69]
As Ive said previously, you are mixing server side and client side concepts, velocity != javascript.
Prefixing a # indicates that it is a velocity directive, this runs on the server and dissapears by the time it gets to the client. What you are seeing as a server side validation failure, because $document cannot be resolved on the server.
Perhaps you could explain what you are trying to achieve? Where is this velocity triggered from, an action? Perhaps you are looking for the current user that is available (if driven by an action) via $action.getLoggedInUser(), then you can use the various methods on the user for your comparison.
Try #if($document.form.userNameContains.value.equals($element.getName()));
Also check if both the values are not null
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.