Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: LifeRay 6.2 & velocity variables
Bartek Stanczyk, modificat fa 11 anys.
New Member
Apunts: 16
Data d'incorporació: 21/03/14
Publicacions recents
Hello,
I'm wondering how can I access and format properly, particular vm variable - user's getLastLoginDate and getLastFailedLoginDate. With my observation, first one format is unchangeable in vm template, second one is not set properly on vm level even if it is set properly in DB's user_ table. Can anyone please help me out?
Thank You in advance,
I'm wondering how can I access and format properly, particular vm variable - user's getLastLoginDate and getLastFailedLoginDate. With my observation, first one format is unchangeable in vm template, second one is not set properly on vm level even if it is set properly in DB's user_ table. Can anyone please help me out?
Thank You in advance,
David H Nebinger, modificat fa 11 anys.
Liferay Legend
Apunts: 14933
Data d'incorporació: 02/09/06
Publicacions recents
The object is a Date and therefore will print per Date's toString().
There used to be a DateUtil or DateTool object stuffed in the context (it's been awhile since I've used it) that you could use for specialized printing, but I don't know if it's still there.
For the conditional one, you'd determine if it is not null and only then print something out (same as you would do conditional logic in your java code).
There used to be a DateUtil or DateTool object stuffed in the context (it's been awhile since I've used it) that you could use for specialized printing, but I don't know if it's still there.
For the conditional one, you'd determine if it is not null and only then print something out (same as you would do conditional logic in your java code).
Bartek Stanczyk, modificat fa 11 anys.
New Member
Apunts: 16
Data d'incorporació: 21/03/14
Publicacions recents
That is the simpler part of the question , if anyone knows how to get to the proper value of getLastLoginDate of User object?
Thank You in advance.
Thank You in advance.
David H Nebinger, modificat fa 11 anys.
Liferay Legend
Apunts: 14933
Data d'incorporació: 02/09/06
Publicacions recents
What do you mean, 'proper value'? It's right there in the User object. Just invoke user.getLastLoginDate();
Bartek Stanczyk, modificat fa 11 anys.
New Member
Apunts: 16
Data d'incorporació: 21/03/14
Publicacions recents
As I wrote above
there is problem with this value even if it is set properly in user_ table. For example :
{uuid=13ee286a-c390-4553-b1f5-f2d6196c0467, userId=49006, companyId=10157, createDate=Thu Jul 03 16:47:50 CEST 2014, modifiedDate=Thu Jul 17 09:48:09 CEST 2014, defaultUser=false, contactId=49007, password={BCRYPT}$2a$10$EsQ8BWqh8Hm2Ru927sQaJOwbMz1agwsVFvzUZUFFyjkvhmP3IecHq, passwordEncrypted=true, passwordReset=false, passwordModifiedDate=Wed Jul 23 11:42:18 CEST 2014, digest=d997512d04821acb35d1d7c5c19f6846,08ebb3a818b300fe61cdd528c2cab44b,f836e8c50322411cc12ad349d3ee15b7, reminderQueryQuestion=what-is-your-father's-middle-name, reminderQueryAnswer=tata, graceLoginCount=0, screenName=b.stanczyk.amg, emailAddress=b.stanczyk@amg.net.pl, facebookId=0, ldapServerId=-1, openId=, portraitId=0, languageId=pl_PL, timeZoneId=Europe/Paris, greeting=Witaj Bartosz Stanczyk!, comments=, firstName=Bartosz, middleName=, lastName=Stanczyk, jobTitle=, loginDate=Fri Jul 25 13:58:16 CEST 2014, loginIP=127.0.0.1, lastLoginDate=Fri Jul 25 13:05:22 CEST 2014, lastLoginIP=127.0.0.1, lastFailedLoginDate=null, failedLoginAttempts=0, lockout=false, lockoutDate=null, agreedToTermsOfUse=false, emailAddressVerified=false, status=0}
but in DB :
13ee286a-c390-4553-b1f5-f2d6196c0467 49006 10157 14/07/03 16:47:50,329000000 14/07/17 09:48:09,864000000 0 49007 {BCRYPT}$2a$10$EsQ8BWqh8Hm2Ru927sQaJOwbMz1agwsVFvzUZUFFyjkvhmP3IecHq 1 0 14/07/23 11:42:18,651000000 d997512d04821acb35d1d7c5c19f6846,08ebb3a818b300fe61cdd528c2cab44b,f836e8c50322411cc12ad349d3ee15b7 what-is-your-father's-middle-name tata 0 b.stanczyk.amg b.stanczyk@amg.net.pl 0 -1 0 pl_PL Europe/Paris Witaj Bartosz Stanczyk! Bartosz Stanczyk 14/07/25 12:09:29,803000000 127.0.0.1 14/07/25 11:55:18,857000000 127.0.0.1 14/06/05 09:17:39,076000000 0 0 14/06/05 09:17:39,076000000 0 0 0
Bartek Stanczyk:
second one is not set properly on vm level even if it is set properly in DB's user_ table. Can anyone please help me out? Thank You in advance,
there is problem with this value even if it is set properly in user_ table. For example :
{uuid=13ee286a-c390-4553-b1f5-f2d6196c0467, userId=49006, companyId=10157, createDate=Thu Jul 03 16:47:50 CEST 2014, modifiedDate=Thu Jul 17 09:48:09 CEST 2014, defaultUser=false, contactId=49007, password={BCRYPT}$2a$10$EsQ8BWqh8Hm2Ru927sQaJOwbMz1agwsVFvzUZUFFyjkvhmP3IecHq, passwordEncrypted=true, passwordReset=false, passwordModifiedDate=Wed Jul 23 11:42:18 CEST 2014, digest=d997512d04821acb35d1d7c5c19f6846,08ebb3a818b300fe61cdd528c2cab44b,f836e8c50322411cc12ad349d3ee15b7, reminderQueryQuestion=what-is-your-father's-middle-name, reminderQueryAnswer=tata, graceLoginCount=0, screenName=b.stanczyk.amg, emailAddress=b.stanczyk@amg.net.pl, facebookId=0, ldapServerId=-1, openId=, portraitId=0, languageId=pl_PL, timeZoneId=Europe/Paris, greeting=Witaj Bartosz Stanczyk!, comments=, firstName=Bartosz, middleName=, lastName=Stanczyk, jobTitle=, loginDate=Fri Jul 25 13:58:16 CEST 2014, loginIP=127.0.0.1, lastLoginDate=Fri Jul 25 13:05:22 CEST 2014, lastLoginIP=127.0.0.1, lastFailedLoginDate=null, failedLoginAttempts=0, lockout=false, lockoutDate=null, agreedToTermsOfUse=false, emailAddressVerified=false, status=0}
but in DB :
13ee286a-c390-4553-b1f5-f2d6196c0467 49006 10157 14/07/03 16:47:50,329000000 14/07/17 09:48:09,864000000 0 49007 {BCRYPT}$2a$10$EsQ8BWqh8Hm2Ru927sQaJOwbMz1agwsVFvzUZUFFyjkvhmP3IecHq 1 0 14/07/23 11:42:18,651000000 d997512d04821acb35d1d7c5c19f6846,08ebb3a818b300fe61cdd528c2cab44b,f836e8c50322411cc12ad349d3ee15b7 what-is-your-father's-middle-name tata 0 b.stanczyk.amg b.stanczyk@amg.net.pl 0 -1 0 pl_PL Europe/Paris Witaj Bartosz Stanczyk! Bartosz Stanczyk 14/07/25 12:09:29,803000000 127.0.0.1 14/07/25 11:55:18,857000000 127.0.0.1 14/06/05 09:17:39,076000000 0 0 14/06/05 09:17:39,076000000 0 0 0
David H Nebinger, modificat fa 11 anys.
Liferay Legend
Apunts: 14933
Data d'incorporació: 02/09/06
Publicacions recents
Try rebuilding the indexes...
Liferay does not hit the DB for user objects, it goes to the local index. If the local index is out of sync w/ the database then sometimes you'll get oddball things like that.
Could also be the case that the last login failed date is not in the index at all, hence the failed value. In this case you'll need an index post processor to add the field so it gets stored in the index and returned when Liferay pulls the entity.
Liferay does not hit the DB for user objects, it goes to the local index. If the local index is out of sync w/ the database then sometimes you'll get oddball things like that.
Could also be the case that the last login failed date is not in the index at all, hence the failed value. In this case you'll need an index post processor to add the field so it gets stored in the index and returned when Liferay pulls the entity.
Bartek Stanczyk, modificat fa 11 anys.
New Member
Apunts: 16
Data d'incorporació: 21/03/14
Publicacions recents
I believe it depends on settings and as far as I know property
users.search.with.index=false
implicate that user should be search directly in DB. We have used this setting because of other liferay search problems.
users.search.with.index=false
implicate that user should be search directly in DB. We have used this setting because of other liferay search problems.
David H Nebinger, modificat fa 11 anys.
Liferay Legend
Apunts: 14933
Data d'incorporació: 02/09/06
Publicacions recents
The only other thing I can think of is the user object is a proxy (it's all built on hibernate), and perhaps the proxy cannot access the original value within the scope of a velocity template, but I'd hate to think that's even a possibility.
Otherwise the value should be there, not sure why it is not working.
Otherwise the value should be there, not sure why it is not working.
Yogesh Sharma, modificat fa 11 anys.
Junior Member
Apunts: 32
Data d'incorporació: 07/03/12
Publicacions recents
String representation of date in db and velocity variable could look different. Liferay provides formatted date in object model.
So in order to have this date converted to specific string format, you need to format the date in velocity template. There are util variables available in velocity template context for date.
So in order to have this date converted to specific string format, you need to format the date in velocity template. There are util variables available in velocity template context for date.
Yogesh Sharma, modificat fa 11 anys.
Junior Member
Apunts: 32
Data d'incorporació: 07/03/12
Publicacions recents
For your ease,
displays last login date of user.
$dateTool.format("dd-MM-yyyy",$user.getLastLoginDate())displays last login date of user.
Yogesh Sharma, modificat fa 11 anys.
Junior Member
Apunts: 32
Data d'incorporació: 07/03/12
Publicacions recents
For detail of more signatures of format method, you can check https://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/DateTool.html
Community
Company
Feedback