I need to add a Custom Field to Site create page, i went to Portal > Custom Fields > Site and added a custom field named "licence".
I followed this tutorial http://www.liferay.com/pt/community/wiki/-/wiki/Main/Custom+Fields+and+JSP+Hooks
I'm trying to access this field in details.jsp page. It's located at of tomcat-7.0.27\webapps\ROOT\html\portlet\sites_admin\site i tryed to do this:
<liferay-ui:custom-attribute
label="Licence"
className="<%= Site.class.getName() %>"
classPK="<%= 0 %>"
editable="<%= true %>"
name="licence"
/>
but it's wrong. How can I access the Site custom field that i added??
Thanks!!
Update
I solved like this
<liferay-ui:custom-attribute
className="<%= Group.class.getName() %>"
classPK="<%= (liveGroup != null) ? liveGroup.getGroupId() : 0 %>"
editable="<%= true %>"
label="<%= true %>"
name="tipo-licenca"
/>
Related
I'm trying to do a simple example with the searchContainer working with liferay 6.1.
The searchContainer variable is unknown in view.jsp.
I get the error "searchContainer cannot be resolved".
I tried to include <%# taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
It didn't work.
Code looks like this:
<liferay-ui:search-container iteratorURL="<%= actionURL %>" delta="10" emptyResultsMessage="no-documents">
<liferay-ui:search-container-results total="<%= list.size() %>" results="<%= ListUtil.subList(list, searchContainer.getStart(), searchContainer.getEnd()) %>" />
Update
I am using the varibale searchContainer in search-container-results tag and in the search-iterator tag
<liferay-ui:search-container iteratorURL="<%= actionURL %>"
delta="10" emptyResultsMessage="no-documents">
<liferay-ui:search-container-results total="<%= list.size() %>"
results="<%= ListUtil.subList(list, searchContainer.getStart(),
searchContainer.getEnd()) %>" />
<liferay-ui:search-container-row modelVar="file
className="DLFileEntry">
.
.
.
</liferay-ui:search-container-row>
<liferay-ui:search-iterator
searchContainer="<%= searchContainer %>"
paginate="${fn:length(listFiles) ge 10}" />
</liferay-ui:search-container>
In principle your code should work. I'd look for these options, in order of probability:
Either you're cl the search-container tag before you use the search-container-results tag, thus searchContainer would be out of scope. (assuming you might have shortened the code here, or you have another reference to searchContainer, not just the one that you're showing here.
or you're declaring the variable explicitly to be named differently, e.g. <liferay-ui:search-container var="myOwnNameForSearchContainer" ...>, again this assumes that you've severely shortened the sample code here
or the tag library is not recognized (low probability).
How to mitigate?
Watch out for other references to searchContainer later on the page, particularly after the occurrence of </liferay-ui:search-container>.
should be obvious
Shorten the page to just <liferay-ui:searchContainer ... > </liferay-ui:search-container> and make sure that this gets replaced with actual HTML code, and this particular markup is no longer existing in the HTML output when you render the page, then add individual other elements.
I want to remove a "delete" action button from the "user-profile-portlet". I am not core Liferay developer so facing this issue. Any help would be appreciated:
Sample code:
<portlet:renderURL windowState="<%= LiferayWindowState.POP_UP.toString() %>" var="editUserPortraitURL">
<portlet:param name="jspPage" value="/edit_user_portrait.jsp" />
<portlet:param name="redirect" value="<%= currentURL %>" />
<portlet:param name="p_u_i_d" value="<%= String.valueOf(user.getUserId()) %>" />
<portlet:param name="portrait_id" value="<%= String.valueOf(user.getPortraitId()) %>" />
</portlet:renderURL>
<liferay-ui:logo-selector
currentLogoURL="<%= user.getPortraitURL(themeDisplay) %>"
defaultLogoURL="<%= UserConstants.getPortraitURL(themeDisplay.getPathImage(), user.isMale(), 0) %>"
editLogoURL="<%= editUserPortraitURL %>"
imageId="<%= user.getPortraitId() %>"
logoDisplaySelector=".user-logo"
showBackground="<%= false %>"
/>
I recomemend you not to modify directly the portlet, but to modify the permission for the roles that you consider. Here it is explained:
https://dev.liferay.com/discover/portal/-/knowledge_base/6-2/roles-and-permissions
If it is not enough, you can create a hook that will overwrite the jsp you need to modify. For doing this, I recommend you following this:
https://dev.liferay.com/develop/tutorials/-/knowledge_base/6-2/customizing-jsps-by-extending-the-original
Good luck!
liferay-ui:logo-selector is the tag which displays image and other change and delete control buttons.
Below file is responisble to render that part.
https://github.com/liferay/liferay-portal/blob/master/portal-web/docroot/html/taglib/ui/logo_selector/page.jsp
You have to customize this jsp using hook plugins as mentioned in the link given in #Doc Manhattan's answer.
i have liferay 6.2 GA4.. i have a question
i want to use liferay's user portrait change, but i dont want to copy all the code to my portlet...
is there a way to call liferay's portrait update from my portlet? just like in a render URL or something like that... call the edit_user_portrait struts action from liferay's my account portlet, and then let liferay do everything else... update the image, show errors, etc...
using this for example: (this is the code in liferay's my account portlet, to call the pop up that updates the portrait)
<portlet:renderURL var="editUserPortraitURL" windowState="<%= LiferayWindowState.POP_UP.toString() %>">
<portlet:param name="struts_action" value="/users_admin/edit_user_portrait" />
<portlet:param name="redirect" value="<%= currentURL %>" />
<portlet:param name="p_u_i_d" value="<%= String.valueOf(selUser.getUserId()) %>" />
<portlet:param name="portrait_id" value="<%= String.valueOf(selUser.getPortraitId()) %>" />
i want something like this, but this is not working... where i tell the portlet name (users admin in this case) where the struts action lives... and let liferay handle the rest..
<liferay-portlet:renderURL portletName="<%=PortletKeys.USERS_ADMIN %>" var="editUserPortraitURL" windowState="<%= LiferayWindowState.POP_UP.toString() %>">
<portlet:param name="struts_action" value="/users_admin/edit_user_portrait" />
<portlet:param name="redirect" value="<%= currentURL %>" />
<portlet:param name="p_u_i_d" value="<%= String.valueOf(selUser.getUserId()) %>" />
<portlet:param name="portrait_id" value="<%= String.valueOf(selUser.getPortraitId()) %>" />
for this i imported the <%# taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet"%>
this code gives me a permissions error:
You do not have the roles required to access this portlet.
but i doesnt send any error in the log..
how can i make this work? what im i missing?
thank you!!
i want to use liferay's user portrait change
Using Liferay API you can do this.
InputStream inputStream = new FileInputStream(file);
byte[] bytes = FileUtil.getBytes(inputStream);
UserServiceUtil.updatePortrait(themeDisplay.getUser().getUserId(), bytes);
reference
Thanks.
What I ended up doing is what Saleem suggested in the comments:
<%String editPortraitUrl = themeDisplay.getPortalURL()+"/group/control_panel/manage?p_p_id=2&p_p_lifecycle=0&p_p_state=pop_up&p_p_mode=view&_2_portrait_id=0&_2_p_u_i_d="+themeDisplay.getUserId()+"&_2_struts_action=%2Fmy_account%2Fedit_user_portrait";
%>
<liferay-ui:logo-selector
currentLogoURL="<%= selUser.getPortraitURL(themeDisplay) %>"
defaultLogoURL="<%= UserConstants.getPortraitURL(themeDisplay.getPathImage(), selUser.isMale(), 0) %>"
editLogoURL="<%=editPortraitUrl %>"
imageId="<%= selUser.getPortraitId() %>"
logoDisplaySelector=".user-logo"/>
Here is a link for reference:
https://www.liferay.com/es/community/forums/-/message_boards/message/57413369
I have a requirement that I need to add one link or button in docbar. From my custom jsp of the portlet when I click a link or button It should open the docbar left menu.For example in the docbar if I click on edit page it will open the left menu as shown below.How to achieve this ?
I have tried open the left menu link form my custom jsp page, it is not opened even I have included the docabr.js in custom jsp page. can any one guide me how to achieve this?
the following is my code which I have tried:
<script type="text/javascript" src="/html/js/liferay/dockbar.js"></script>
<portlet:renderURL var="editLayoutURL" windowState="<%= LiferayWindowState.EXCLUSIVE.toString() %>">
<portlet:param name="struts_action" value="/dockbar/edit_layout_panel" />
<portlet:param name="closeRedirect" value="<%= PortalUtil.getLayoutURL(layout, themeDisplay) %>" />
<portlet:param name="groupId" value="<%= String.valueOf(scopeGroupId) %>" />
<portlet:param name="selPlid" value="<%= String.valueOf(plid) %>" />
</portlet:renderURL>
<aui:nav-item anchorId="editLayoutPanel" cssClass="page-edit-controls" data-panelURL="<%= editLayoutURL %>" href="javascript:;" iconCssClass="icon-edit" label="edit" />
<aui:script position="inline" use="liferay-dockbar">
Liferay.Dockbar.init('#<portlet:namespace />dockbar');
var customizableColumns = A.all('.portlet-column-content.customizable');
if (customizableColumns.size() > 0) {
customizableColumns.get('parentNode').addClass('customizable');
}
</aui:script>
You probably need to register your panel in the Dockbar like this:
<aui:script use="liferay-dockbar">
Liferay.Dockbar.DOCKBAR_PANELS.myPanel = {
css: 'lfr-has-mypanel',
id: 'myPanel',
node: null,
showFn: A.bind(Liferay.Dockbar._showPanel, Liferay.Dockbar),
tpl: '<div class="lfr-add-panel lfr-admin-panel" id="{0}" />'
};
</aui:script>
You can check out a working implementation of this in the Audience Targetting Simulator Hook
I am new to liferay development.
I have done good work to display the liferay grid by using liferay search container.
But now the requirement is that some of the fields in the grid should have provision to be modified by user.
Is it possible through liferay search container or do I need to follow any other approach to achieve editable liferay grid?
You can use <liferay-ui:search-container-column-jsp tag or directly use <aui-input /> inside the <liferay-ui:search-container-column-text tag.
Example (I have included code comments with the code sample for your understanding):
<liferay-ui:search-container
emptyResultsMessage="no-assets-selected"
iteratorURL="<%= configurationRenderURL %>"
total="<%= assetEntries.size() %>"
>
<liferay-ui:search-container-results
results="<%= assetEntries.subList(searchContainer.getStart(), searchContainer.getResultEnd()) %>"
/>
<liferay-ui:search-container-row
className="com.liferay.portlet.asset.model.AssetEntry"
escapedModel="<%= true %>"
keyProperty="entryId"
modelVar="assetEntry"
>
<aui:form action="doesThisWork?">
<%-- this is the normal way --%>
<liferay-ui:search-container-column-text
name="type"
value="<%= assetRendererFactory.getTypeName(locale, false) %>"
/>
<liferay-ui:search-container-column-date
name="modified-date"
value="<%= assetEntry.getModifiedDate() %>"
/>
<%--
this is the JSP way
You can include anything in the JSP like <input /> fields, textarea, select drop-down etc.
--%>
<liferay-ui:search-container-column-jsp
align="right"
path="/html/portlet/asset_publisher/asset_selection_action.jsp"
/>
<%--
Here is including <input /> field inside the column text field.
Notice I am not using the "value" attribute of this tag, instead I am
writing HTML inside the body of this tag.
--%>
<liferay-ui:search-container-column-text
name="type"
>
<aui:input type="text" name="enterSomething" value="I can enter input here" />
<aui:input type="text" name="enterSomething" value="<%=assetEntry.getTitle %>" />
<aui:input type="hidden" name="enterSomething" value="this is a hidden field of the form" />
</liferay-ui:search-container-column-text>
</aui:form>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator paginate="<%= total > SearchContainer.DEFAULT_DELTA %>" />
</liferay-ui:search-container>
In the above example, there would be a <form> for each row, so you can have a submit button at the end of each row to submit the data for that row.
But you can do it in other ways as well:
You can write the <form> outside the Search-container tag so that you just have one form and can submit all the row data togather
Or else you can have a <form> somewhere down the page and through javascript populate the value in the form and then submit.
Or else you can use ajax and other stuff to accomplish this. Or a combination of several approaches.
I leave this upto you to figure out.
Disclaimer: I have not test this code. But as per my understanding this should work. :-)