How to pass input text value as portlet param - liferay

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.

Related

Liferay change Full name logged in

I want to change name appear in Liferay portal after logged in.
If i logged in Liferay, it has "Full name (Sign out)" on the top right of page.
Can I change the Full name to another name I config?
I have build a Liferay-login-portlet already.
You have to implement a hook for the file /html/portlet/dockbar/view.jsp replacing in this code...
<liferay-util:buffer var="userName">
<img alt="<liferay-ui:message key="manage-my-account" />" src="<%= HtmlUtil.escape(user.getPortraitURL(themeDisplay)) %>" />
<span class="user-full-name">
<%= HtmlUtil.escape(user.getFullName()) %>
</span>
</liferay-util:buffer>
where it says user.getFullName() with that you want. For example, to use the user nick, use this
<liferay-util:buffer var="userName">
<img alt="<liferay-ui:message key="manage-my-account" />" src="<%= HtmlUtil.escape(user.getPortraitURL(themeDisplay)) %>" />
<span class="user-full-name">
<%= HtmlUtil.escape(user.getScreenName()) %>
</span>
</liferay-util:buffer>
Hope this helps. Regards.

How to create and call action button for User entity

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.

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.

How do you change the return key text in Mobile Safari keyboard without the form tag?

I would like to change the the "return" button text on the Mobile Safari keyboard when my input element is focused. I know you can do this:
<form action="somewebsite.com">
<input id='SearchTextBox' type="search"/>
<input id='SearchButton' type="button" value="Search" />
</form>
But I don't want the form tag because the search is ajaxian (I don't want to reload the page).
Does anyone know if this is possible?
Heh, should have thought of this (coworker solved). Just cancel the form submission with JavaScript. For example:
<form action="#" onsubmit="return false;">
<input id='SearchTextBox' type="search"/>
<input id='SearchButton' type="button" value="Search" />
</form>
You can now use enterkeyhint
<input enterkeyhint="search" />
Theres more options like "send", "go", etc

Add a form with POST method on a SharePoint 2010 page?

The HTML I got asked to add to a page is:
<div>
<div> Click below to enter</div>
<form id="formID" method=POST action="http://www.someWebsite.com">
<input type="submit" name="do_login" value="Log in" />
<input type="hidden" name="username" value="someUsername" />
<input type="hidden" name="password" value="somePassword" />
</form>
</div>
I know I can't add a form like that because there is already on that SharePoint created, I had a look at http://www.sharepointboris.net/2008/09/making-post-and-get-forms-from-sharepoints-pages/ but when I follow the example and save SharePoint still strips out most of the code so how can I achieve what I want in another way?
Thanks in advance.
For our SharePoint 2007 installation, I created a quiz web part. Basically, it pulls questions and answers from a list, but the actual questions are presented and submitted using a form with POST variables. It's probably much more complex and in-depth than you're looking to go, but I made a custom web part to present the form, read the post variables, and execute associated functions. The big plus to using a custom web part is that you're able to put in nearly any content you want, since you're coding it in ASP.NET.
What I did was to create a custom .aspx page (not through the sharepoint gui) with the code I posted in my question, uploaded the page to a library and then linked to it via a page viewer web part
You can get the form to work as normal if you remove the tags and place the form control inside a div like so:
<div>
<div> Click below to enter</div>
<div id="formID" method=POST action="http://www.someWebsite.com">
<input type="submit" name="do_login" value="Log in" />
<input type="hidden" name="username" value="someUsername" />
<input type="hidden" name="password" value="somePassword" />
</div>
</div>
This way sharepoint will accept everything inside the div tags. In a asp.net when you create a page in sharepoint, the whole page is containied withing a form that why sharepoint does not allow you to use another form within it.
Hope this helps

Resources