Foros de discusión

Velocity template and Java code

thumbnail
Chris Mount, modificado hace 11 años.

Velocity template and Java code

New Member Mensajes: 11 Fecha de incorporación: 6/04/12 Mensajes recientes
Hi I am a new to LIferay and wanting to know what the proper way to go about using a small amount of java code for use in the header.

Using 6.1 w/ Tomcat bundle

For example here is what I am trying to do. I want to do some java Calendar() manipulation on a custom field that I have mapped from LDAP.

So in my _diffs/templates/init_custom.vm, I have the following:

#set($pwdChangeTime = $themeDisplay.getUser().getExpandoBridge().getAttribute('pwdChangedTime').toString())

Now in my _diffs/templates/portal_normal.vm, I want to make use of it in the header. Where should I put the java code for adding 60 days?

Thanks - Chris
thumbnail
David H Nebinger, modificado hace 11 años.

RE: Velocity template and Java code (Respuesta)

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Putting the value in the header makes no sense unless you're going to be manipulating it in javascript.

And if you're manipulating it in javascript, why not just add the 60 days using JS?
thumbnail
Brian Scott Schupbach, modificado hace 11 años.

RE: Velocity template and Java code (Respuesta)

Expert Mensajes: 329 Fecha de incorporación: 23/10/08 Mensajes recientes
Agreed. Sounds like you want to use javascript here.

I'm not exactly sure what you're trying to do but if you want to include java you can include a .jsp file using velocity. The .jsp file must live inside the theme project.

$theme.include($themeServletContext, "/elements.jsp")
thumbnail
Chris Mount, modificado hace 11 años.

RE: Velocity template and Java code

New Member Mensajes: 11 Fecha de incorporación: 6/04/12 Mensajes recientes
Hey guys thanks so much for the reply. I just did not know what the best way to go about it was. I am new to Velocity and in our current portal, I just did this with java in the jsp.