Foren
layout.default.template.id is broken, what fix is best?
Jesper W, geändert vor 16 Jahren.
layout.default.template.id is broken, what fix is best?
Expert Beiträge: 310 Beitrittsdatum: 25.03.07 Neueste Beiträge
The portal.property layout.default.template.id does not work in 4.4.
The code in EditPagesAction.java says:
The issue is that layoutTypePortlet.getLayoutTemplateId() in LayoutTypePortletImpl.java is not a pure getter, it has a side effect:
...so the isNull() in the action will never trigger, since the getter actually sets the TemplateId.
Not so nice, if you ask me. A getter should get, not set. Plus the fact that the default is hardcoded when we actually have a property for it.
I would prefer to just remove the setting thing from getLayoutTemplateId().
An alternative is to set it to PropsValues.LAYOUT_DEFAULT_TEMPLATE_ID instead of "2_columns_ii".
Any opinions?
/j
The code in EditPagesAction.java says:
if (Validator.isNull(
layoutTypePortlet.getLayoutTemplateId())) {
layoutTypePortlet.setLayoutTemplateId(
0, PropsValues.LAYOUT_DEFAULT_TEMPLATE_ID, false);
LayoutServiceUtil.updateLayout(
layout.getGroupId(), layout.isPrivateLayout(),
layout.getLayoutId(), layout.getTypeSettings());
}
The issue is that layoutTypePortlet.getLayoutTemplateId() in LayoutTypePortletImpl.java is not a pure getter, it has a side effect:
public String getLayoutTemplateId() {
String layoutTemplateId =
getTypeSettingsProperties().getProperty(LAYOUT_TEMPLATE_ID);
if (Validator.isNull(layoutTemplateId)) {
layoutTemplateId = "2_columns_ii";
getTypeSettingsProperties().setProperty(
LAYOUT_TEMPLATE_ID, layoutTemplateId);
_log.warn(
"Layout template id for layout " + getLayout().getPrimaryKey() +
" is null, setting it to 2_columns_ii");
}
return layoutTemplateId;
}
...so the isNull() in the action will never trigger, since the getter actually sets the TemplateId.
Not so nice, if you ask me. A getter should get, not set. Plus the fact that the default is hardcoded when we actually have a property for it.
I would prefer to just remove the setting thing from getLayoutTemplateId().
An alternative is to set it to PropsValues.LAYOUT_DEFAULT_TEMPLATE_ID instead of "2_columns_ii".
Any opinions?
/j
Jorge Ferrer, geändert vor 16 Jahren.
RE: layout.default.template.id is broken, what fix is best?
Liferay Legend Beiträge: 2871 Beitrittsdatum: 31.08.06 Neueste Beiträge
Hi Jesper,
I agree with you about the preferred solution, although you would have to make sure that it wouldn't cause undesired effects. I've found at least 4 usages of that method and at least one of them (in ServicePreAction) does not expect a null return value.
Unless you are able to to make sure there will not be undesired effects, changing "2_columns_ii" with the PropsValue constant will be a safer bet.
I agree with you about the preferred solution, although you would have to make sure that it wouldn't cause undesired effects. I've found at least 4 usages of that method and at least one of them (in ServicePreAction) does not expect a null return value.
Unless you are able to to make sure there will not be undesired effects, changing "2_columns_ii" with the PropsValue constant will be a safer bet.
Jesper W, geändert vor 16 Jahren.
RE: layout.default.template.id is broken, what fix is best?
Expert Beiträge: 310 Beitrittsdatum: 25.03.07 Neueste Beiträge
I think I will try to do it the proper way.
ServicePreAction() is easy to fix, poor programming practice anyway:
"freeform".equals(layoutTypePortlet.getLayoutTemplateId());
is much safer.
But you say 4 references, I can only find 2 using Find References in Eclipse. (ServicePreAction and EditPagesAction.updateLayout)
Where are the others?
ServicePreAction() is easy to fix, poor programming practice anyway:
"freeform".equals(layoutTypePortlet.getLayoutTemplateId());
is much safer.
But you say 4 references, I can only find 2 using Find References in Eclipse. (ServicePreAction and EditPagesAction.updateLayout)
Where are the others?
Jorge Ferrer, geändert vor 16 Jahren.
RE: layout.default.template.id is broken, what fix is best?
Liferay Legend Beiträge: 2871 Beitrittsdatum: 31.08.06 Neueste Beiträge
Hi Jesper,
The other two are just invocations to that method from within the LayoutTypePortletImpl class itself.
The other two are just invocations to that method from within the LayoutTypePortletImpl class itself.
Jesper W, geändert vor 16 Jahren.
RE: layout.default.template.id is broken, what fix is best?
Expert Beiträge: 310 Beitrittsdatum: 25.03.07 Neueste Beiträge
Jorge Ferrer, geändert vor 16 Jahren.
RE: layout.default.template.id is broken, what fix is best?
Liferay Legend Beiträge: 2871 Beitrittsdatum: 31.08.06 Neueste Beiträge
Thanks Jesper
Matteo Cajani, geändert vor 14 Jahren.
RE: layout.default.template.id is broken, what fix is best?
New Member Beitrag: 1 Beitrittsdatum: 29.04.09 Neueste Beiträge
Hello everyone,
I'm using Liferay 5.2.
I've seen that http://issues.liferay.com/browse/LEP-5361 status is fixed but I'm still having troubles setting the "default.layout.template.id" property in portal-ext.properties: each and every time I create a new community the default layout is "2_columns_ii" and not the one I've setted in portal-ext.properties.
Am I doing something wrong or the issue is still open?
Any help is appareciated!
Thanks,
Matteo
I'm using Liferay 5.2.
I've seen that http://issues.liferay.com/browse/LEP-5361 status is fixed but I'm still having troubles setting the "default.layout.template.id" property in portal-ext.properties: each and every time I create a new community the default layout is "2_columns_ii" and not the one I've setted in portal-ext.properties.
Am I doing something wrong or the issue is still open?
Any help is appareciated!
Thanks,
Matteo
Kyrre Myrbostad, geändert vor 14 Jahren.
RE: layout.default.template.id is broken, what fix is best?
Junior Member Beiträge: 37 Beitrittsdatum: 21.01.09 Neueste Beiträge
Same issue here. Are we the only ones with this problem?
Jorge Ferrer, geändert vor 14 Jahren.
RE: layout.default.template.id is broken, what fix is best?
Liferay Legend Beiträge: 2871 Beitrittsdatum: 31.08.06 Neueste Beiträge
Hi Kyrre,
That post above probably didn't get much attention because it wasn't related to the original thread topic neither was posted in the appropriate category. I would recommend moving the conversation to the appropriate place and if it's confirmed that it's a bug I would add a JIRA issue.
I've done a quick check and that property still exists and is read as any other property so I would verify looking at the logs that the portal-ext.properties file is being loaded.
That post above probably didn't get much attention because it wasn't related to the original thread topic neither was posted in the appropriate category. I would recommend moving the conversation to the appropriate place and if it's confirmed that it's a bug I would add a JIRA issue.
I've done a quick check and that property still exists and is read as any other property so I would verify looking at the logs that the portal-ext.properties file is being loaded.
Kyrre Myrbostad, geändert vor 14 Jahren.
RE: layout.default.template.id is broken, what fix is best?
Junior Member Beiträge: 37 Beitrittsdatum: 21.01.09 Neueste Beiträge
I guess I posted here because I searched the forums "default.layout.template.id" and this thread came up with relevant info.
EDIT:
Continued discussion in this post:
http://www.liferay.com/web/guest/community/forums/-/message_boards/message/3484963
EDIT:
Continued discussion in this post:
http://www.liferay.com/web/guest/community/forums/-/message_boards/message/3484963