How to create and call action button for User entity - liferay

I have created a portlet and which has the user form and on click of save buton in the class I am calling UserLocalServiceUtil.addUser() to save the user info in DB. With the following code I am printing list of users in my view.jsp.
<liferay-ui:search-container delta="10" emptyResultsMessage="no-users-were-found">
<liferay-ui:search-container-results
results="<%=UserLocalServiceUtil.getUsers(searchContainer.getStart(), searchContainer.getEnd())%>"
total="<%=UserLocalServiceUtil.getUsersCount()%>" />
<liferay-ui:search-container-row
className="com.liferay.portal.model.User"
keyProperty="userId"
modelVar="user"
>
<liferay-ui:search-container-column-text
name="name"
value="<%= user.getFullName() %>"
/>
<liferay-ui:search-container-column-text
name="first-name"
property="firstName"
/>
<liferay-ui:search-container-column-text
name="last-name"
property="lastName"
/>
<liferay-ui:search-container-column-text
name="screen-name"
property="screenName"
/>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
<liferay-ui:search-container delta="10" emptyResultsMessage="no-users-were-found" />
Now the screen shot for my code is as follows,
Now I wanted to enable the action controls for the users list. Is there any way to call the API methods to call and enable the follwoing actions buttons with functionality.
If that is not possible with API methods, How can add action buttons for users list so that I can edit user info.
Any suggestions that In which way I can achieve my task

What you are searching for is implemented in the following file: https://github.com/liferay/liferay-portal/blob/6.2.x/portal-web/docroot/html/portlet/users_admin/user_action.jsp
That file is included inside the last column of the search iterator.

Related

How to pass input text value as portlet param

