Foros de discusión

edit records in dynamic list by velocity

juan meza, modificado hace 8 años.

edit records in dynamic list by velocity

Regular Member Mensajes: 228 Fecha de incorporación: 6/01/14 Mensajes recientes
Hi, I have liferay 6.2 GA4...

I have a dynamic list, with a display template assigned to it...
I want some users (by role) to be able to add and edit records... the add part works fine... its the edit part im having issues with...
as you know, when you add a display template, you remove the "actions" button from the records... so the edit part of the button is removed as well...

I asked this question in another post, but its an old post...

some one says that they created the url of the edit button, but i have some questions about that way of doing it... ill repeat them here to maybe save a click

http://localhost:8080/group/secretary/tools?
 p_p_id=169_INSTANCE_gG7q7sro24l6
 &p_p_lifecycle=0
 &p_p_state=maximized
 &p_p_mode=view
 &p_p_col_id=column-1
 &p_p_col_count=1
 &_169_INSTANCE_gG7q7sro24l6_recordId=38911
 &_169_INSTANCE_gG7q7sro24l6_cmd=update
&_169_INSTANCE_gG7q7sro24l6_formDDMTemplateId=0
&_169_INSTANCE_gG7q7sro24l6_formDDMTemplateId=0
&_169_INSTANCE_gG7q7sro24l6_redirect=http%3A%2F%2Flocalhost%3A8080%2Fgroup%2Fsecretary%2Ftools%3Fp_p_id%3D169_INSTANCE_gG7q7sro24l6%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-1%26p_p_col_count%3D1&_169_INSTANCE_gG7q7sro24l6_struts_action=%2Fdynamic_data_list_display%2Fedit_record&_169_INSTANCE_gG7q7sro24l6_spreadsheet=false&_169_INSTANCE_gG7q7sro24l6_displayDDMTemplateId=0&_169_INSTANCE_gG7q7sro24l6_editable=true


this is the url from the "edit" record action...
my question is about the p_p_id parameter and the _169_INSTANCE_gG7q7sro24l6_redirect parameter
how can i get them in velocity?

im guessing the other parameters are static... except the record id, but i think i know how to get that one

or, is there another way to add this "edit" record in some way to the display template?


thank you!
thumbnail
James Falkner, modificado hace 8 años.

RE: edit records in dynamic list by velocity (Respuesta)

Liferay Legend Mensajes: 1399 Fecha de incorporación: 17/09/10 Mensajes recientes
Here's the code Liferay uses (when you're not using a display template) to generate the edit url.

Notice the redirect parameter is simply the current url which can be retrieved in velocity with $themeDisplay.URLCurrent

If you were to use Freemarker (which I would strongly recommend) you could access the Liferay taglibs directly and replicate the code referenced above!
juan meza, modificado hace 8 años.

RE: edit records in dynamic list by velocity

Regular Member Mensajes: 228 Fecha de incorporación: 6/01/14 Mensajes recientes
really? i dont know how to use freemaker, but ill give it a try!

thank you!
juan meza, modificado hace 8 años.

RE: edit records in dynamic list by velocity

Regular Member Mensajes: 228 Fecha de incorporación: 6/01/14 Mensajes recientes
James Falkner:
Here's the code Liferay uses (when you're not using a display template) to generate the edit url.

Notice the redirect parameter is simply the current url which can be retrieved in velocity with $themeDisplay.URLCurrent

If you were to use Freemarker (which I would strongly recommend) you could access the Liferay taglibs directly and replicate the code referenced above!



Hi James, quick question...

if i use the $themeDisplay.URLCurrent it returns "http://localhost:8080/group/secretary/tools"
but if i change the display template to the default, and go to the edit button, it returns: "http%3A%2F%2Flocalhost%3A8080%2Fgroup%2Fsecretary%2Ftools%3Fp_p_id%3D169_INSTANCE_gG7q7sro24l6%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-1%26p_p_col_count%3D1&_169_INSTANCE_gG7q7sro24l6_struts_action=%2Fdynamic_data_list_display%2Fedit_record&_169_INSTANCE_gG7q7sro24l6_spreadsheet=false&_169_INSTANCE_gG7q7sro24l6_displayDDMTemplateId=0&_169_INSTANCE_gG7q7sro24l6_editable=true"

so what am i missing? using the $themeDisplay.URLCurrent just keeps refreshing the page, doesnt go to the edit record, but if i hardcode that URL, it works as expected... can you help me out a bit?

thank you!
juan meza, modificado hace 8 años.

RE: edit records in dynamic list by velocity (Respuesta)

Regular Member Mensajes: 228 Fecha de incorporación: 6/01/14 Mensajes recientes
James Falkner:
Here's the code Liferay uses (when you're not using a display template) to generate the edit url.

Notice the redirect parameter is simply the current url which can be retrieved in velocity with $themeDisplay.URLCurrent

If you were to use Freemarker (which I would strongly recommend) you could access the Liferay taglibs directly and replicate the code referenced above!



Hi James, quick question...

if i use the $themeDisplay.URLCurrent it returns "http://localhost:8080/group/secretary/tools"
but if i change the display template to the default, and go to the edit button, it returns: "http%3A%2F%2Flocalhost%3A8080%2Fgroup%2Fsecretary%2Ftools%3Fp_p_id%3D169_INSTANCE_gG7q7sro24l6%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-1%26p_p_col_count%3D1&_169_INSTANCE_gG7q7sro24l6_struts_action=%2Fdynamic_data_list_display%2Fedit_record&_169_INSTANCE_gG7q7sro24l6_spreadsheet=false&_169_INSTANCE_gG7q7sro24l6_displayDDMTemplateId=0&_169_INSTANCE_gG7q7sro24l6_editable=true"

so what am i missing? using the $themeDisplay.URLCurrent just keeps refreshing the page, doesnt go to the edit record, but if i hardcode that URL, it works as expected... can you help me out a bit?

thank you!


EDIT
maybe i just need to encode it, will try that

EDIT 2

no, encoding it was not it

EDIT 3
you need to add all the parameters to the redirect page as well... so i ended up doing this:
<a href="tools?p_p_id=$themeDisplay.getPortletDisplay().getId()&amp;p_p_lifecycle=0&amp;p_p_state=maximized&amp;p_p_mode=view&amp;p_p_col_id=column-1&amp;p_p_col_count=1&amp;_$themeDisplay.getPortletDisplay().getId()_recordId=$cur_record.getRecordId()&amp;_$themeDisplay.getPortletDisplay().getId()_cmd=update&amp;_$themeDisplay.getPortletDisplay().getId()_formDDMTemplateId=0&amp;_$themeDisplay.getPortletDisplay().getId()_formDDMTemplateId=0&amp;_$themeDisplay.getPortletDisplay().getId()_redirect=$httpUtil.encodeURL($themeDisplay.getURLCurrent() )%3Fp_p_id%3D$themeDisplay.getPortletDisplay().getId()%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-1%26p_p_col_count%3D1&amp;_$themeDisplay.getPortletDisplay().getId()_struts_action=%2Fdynamic_data_list_display%2Fedit_record&amp;_$themeDisplay.getPortletDisplay().getId()_spreadsheet=false&amp;_$themeDisplay.getPortletDisplay().getId()_displayDDMTemplateId=0&amp;_$themeDisplay.getPortletDisplay().getId()_editable=true">Edit Record </a>


this works emoticon... i didnt have to use a relative page name, cuz its a site template, so there will always be a "tools" page...

thanks!