hi folks as per Search box in Search conatiner Image is here !
i just wanted to ask when the user type a name in search box then the particular field should be display.i am putting my view.jsp code is here also??
Vuew.jsp
<%#page import="com.proliferay.servicebuilder.service.BlobDemoLocalServiceUtil"%>
<%# taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%# taglib uri="http://liferay.com/tld/aui" prefix="aui"%>
<%# taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%#page import="javax.portlet.PortletURL"%>
<%# taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<%# taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%# taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%# taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<liferay-theme:defineObjects />
<portlet:defineObjects />
<style>
.wrapper {
text-align: center;
}
.button {
position: absolute;
top: 20%;
}
</style>
<%
PortletURL addEmp = renderResponse.createRenderURL();
addEmp.setParameter("mvcPath", "/html/blobdemo/add.jsp");
PortletURL homeURL = renderResponse.createRenderURL();
PortletURL iteratorURL=renderResponse.createRenderURL();
iteratorURL.setParameter("mvcPath", "/html/blobdemo/display_student.jsp");
PortletURL addEmployee = renderResponse.createRenderURL();
addEmployee.setParameter("mvcPath", "html/blobdemo/add_emp.jsp");
PortletURL employeeDetailsURL = renderResponse.createRenderURL();
employeeDetailsURL.setParameter("mvcPath", "/html/empref/student_details.jsp");
PortletURL displaySearchStudent = renderResponse.createRenderURL();
displaySearchStudent.setParameter("mvcPath", "/html/blobdemo/view.jsp");
%>
Home<br/><br/>
<div class="wrapper">
<button class="btn btn-info" >Employee Referral</button>
</div>
<button class="btn btn-info">Refer an Employee</button>
<!-- <form class="form-search">
<input type="text" class="input-medium search-query" style="margin-left: 571px;margin-top:-25px;"> -->
<!-- --search button -->
<input name="<portlet:namespace/>search" type="text" style="margin-top: -42px;margin-left: 663px;"/>
<input type="submit" label="" value="search"
style=" margin-top: -40px" formaction="" name="stdForm" >
<!-- -search button ends here! -->
<liferay-ui:search-container emptyResultsMessage="There is no data to display">
<liferay-ui:search-container-results
results="<%=BlobDemoLocalServiceUtil.getBlobDemos(
searchContainer.getStart(), searchContainer.getEnd())%>"
total="<%= BlobDemoLocalServiceUtil.getBlobDemosCount() %>" />
<liferay-ui:search-container-row className="com.proliferay.servicebuilder.model.BlobDemo" modelVar="aBlobDemo">
<portlet:resourceURL var="viewURL"> <portlet:param name="dataId" value="<%=String.valueOf(aBlobDemo.getBlobId())%>" />
</portlet:resourceURL>
<liferay-ui:search-container-column-text
value="<%=String.valueOf(row.getPos() + 1)%>" name="Serial No" />
<liferay-ui:search-container-column-text property="customer" name="customer" />
<liferay-ui:search-container-column-text property="referral" name="referral ID" />
<liferay-ui:search-container-column-text property="candidateName" name="Candidate Name" />
<liferay-ui:search-container-column-text property="contactNumber" name="Contact Number" />
<liferay-ui:search-container-column-text property="qualification" name="Qualification " />
<liferay-ui:search-container-column-text property="interviewdateandtime" name="interviewdateandtime" />
<liferay-ui:search-container-column-text property="tenetavijoiningdate" name="Tenetavijoiningdate" />
<liferay-ui:search-container-column-text property="status" name="Status " />
<liferay-ui:search-container-column-text property="actualjoiningdate" name="Actualjoiningdate" />
<liferay-ui:search-container-column-text property="tanurityindays" name="Tanurityindays " />
<liferay-ui:search-container-column-jsp path="/html/blobdemo/action.jsp" align="right" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
</form>
yeah itz been completd , we can write a dynamic query for this and rebuild the sevices.
steps to do this.
1:- first we have to write a dynamic query in localserviceimpl.java so that when we rebuild the services it will generate the methods in localserviceutil.java
2:- and we can call in this methods in search form search container using display terms .
3:- we can easily search using any keyvalue.
package com.data.dbservice.service.impl;
import java.util.List;
import com.data.dbservice.service.base.StudentLocalServiceBaseImpl;
import com.liferay.portal.kernel.dao.orm.DynamicQuery;
import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
import com.liferay.portal.kernel.dao.orm.Junction;
import com.liferay.portal.kernel.dao.orm.Property;
import com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil;
import com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.Validator;
import com.data.dbservice.model.Student;
import com.data.dbservice.service.StudentLocalServiceUtil;
/**
* The implementation of the student local service.
*
* <p>
* All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {#link com.data.dbservice.service.StudentLocalService} interface.
*
* <p>
* This is a local service. Methods of this service will not have security checks based on the propagated JAAS credentials because this service can only be accessed from within the same VM.
* </p>
*
* #author Abhishek
* #see com.data.dbservice.service.base.StudentLocalServiceBaseImpl
* #see com.data.dbservice.service.StudentLocalServiceUtil
*/
public class StudentLocalServiceImpl extends StudentLocalServiceBaseImpl {
public List getSerachStudents(String firstName,String lastName,int studentAge,int studentGender,String studentAddress,
boolean andSearch, int start, int end, OrderByComparator orderByComparator)
throws SystemException
{
DynamicQuery dynamicQuery = buildStudentDynamicQuery(firstName, lastName, studentAge, studentGender, studentAddress, andSearch);
return StudentLocalServiceUtil.dynamicQuery(dynamicQuery, start, end, orderByComparator);
}
public int getSearchStudentsCount(String firstName,String lastName,int studentAge,int studentGender,String studentAddress,boolean andSearch)
throws SystemException
{
DynamicQuery dynamicQuery = buildStudentDynamicQuery(firstName, lastName, studentAge, studentGender, studentAddress, andSearch);
return (int)StudentLocalServiceUtil.dynamicQueryCount(dynamicQuery);
}
protected DynamicQuery buildStudentDynamicQuery(String firstName,String lastName,int studentAge,int studentGender,String studentAddress,boolean andSearch)
{
Junction junction = null;
if(andSearch)
junction = RestrictionsFactoryUtil.conjunction();
else
junction = RestrictionsFactoryUtil.disjunction();
if(Validator.isNotNull(firstName))
{
Property property = PropertyFactoryUtil.forName("firstName");
String value = (new StringBuilder("%")).append(firstName).append("%").toString();
junction.add(property.like(value));
}
if(Validator.isNotNull(lastName))
{
Property property = PropertyFactoryUtil.forName("lastName");
String value = (new StringBuilder("%")).append(lastName).append("%").toString();
junction.add(property.like(value));
}
if(studentAge > 0)
{
Property property = PropertyFactoryUtil.forName("studentAge");
junction.add(property.eq(Integer.valueOf(studentAge)));
}
if(studentGender > 0)
{
Property property = PropertyFactoryUtil.forName("studentGender");
junction.add(property.eq(Integer.valueOf(studentGender)));
}
if(Validator.isNotNull(studentAddress))
{
Property property = PropertyFactoryUtil.forName("studentAddress");
String value = (new StringBuilder("%")).append(studentAddress).append("%").toString();
junction.add(property.like(value));
}
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Student.class, getClassLoader());
return dynamicQuery.add(junction);
}
}
Related
Using the iNotesCalendar view in my Bootstrap enabled web application provides a not so appealing calendar (see below)
Is there a way to wrap some bootstrap styling around the calendar? I couldn't find anything about bootstrap calendars in XPages4Bootstrap or on the Bootstrap page.
As Eric suggested I am going to answer my own question. A very good starting point is Frank's excellent post.
I will post a lot of code and as much explanation as I can.
First you need to get the files and add them to the WebContent folder of your NSF, which you can find in the Package Explorer. I made a sub folder named "FullCalendar" to keep things orderly.
Create a custom control for your calendar. [Code for this at the bottom of the this entry.]
There a few things in my custom control that I had to add to Frank's explanation that were particular to my environment - they may be true of yours as well.
First, notice that I set the xsp.resources.aggregate property to "true", which overrides the database setting of false. I do not remember why I had to do this, but my calendar did not work unless I did.
Note: I found the code and the reason in this post.
Next, I add three resources, 3 that are related to FullCalendar (the fourth is some common layout css). The ordering is very important here. jQuery must be loaded before moment.min.js, which must be loaded before fullcalendar.min.js. Don't see jQuery there though? jQuery is already loaded in my theme, don't want to load it again.
Notice that moment is loaded with some unfamiliar syntax using a head tag and attributes. I posted a question about using Bootstrap with Full Calendar. Long story short you must also fix the AMD issue (see the post), and load resources as I did to get this to work, although I imagine I am doing something wrong!
There is some standard type of code for buttons and so on, and a div container. The real work is in the script block, and the important part is calling the rest service. I tried to make this fairly standard - I always put rest elements in a design element called XpRest.xsp and then put a specific name on each of the elements, this one being CalendarEvents.
This rest service element calls a java Rest service. The code for the rest service extension library design element is:
<xe:restService
id="restService2"
pathInfo="calendarEvents"
ignoreRequestParams="false"
state="false"
preventDojoStore="true">
<xe:this.service>
<xe:customRestService
contentType="application/json"
serviceBean="com.XXXX.rest.CalendarEvents">
</xe:customRestService>
</xe:this.service>
</xe:restService>
So this is going to call a java rest service, and the code for this is...
package com.XXXXX.rest;
import java.io.IOException;
import java.io.Writer;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.openntf.domino.Database;
import org.openntf.domino.Session;
import org.openntf.domino.View;
import org.openntf.domino.ViewEntry;
import org.openntf.domino.ViewNavigator;
import org.openntf.domino.utils.Factory;
import org.openntf.domino.DateTime;
import com.ibm.commons.util.io.json.JsonException;
import com.ibm.commons.util.io.json.util.JsonWriter;
import com.ibm.domino.services.ServiceException;
import com.ibm.domino.services.rest.RestServiceEngine;
import com.ibm.xsp.extlib.component.rest.CustomService;
import com.ibm.xsp.extlib.component.rest.CustomServiceBean;
import com.scoular.cache.CacheBean;
public class CalendarEvents extends CustomServiceBean {
#SuppressWarnings("unused")
private Database dataDB;
#Override
public void renderService(CustomService service, RestServiceEngine engine) throws ServiceException {
try {
HttpServletRequest request = engine.getHttpRequest();
HttpServletResponse response = engine.getHttpResponse();
response.setHeader("Content-Type", "application/json; charset=UTF-8");
response.setContentType("application/json");
response.setHeader("Cache-Control", "no-cache");
response.setCharacterEncoding("utf-8");
response.addHeader("Access-Control-Allow-Origin", "*");
response.addHeader("Access-Control-Allow-Credentials", "true");
response.addHeader("Access-Control-Allow-Methods", "GET, POST");
response.addHeader("Access-Control-Allow-Headers", "Content-Type");
response.addHeader("Access-Control-Max-Age", "86400");
String method = request.getMethod();
if (method.equals("GET")) {
this.doGet(request, response);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, JsonException {
try {
Integer cnt = 0;
ViewNavigator nav;
View chgView;
DateTime tmpDte;
Date tmpDte2;
Database DB = this.getDataDB();
chgView = DB.getView("(xpViewCalendar01)");
nav = chgView.createViewNav();
Writer out = response.getWriter();
JsonWriter writer = new JsonWriter(out, false);
writer.isCompact();
writer.startArray();
for (ViewEntry entry : nav) {
//Vector<?> columnValues = entry.getColumnValues();
cnt = cnt + 1;
writer.startArrayItem();
writer.startObject();
//Event Title
writer.startProperty("title");
writer.outStringLiteral(String.valueOf(entry.getColumnValues().get(0)));
writer.endProperty();
//Change id
writer.startProperty("id");
writer.outStringLiteral(cnt.toString());
writer.endProperty();
//Start Date and Time
writer.startProperty("start");
tmpDte = (DateTime) entry.getColumnValues().get(4);
tmpDte2 = tmpDte.toJavaDate();
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
String tmpStr = df.format(tmpDte2);
writer.outStringLiteral(tmpStr);
writer.endProperty();
//End Date and Time (same as start)
writer.startProperty("end");
writer.outStringLiteral(tmpStr);
writer.endProperty();
writer.endObject();
writer.endArrayItem();
}
writer.endArray();
writer.flush();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public Database getDataDB() {
Session session = Factory.getSession();
Database DataDB = session.getDatabase(CacheBean.get().getAppDataDBPath());
return DataDB;
}
public void setDataDB(Database dataDB) {
this.dataDB = dataDB;
}
}
This rest service is not totally completed yet, as I am not grabbing the "end" date nor grabbing the allDay element, although I have put in hooks for them in the entry form. But I think that would be pretty easy to add to this code.
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xe="http://www.ibm.com/xsp/coreex">
<xp:this.properties>
<xp:parameter name="xsp.resources.aggregate" value="true" />
</xp:this.properties>
<xp:this.resources>
<xp:headTag tagName="script">
<xp:this.attributes>
<xp:parameter name="type" value="text/javascript" />
<xp:parameter name="src"
value="FullCalendar/moment.min.js" />
</xp:this.attributes>
</xp:headTag>
<xp:script src="FullCalendar/fullcalendar.min.js"
clientSide="true">
</xp:script>
<xp:styleSheet href="FullCalendar/fullcalendar1.min.css"></xp:styleSheet>
<xp:styleSheet href="/cc_CommonGrid.css"></xp:styleSheet>
</xp:this.resources>
<!--The Container-->
<div class="container-fluid">
<!--The Button Bar-->
<div class="toolbar" style="width: 100% !important">
<div class="row">
<span style="margin-right:10px">
<button type="button" id="newDoc"
class="btn btn-primary">
Add Event
</button>
</span>
<span style="float: right">
<div class="input-group" style="width:300px">
<input type="text" id="searchInput"
class="form-control"
style="border-radius: 5px; border-bottom-right-radius:0px ;border-top-right-radius: 0px"
placeholder="Search for..." />
</div>
</span>
</div>
</div>
<!--The Button Bar-->
<!--The Grid-->
<div
id="div1"
class="row"
style="margin-top:15px">
<!--The Grid-->
<xp:div
id="grid"
style="background-color:rgb(255,255,255)"
styleClass="cal">
</xp:div>
<!--The Grid-->
</div>
<!--The Grid-->
</div>
<!--The Container-->
<xp:scriptBlock id="scriptBlock1">
<xp:this.value><![CDATA[// Add Document
$('#newDoc').click(function(event){
var url = "xpFormEvent.xsp";
window.open(url,"_self");
});
$(document).ready(function() {
//Get URL for web serice
var b1 = "#{javascript:context.getUrl().getAddress().replace(view.getPageName(), '');}"
var b2 = b1 + "/xpRest.xsp/calendarEvents";
var calCon = $(".cal");
calCon.fullCalendar({
header: {
left: 'prevYear,nextYear',
center: 'title',
right: 'today,month,prev,next'
},
eventSources: [
{
url: b2
}
]
});
})
]]></xp:this.value>
</xp:scriptBlock>
</xp:view>
OK so here is the code for the ccCalendarView01:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xe="http://www.ibm.com/xsp/coreex">
<xp:this.properties>
<xp:parameter name="xsp.resources.aggregate" value="true" />
</xp:this.properties>
<xp:this.resources>
<xp:headTag tagName="script">
<xp:this.attributes>
<xp:parameter name="type" value="text/javascript" />
<xp:parameter name="src"
value="FullCalendar/moment.min.js" />
</xp:this.attributes>
</xp:headTag>
<xp:script src="FullCalendar/fullcalendar.min.js"
clientSide="true">
</xp:script>
<xp:styleSheet href="FullCalendar/fullcalendar1.min.css"></xp:styleSheet>
<xp:styleSheet href="/cc_CommonGrid.css"></xp:styleSheet>
</xp:this.resources>
<!--The Container-->
<div class="container-fluid">
<!--The Button Bar-->
<div class="toolbar" style="width: 100% !important">
<div class="row">
<span style="margin-right:10px">
<button type="button" id="newDoc"
class="btn btn-primary">
Add Event
</button>
</span>
<span style="float: right">
<div class="input-group" style="width:300px">
<input type="text" id="searchInput"
class="form-control"
style="border-radius: 5px; border-bottom-right-radius:0px ;border-top-right-radius: 0px"
placeholder="Search for..." />
</div>
</span>
</div>
</div>
<!--The Button Bar-->
<!--The Grid-->
<div
id="div1"
class="row"
style="margin-top:15px">
<!--The Grid-->
<xp:div
id="grid"
style="background-color:rgb(255,255,255)"
styleClass="cal">
</xp:div>
<!--The Grid-->
</div>
<!--The Grid-->
</div>
<!--The Container-->
<xp:scriptBlock id="scriptBlock1">
<xp:this.value><![CDATA[// Add Document
$('#newDoc').click(function(event){
var url = "xpFormEvent.xsp";
window.open(url,"_self");
});
$(document).ready(function() {
//Get URL for web serice
var b1 = "#{javascript:context.getUrl().getAddress().replace(view.getPageName(), '');}"
var b2 = b1 + "/xpRest.xsp/calendarEvents";
var calCon = $(".cal");
calCon.fullCalendar({
header: {
left: 'prevYear,nextYear',
center: 'title',
right: 'today,month,prev,next'
},
eventSources: [
{
url: b2
}
]
});
})
]]></xp:this.value>
</xp:scriptBlock>
</xp:view>
I have my render() method with no code.
And I have this action-method:
#ProcessAction(name = "viewBook")
public void viewBook(ActionRequest actionRequest,ActionResponse actionResponse) throws SystemException, PortalException {
long bookId = ParamUtil.getLong(actionRequest, "bookId");
Book book = BookLocalServiceUtil.getBook(bookId);
actionRequest.setAttribute(FinalStrings.BOOK_ENTRY, book);
actionResponse.setRenderParameter("jspPage", "/html/LibraryPortlet/view_book.jsp");
How can I rewrite this "GET" method into render() method? I mean I need to run
public void render(RenderRequest renderRequest, RenderResponse rendeResponse){
super.render(renderRequest, renderResponse)
}
in the default situation and
public void render(RenderRequest renderRequest, RenderResponse rendeResponse){
\\THIS CODE IS NOT WORKING, IT'S JUST TO SHOW WHAT I WANT!
long bookId = ParamUtil.getLong(actionRequest, "bookId");
Book book = BookLocalServiceUtil.getBook(bookId);
actionRequest.setAttribute(FinalStrings.BOOK_ENTRY, book);
actionResponse.setRenderParameter("jspPage", "/html/LibraryPortlet/view_book.jsp");
when I need to use viewBook() method. How can I parametrize(?) render() method?
Update:
For more details I attached one screenshot:
Meanwhile in my action.jsp:
<liferay-ui:icon-menu>
<portlet:actionURL name="deleteBook" var="deleteURL">
<portlet:param name="bookId"
value="${String.valueOf(book.getBookId())}" />
</portlet:actionURL>
<portlet:renderURL name="viewBook" var="viewURL">
<portlet:param name="bookId"
value="${String.valueOf(book.getBookId())}" />
</portlet:renderURL>
<portlet:renderURL var="editBookURL" name="viewEdit">
<portlet:param name="bookId" value="${String.valueOf(book.getBookId())}" />
</portlet:renderURL>
<liferay-ui:icon image="add" message="View" url="${viewURL.toString()}" />
<liferay-ui:icon image="add" message="Edit" url="${editBookURL.toString()}" />
<liferay-ui:icon-delete image="delete" message="Delete" url="${deleteURL.toString()}" />
In my view_book.jsp:
<%#page import="com.softwerke.FinalStrings"%>
<%#page import="com.softwerke.model.Book"%>
<%#page import="com.softwerke.service.BookLocalServiceUtil"%>
<%#page import="com.liferay.portal.kernel.util.ParamUtil"%>
<%# include file="/html/init.jsp"%>
<portlet:renderURL var="backURL">
<portlet:param name="jspPage" value="/html/view.jsp"/>
</portlet:renderURL>
<liferay-ui:header backURL="${backURL}" title="Back" />
<%
Book book = (Book) request.getAttribute(FinalStrings.BOOK_ENTRY);
%>
<aui:form>
<aui:model-context bean="${book}" model="${Book.class}" />
<aui:input name="bookName" label="Book Name" disabled="true"/>
<aui:input type="textarea" name="description" label="Description" disabled="true"/>
<aui:input name="authorName" label="Author Name" disabled="true"/>
<aui:input name="price" label="Price" disabled="true"/>
</aui:form>
According to my task I can not use Action URL here. What should I do???
You can send a command param to the render, so you can split the logic into two or more render methods, depending on the command, or maybe easier, invoke a mvcPath without the need of implementing anything in render(). Include something like this in the jsp with your list of books:
<portlet:renderURL var="myBookURL">
<portlet:param name="mvcPath" value="/view_book.jsp" />
<portlet:param name="bookId" value="<%= someBookId %>" />
</portlet:renderURL>
View My Book
You just need a view_book.jsp with something like:
<%
long bookId = ParamUtil.getLong(request, "bookId");
Book book = BookLocalServiceUtil.getBook(bookId);
%>
Hope it helps.
I am using <liferay-ui:tabs> for displaying jsp pages as tabs. I am able to see my pages as tabs but If I navigate to one of my pages in the tab and on click of the button then it is navigating to some other page, that it showing in a separate page instead of showing under that tab. I need to click of button events the control should be still under the tabs. my Code is as follows,
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%><%#include file="/html/users/init.jsp"%>
<portlet: defineObjects />
<portlet:renderURL var="navigateTabURL"/>
<% String navigateTab = ParamUtil.getString(request, "tabs1","Current"); %>
<liferay-ui:tabs names="Current, Available" url="<%=navigateTabURL.toString()%>" >
<c:if test='<%= navigateTab.equalsIgnoreCase("Current")%>' >
<jsp:include page="current_members.jsp" flush="true" />
</c:if>
<c:if test='<%= navigateTab.equalsIgnoreCase("Available")%>' >
<jsp:include page="available_members.jsp" flush="true" />
</c:if>
</liferay-ui:tabs>
The pages "Current" and "Available" are showing correctly, But If I click any button in my Current page it is navigating to some other jsp I need that jsp also under that tabs only not showing as a separate page.
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%><%#include file="/html/users/init.jsp"%>
<portlet: defineObjects />
<%
List<User> userList = (List) request.getAttribute("UserGroupList");
//out.println(userList.size());
%>
<%!
List<User> users = null;
int totalNoOfUsers=0;
String value = null;
%>
<%
//totalNoOfUsers = UserLocalServiceUtil.getUsersCount();
totalNoOfUsers = userList.size();
users = userList;
%>
<liferay-ui:search-container delta="5" emptyResultsMessage="no-users-were-found" rowChecker="<%= new RowChecker(renderResponse) %>" >
<liferay-ui:search-container-results results="<%= ListUtil.subList(users,searchContainer.getStart(),searchContainer.getEnd()) %>"
total="<%= totalNoOfUsers %>">
</liferay-ui:search-container-results>
<liferay-ui:search-container-row className="com.liferay.portal.model.User" keyProperty="userId" modelVar="user">
<liferay-ui:search-container-row-parameter name="userIds" value="<%= user.getUserId()%>">
</liferay-ui:search-container-row-parameter>
<liferay-ui:search-container-column-text name="UserName" value="
<%= user.getScreenName()%>" />
<liferay-ui:search-container-column-text name="First Name" value="<%= user.getFirstName() %>">
</liferay-ui:search-container-column-text>
<liferay-ui:search-container-column-text name="Last Name" value="<%= user.getLastName() %>">
</liferay-ui:search-container-column-text>
<liferay-ui:search-container-column-jsp align="right" path="/html/users/custom_user_actions.jsp" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
<liferay-ui:search-container delta="5" emptyResultsMessage="no-users-were-found" />
<portlet:actionURL name="viewEntry" var="viewEntryURL"></portlet:actionURL>
<aui:form action="<%= viewEntryURL %>" name="<portlet:namespace />fms">
<aui:button type="submit" value="Cancel"></aui:button>
</aui:form>
How do I navigate the tabs as dynamic requests. Any suggestions please!!
To retain a tab selection, "value" attribute of should be mentioned with name of tab to select.
If "value" attribute not specified then first tab will be considered as active.
For example, please refer following file in liferay portal sources.
portal-web/docroot/html/portlet/dockbar/add_panel.jsp
Also, below post in liferay forum should help.
http://www.liferay.com/en_GB/community/forums/-/message_boards/message/4809190
Im trying to customize the login portlet for my purpose using this portlet login sample.
But when i login with test#liferay.com with a wrong password it shows "web page is not available"
SignInPortlet.java
public class SignInPortlet extends MVCPortlet {
#Override
public void processAction(
ActionRequest actionRequest, ActionResponse actionResponse)
throws IOException, PortletException {
String className = "com.liferay.portlet.login.action.LoginAction";
PortletConfig portletConfig = getPortletConfig();
NoRedirectActionResponse noRedirectActionResponse =
new NoRedirectActionResponse(actionResponse);
try {
PortletActionInvoker.processAction(
className, portletConfig, actionRequest,
noRedirectActionResponse);
}
catch (Exception e) {
_log.error(e, e);
}
String login = ParamUtil.getString(actionRequest, "login");
String password = ParamUtil.getString(actionRequest, "password");
String rememberMe = ParamUtil.getString(actionRequest, "rememberMe");
if (Validator.isNull(noRedirectActionResponse.getRedirectLocation())) {
actionResponse.setRenderParameter("login", login);
actionResponse.setRenderParameter("rememberMe", rememberMe);
}
else {
String redirect =
PortalUtil.getPathMain() + "/portal/login?login=" + login +
"&password=" + password + "&rememberMe=" + rememberMe;
actionResponse.sendRedirect(redirect);
}
}
private static Log _log = LogFactoryUtil.getLog(SignInPortlet.class);
}
View.jsp
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%# taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%# taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<%# taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%# taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%# page import="com.liferay.portal.CookieNotSupportedException" %>
<%# page import="com.liferay.portal.NoSuchUserException" %>
<%# page import="com.liferay.portal.PasswordExpiredException" %>
<%# page import="com.liferay.portal.UserEmailAddressException" %>
<%# page import="com.liferay.portal.UserLockoutException" %>
<%# page import="com.liferay.portal.UserPasswordException" %>
<%# page import="com.liferay.portal.UserScreenNameException" %>
<%# page import="com.liferay.portal.kernel.language.LanguageUtil" %>
<%# page import="com.liferay.portal.kernel.util.ClassResolverUtil" %>
<%# page import="com.liferay.portal.kernel.util.Constants" %>
<%# page import="com.liferay.portal.kernel.util.GetterUtil" %>
<%# page import="com.liferay.portal.kernel.util.HtmlUtil" %>
<%# page import="com.liferay.portal.kernel.util.MethodKey" %>
<%# page import="com.liferay.portal.kernel.util.ParamUtil" %>
<%# page import="com.liferay.portal.kernel.util.PortalClassInvoker" %>
<%# page import="com.liferay.portal.kernel.util.PropsUtil" %>
<%# page import="com.liferay.portal.model.Company" %>
<%# page import="com.liferay.portal.security.auth.AuthException" %>
<%# page import="javax.portlet.WindowState" %>
<portlet:defineObjects />
<liferay-theme:defineObjects />
<c:choose>
<c:when test="<%= themeDisplay.isSignedIn() %>">
<%
String signedInAs = user.getFullName();
if (themeDisplay.isShowMyAccountIcon()) {
signedInAs = "" + signedInAs + "";
}
%>
<%= LanguageUtil.format(pageContext, "you-are-signed-in-as-x", signedInAs, false) %>
</c:when>
<c:otherwise>
<%
MethodKey methodKey = new MethodKey(ClassResolverUtil.resolveByPortalClassLoader("com.liferay.portlet.login.util.LoginUtil"), "getLogin", HttpServletRequest.class, String.class, Company.class);
String login = GetterUtil.getString((String)PortalClassInvoker.invoke(false, methodKey, request, "login", company));
boolean rememberMe = ParamUtil.getBoolean(request, "rememberMe");
%>
<portlet:actionURL var="loginURL" />
<aui:form action="<%= loginURL %>" method="post" name="fm">
<aui:input name="saveLastPath" type="hidden" value="<%= false %>" />
<aui:input name="<%= Constants.CMD %>" type="hidden" value="<%= Constants.UPDATE %>" />
<aui:input name="rememberMe" type="hidden" value="<%= rememberMe %>" />
<liferay-ui:error exception="<%= AuthException.class %>" message="authentication-failed" />
<liferay-ui:error exception="<%= CookieNotSupportedException.class %>" message="authentication-failed-please-enable-browser-cookies" />
<liferay-ui:error exception="<%= NoSuchUserException.class %>" message="please-enter-a-valid-login" />
<liferay-ui:error exception="<%= PasswordExpiredException.class %>" message="your-password-has-expired" />
<liferay-ui:error exception="<%= UserEmailAddressException.class %>" message="please-enter-a-valid-login" />
<liferay-ui:error exception="<%= UserLockoutException.class %>" message="this-account-has-been-locked" />
<liferay-ui:error exception="<%= UserPasswordException.class %>" message="please-enter-a-valid-password" />
<liferay-ui:error exception="<%= UserScreenNameException.class %>" message="please-enter-a-valid-screen-name" />
<table class="lfr-table">
<tr>
<td>
<aui:input name="login" style="width: 120px;" type="text" value="<%= HtmlUtil.escape(login) %>" />
</td>
</tr>
<tr>
<td>
<aui:input name="password" style="width: 120px;" type="password" value="" />
<span id="<portlet:namespace />passwordCapsLockSpan" style="display: none;"><liferay-ui:message key="caps-lock-is-on" /></span>
</td>
</tr>
<c:if test='<%= company.isAutoLogin() && !GetterUtil.getBoolean(PropsUtil.get("session.disabled")) %>'>
<tr>
<td>
<aui:input checked="<%= rememberMe %>" name="rememberMe" type="checkbox" />
</td>
</tr>
</c:if>
</table>
<br />
<input type="submit" value="<liferay-ui:message key="sign-in" />" />
</aui:form>
<c:if test="<%= renderRequest.getWindowState().equals(WindowState.MAXIMIZED) %>">
<aui:script>
Liferay.Util.focusFormField(document.<portlet:namespace />fm.<portlet:namespace />login);
</aui:script>
</c:if>
<aui:script use="aui-base">
A.one('#<portlet:namespace />password').on(
'keypress',
function(event) {
Liferay.Util.showCapsLock(event, '<portlet:namespace />passwordCapsLockSpan');
}
);
</aui:script>
</c:otherwise>
</c:choose>
Does any one know how to solve this?
I changed the portlet code like this .Now it is ok
public class SignInPortlet extends MVCPortlet {
#Override
public void processAction(
ActionRequest actionRequest, ActionResponse actionResponse)
throws IOException, PortletException {
String className = "com.liferay.portlet.login.action.LoginAction";
PortletConfig portletConfig = getPortletConfig();
NoRedirectActionResponse noRedirectActionResponse =
new NoRedirectActionResponse(actionResponse);
try {
PortletActionInvoker.processAction(
className, portletConfig, actionRequest,
noRedirectActionResponse);
}
catch (Exception e) {
_log.error(e, e);
}
String login = ParamUtil.getString(actionRequest, "login");
String password = ParamUtil.getString(actionRequest, "password");
String rememberMe = ParamUtil.getString(actionRequest, "rememberMe");
Object object = SessionErrors.get( actionRequest, AuthException.class.getName() );
if (( object != null ) || Validator.isNull(noRedirectActionResponse.getRedirectLocation())) {
actionResponse.setRenderParameter("login", login);
actionResponse.setRenderParameter("rememberMe", rememberMe);
}
else {
String redirect =
PortalUtil.getPathMain() + "/portal/login?login=" + login +
"&password=" + password + "&rememberMe=" + rememberMe;
actionResponse.sendRedirect(redirect);
}
}
private static Log _log = LogFactoryUtil.getLog(SignInPortlet.class);
}
I'm working on a portlet for showing a list of rules, for selection.
And I want to focus the row of content selected on my database (rules variable loaded on init.jsp).
What I should do for focusing/highlighting exactly one row?
Should I use <c:when <c:otherwhise for all the .jsp:
I show a list of rules with this code:
<%# taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
<liferay-ui:search-container emptyResultsMessage="there-are-no-products" delta="5">
<liferay-ui:search-container-results>
<%
List<IRRule> tempResults = ActionUtil.getRules(renderRequest);
results = ListUtil.subList(tempResults, searchContainer.getStart(),
searchContainer.getEnd());
total = tempResults.size();
pageContext.setAttribute("results", results);
pageContext.setAttribute("total", total);
%>
</liferay-ui:search-container-results>
<liferay-ui:search-container-row
className="com.everis.oriol.inputrules.model.IRRule"
keyProperty="ruleId"
modelVar="rule">
<liferay-ui:search-container-column-text
name="ruleName"
property="ruleName"
/>
<liferay-ui:search-container-column-text
name="ruleDescription"
property="ruleDescription"
/>
<liferay-ui:search-container-column-jsp
path="/row.jsp"
align="right"
/>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
In the init.jsp file I have...
<%
long groupId = themeDisplay.getScopeGroupId();
List<IRSelect> rulesPas = IRSelectLocalServiceUtil.getRule(groupId);
String rules = rulesPas.get(0).getRuleName();
%>
I exactly want to compare...
<liferay-ui:search-container-column-text
name="ruleName"
property="ruleName"
/>
with...
rules
Thank you for your help
One of the ways I can think of is by setting the bold attribute of <liferay-ui:search-container-row> tag
which would show the element as bold if its value is true:
<liferay-ui:search-container-row
className="com.everis.oriol.inputrules.model.IRRule"
keyProperty="ruleId"
modelVar="rule"
bold="<%=rules.equals(rule.getRuleName()) %>">
...
</liferay-ui:search-container-row>
Or by setting a CSS class for the entire row if you want more options to style the row:
<liferay-ui:search-container-row
className="com.everis.oriol.inputrules.model.IRRule"
keyProperty="ruleId"
modelVar="rule">
<%
if (rules.equals(rule.getRuleName())) {
// here "row" is the ResultRow object, instance for each row
row.setClassName("my-custom-css-class");
}
%>
<liferay-ui:search-container-column-text
name="ruleName"
property="ruleName"
/>
...
</liferay-ui:search-container-row>
If you want that only the rule column text in that one row should be shown differently and not the entire row then:
<liferay-ui:search-container-column-text
name="ruleName"
property="ruleName"
cssClass="<%=rules.equals(rule.getRuleName()) ? \"my-custom-css-class\" : \"\" %>"
/>