I have a portlet page:
<%# taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
<portlet:resourceURL var="resourceUrl">
<portlet:param name="startDate" value="" />
</portlet:resourceURL>
<input id="startdateexportaging" type="text" />
<a style="font-size: 15px;" href="${resourceUrl}" >URL</a>
How to pass the content of startdateexportaging as portlet param startDate when clicking the link with resourceUrl?
You could use an onclick handler to add the content to the URL as soon the link is clicked. But that would be cumbersome, error prone and not necessary.
Instead you should add your input to a form and define the URL as action parameter:
<aui:form action="<%= resourceUrl.toString() %>" method="get">
<aui:input name="startDate" type="text" />
<aui:button value="Download" type="submit" />
</aui:form>
(if you don't use AUI - you can use simple HTML tags as well)
Another advantage of this solution: A button instead of a link makes it easier for the user to understand that the content from the text field is submitted. Compare it with the use of links and buttons here on SO - if you enter some information you have to hit a button.
And it is easier for search engines to parse the website, as those try to follow links - but ignore buttons.

New Form Field Not Displaying on Publishing Page - SharePoint 2007

I'm updating a publishing page in SP 2007 to include two hyperlink fields.
I've added the site columns and site content types, and updated the page layout with:
<SharePointWebControls:CurrencyField FieldName="ExistingField1" runat="server" />
<br />
<SharePointWebControls:UrlField FieldName="NewField1" runat="server" />
<br />
<SharePointWebControls:CurrencyField FieldName="ExistingField2" runat="server" />
<br />
<SharePointWebControls:UrlField FieldName="NewField2" runat="server" />
When I open the page in edit mode, neither of the two newly added fields are there. The page source simply displays the old fields with an addition where the new field should be.
<div align="left" class="ms-formfieldcontainer"><div class="ms-formfieldlabelcontainer" nowrap="nowrap"><span class="ms-formfieldlabel" nowrap="nowrap">Existing Field 1</span></div><div class="ms-formfieldvaluecontainer"><span dir="none">
<input name="ctl00$PlaceHolderMain$EditModePanelB$ctl49$ctl00$TextField" type="text" id="ctl00_PlaceHolderMain_EditModePanelB_ctl49_ctl00_TextField" title="Existing Field 1" class="ms-input" Size="11" style="ime-mode:inactive;" /><br>
</span></div></div>
<br />
<br />
<div align="left" class="ms-formfieldcontainer"><div class="ms-formfieldlabelcontainer" nowrap="nowrap"><span class="ms-formfieldlabel" nowrap="nowrap">Existing Field 2</span></div><div class="ms-formfieldvaluecontainer"><span dir="none">
<input name="ctl00$PlaceHolderMain$EditModePanelB$ctl51$ctl00$TextField" type="text" id="ctl00_PlaceHolderMain_EditModePanelB_ctl51_ctl00_TextField" title="Existing Field 2" class="ms-input" Size="11" style="ime-mode:inactive;" /><br>
</span></div></div>
<br />
I have checked a dozen times to make sure my Field Names are typed correctly and checked the layout in, then out, and approved the layout multiple time.
Any ideas?
I figured out what was going wrong. The new columns also have to be added to the page list in addition to the site column and content types. I should have seen that one coming from a mile away. (Forehead meets desk) =P

EntityRule in subgrid on custom entity not working

I tried to add a button to connection subgrid ribbon. This button should only be visible if the primary entity equals 'new_visitreport'.
Here is my try:
<CustomAction Id="Visitreports.connection.customAction"
Location="Mscrm.SubGrid.connection.MainTab.Management.Controls._children"
Sequence="15" >
<CommandUIDefinition>
<Button Id="Mscrm.SubGrid.connection.AddXYZ"
ToolTipTitle="$LocLabels:Button.AddXYZ.Label"
ToolTipDescription="$LocLabels:Button.AddXYZ.Tooltip"
LabelText="$LocLabels:Button.AddXYZ.Label"
Command="Button.AddXYZ.Command"
Image16by16="$webresource:new_XYZ_16"
Image32by32="$webresource:new_XYZ_32"
TemplateAlias="o1" />
</CommandUIDefinition>
</CustomAction>
<CommandDefinition Id="Button.AddXYZ.Command">
<EnableRules></EnableRules>
<DisplayRules>
<DisplayRule Id="EntityEqualsVisitreport" />
</DisplayRules>
<Actions>
<JavaScriptFunction FunctionName="openDialog"
Library="$webresource:new_script_open_dialog">
<StringParameter Value="3EEE3AE1-5543-433E-8123-6A14EA925A96" />
<StringParameter Value="3EEE3AE1-5543-433E-8123-6A14EA925A96" />
<BoolParameter Value="false" />
</JavaScriptFunction>
</Actions>
</CommandDefinition>
<DisplayRule Id="EntityEqualsVisitreport">
<EntityRule AppliesTo="PrimaryEntity"
EntityName="new_visitreport" />
</DisplayRule>
It seems that this rule always returns false. If I remove the display rule from command definition the button is visible, but independet of the currently primary entity.
Is there any mistake in my examply or is it not working for custom entitis although it is supported? (MSDN article)
Try using FormEntityContextRule it looks like these guys had the same issue you had. Forum Link
<FormEntityContextRule EntityName="account"/>

Create own customized Web Content List

I'm looking to create my own Web Content List portlet. I exactly want to display the web content of my portal applying some filters.
I'm a little bit lost...
I tried to create a hook but I dont know how to find the possible actions of this portlet.
I don't want to get all the content. I want to use a rules mechanism for filtering the contents(drools portlet), depending on the user information.
Thank you in advance,
Oriol
You can get the list of web contents by using following method:
List<JournalArticle> result = JournalArticleLocalServiceUtil.getArticles(groupId, -1, -1);
You can display the list using liferay search container as:
<liferay-ui:search-container delta="30" emptyResultsMessage="no-users-were-found">`
<liferay-ui:search-container-results>`
results="<%= result%>"
total="<%=result.size() %>" />
<liferay-ui:search-container-row
className="com.liferay.portlet.journal.model.JournalArticle"
keyProperty="articleId"
modelVar="content" >
<liferay-ui:search-container-column-text
name="ID" value="<%= content.getArticleId()%>" /> // You can add multiple columns
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
Hope this will help you.

Search container column jsp not working in liferay

The Search Container column jsp is not working in liferay.
I am trying to include a jsp within Liferay Search-container of type Document, for displaying search results for a given string.
Below is the snippet of code displaying search-container in the page:
<liferay-ui:search-container searchContainer="<%=tagsearchContainer%>">
<liferay-ui:search-container-results>
results="<%= hits.toList() %>"
total="<%= hits.getLength() %>"
</liferay-ui:search-container-results>
<liferay-ui:search-container-row
className="com.liferay.portal.kernel.search.Document"
escapedModel="<%= false %>"
keyProperty="UID"
modelVar="document"
stringKey="<%=true %>"
>
<liferay-ui:search-container-column-jsp path="/html/search_tag_result_form.jsp"/>
</liferay-ui:search-container-row>
</liferay-ui:search-container>
The search container only displays all fields from the document,all mashed up,without any errors.It does not display the content from the jsp(actually does not include it,and does not throw even if wrong path for jsp is there).Mashed up results are displayed from container-row .
I think you are missing the <liferay-ui:search-iterator /> before the end-tag </liferay-ui:search-container>.
This <liferay-ui:search-iterator /> is used to actually displays the list and the contents inside the <liferay-ui:search-container-row> tag.
Here is a good explanation for most of the commonly used tags for search-container.

Resources