Pagination with several Searchcontainer - pagination

Try to how to implement Pagination the mapping several Searchcontainer to container page by byi independent.
Here 2 Searchcontainer with different list to display.
I need to change page in first Searchcontainer and dont change page in second.(vice versa)
<aui:form action="<%= renderURL.toString()%>" method="post" name="fm" showEmptyOption="<%= true%>">
<div>
<%
List list = ServiceOrderSearchUtil.simpleSearch(themeDisplay, keywords, serviceOrdersForUserExt);
int count = ServiceOrderSearchUtil.searchCount();
%>
<liferay-ui:panel-container extended="true" accordion="true" id="lfrpc1">
<liferay-ui:panel title='<%= LanguageUtil.get(pageContext, "MaisOrders") + " (" + count + ")"%>' collapsible="true" defaultState="open" id="lfrp1" >
<liferay-ui:search-container iteratorURL="<%= iterURL%>" emptyResultsMessage="no-service-orders-were-found" delta="<%= delta%>">
<liferay-ui:search-container-results>
<%
results = list;
total = count;
results = ListUtil.subList(results, searchContainer.getStart(), searchContainer.getEnd());
pageContext.setAttribute("results", results);
pageContext.setAttribute("total", total);
%>
</liferay-ui:search-container-results>
<%# include file="/jsp/dizo-chief-panel/serviceorder_columns.jspf"%>
<liferay-ui:search-iterator searchContainer="<%= searchContainer%>" paginate="true" />
</liferay-ui:search-container>
</liferay-ui:panel>
</liferay-ui:panel-container>
</div>
<div>
<%
list = ServiceOrderSearchUtil.simpleSearchMV(themeDisplay, keywords, serviceOrdersExt);
count = ServiceOrderSearchUtil.searchCount();
%>
<liferay-ui:panel-container extended="true" accordion="true" id="lfrpc2">
<liferay-ui:panel title='<%= LanguageUtil.get(pageContext, "MVRequests") + " (" + count + ")"%>' collapsible="true" defaultState="close" id="lfrp2" >
<liferay-ui:search-container iteratorURL="<%= iterURL%>" emptyResultsMessage="no-service-orders-were-found" delta="<%= delta%>">
<liferay-ui:search-container-results>
<%
results = list;
total = count;
results = ListUtil.subList(results, searchContainer.getStart(), searchContainer.getEnd());
pageContext.setAttribute("results", results);
pageContext.setAttribute("total", total);
%>
</liferay-ui:search-container-results>
<%# include file="serviceorder_columns.jspf"%>
<liferay-ui:search-iterator searchContainer="<%= searchContainer%>" paginate="false" />
</liferay-ui:search-container>
</liferay-ui:panel>
</liferay-ui:panel-container>
</div>
</aui:form>
sorry for my English ;)

You will need to use 2 Iterator Urls , one for each search container, then use the 'curParam' in each search:container
for example :
String table1Cur = ParamUtil.getString(renderRequest,"table1Cur");
PortletURL table1Url = renderResponse.createRenderURL();
table1Url.setParameter("table1Cur", table1Cur);
<liferay-ui:search-container id="Table1Search" iteratorURL="<%= table1Url %>" curParam="table1Cur" >

Related

Search box in search container

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);
}
}

How to handle invalid authentication in liferay sign in portlet

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);
}

Passing an array to a EJS view, using Bookshelf.JS

My logic:
/* GET /events/list */
router.get('/events/list', function(req, res) {
new db.Tag({})
.fetchAll()
.then(function(tags) {
res.locals.title = "List of events";
res.locals.tags = tags;
res.render('events/list.ejs');
});
});
My view:
<% for (var tag in tags) { %>
<div class="checkbox">
<label>
<input type="checkbox" data-tag-id="<%= tag.tagId %>" />
<%= tag.name %>
</label>
</div>
<% } %>
What I'm getting:
[x] undefined
[x] undefined
[x] undefined
[x] undefined
What I should be getting:
[x] foo
[x] bar
[x] zort
[x] troz
I also tried passing
res.locals.tags = tags.toJSON();
and also
res.locals.tags = JSON.stringify(tags);
So.. how do I finally pass my collection to an EJS view?
I also logged (console.log(tags)) just after then(function(tags) and I'm getting the models (tags in this case) correctly.
I also tried tags.forEach in my EJS view but a native javascript array like this: [{tagId:1, name:"blah"}, {tagId:2, name"Foo"}] doesn't have "forEach" method implemented
In your template, use forEach (if available) or loop using the index instead.
server.js
res.locals.tags = tags.toJSON();
view.html (with [].forEach)
<% tags.forEach(function(tag) { %>
<div class="checkbox">
<label>
<input type="checkbox" data-tag-id="<%= tag.tagId %>" />
<%= tag.name %>
</label>
</div>
<% }) %>
view.html (with indices)
<% for (var i in tags) { %>
<div class="checkbox">
<label>
<input type="checkbox" data-tag-id="<%= tags[i].tagId %>" />
<%= tags[i].name %>
</label>
</div>
<% } %>
Here's an alternative to using Array.prototype.forEach. You give the Bookshelf collection to the view. Bookshelf.Collection has its own .forEach:
server.js
res.locals.tags = tags; // NOT .toJSON()
view.html
<% tags.forEach(function(tag) { %>
<div class="checkbox">
<label>
<input type="checkbox" data-tag-id="<%= tag.id %>" />
<%= tag.get('name') %>
</label>
</div>
<% }) %>

Disable a row based on condition from database in Liferay Search Container

I have to disable a row that I retrieve from the database using Liferay search container. I have certain conditions stored in the database.
What I wish to achieve is this:
I am displaying a list of students whose attendance need to be marked.
Sometimes the students may take a leave in advance in which case the attendance is pre-marked in the database.
So when the form for marking attendance is displayed, I want to disable marking attendance by disabling the row containing the data of student whose attendance is already marked.
What I want to do is, if the attendance is pre-marked, show the row on the form with pre-marked attendance and do not allow the user to mark attendance for that student i.e. disable the row.
How can I achieve this?
EDITED:
The code snippet
Mark Attendance for Today:
<%=new java.util.Date()%>
<portlet:actionURL name="updateAtt" var="updateAttURL" />
<aui:form name="updateAtt" action="<%=updateAttURL.toString() %>" method="post" >
Choose Date to mark Attendance:
<liferay-ui:input-date formName="attendanceDate" yearRangeStart="<%=year %>" yearRangeEnd="<%=year %>"
yearValue="<%=year %>" monthValue="<%=month %>" dayValue="<%=day %>"
dayParam="datt" monthParam="matt" yearParam="yatt" />
<portlet:renderURL var="viewstudentDataURL"/>
<liferay-ui:search-container delta="20" emptyResultsMessage="No Results Found">
<liferay-ui:search-container-results total="<%= studentAttendanceDetails .size() %>"
results="<%= ListUtil.subList(studentAttendanceDetails , searchContainer.getStart(), searchContainer.getEnd()) %>" />
<liferay-ui:search-container-row modelVar="search"
className="com.corpserver.mis.portal.model.Student">
<%
String LImageId = String.valueOf(search.getFileEntryId());
long ImageId = Long.valueOf(LImageId);
DLFileEntry image = DLFileEntryLocalServiceUtil .getFileEntry(ImageId );
String imageURL = "/documents/" + image.getGroupId() + "/" + image.getFolderId() + "/" + image.getTitle()+"/"+image.getUuid();
%>
<liferay-ui:search-container-column-text name="student Photo" href = "">
<img src="<%=imageURL%>" height="50" width="50"/>
</liferay-ui:search-container-column-text>
<!-- Code to display student Image -->
<%
String eol = System.getProperty("line.separator");
%>
<liferay-ui:search-container-column-text name='student Name' value='<%=String.valueOf(search.getstudentFname()) + String.valueOf(search.getstudentLname()) + "<br>" + String.valueOf(search.getstudentTitle()) %>' href="" >
</liferay-ui:search-container-column-text>
<liferay-ui:search-container-column-text name="Attendance Status">
<label>Present</label><input type = "radio" name ='updateattendance<%=String.valueOf(search.getstudentId())%>' value = "Present" />
<label>Absent</label><input type = "radio" name= 'updateattendance<%=String.valueOf(search.getstudentId())%>' value = "Absent"/>
</liferay-ui:search-container-column-text>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator searchContainer="<%=searchContainer %>" paginate="<%=true %>" />
</liferay-ui:search-container>
<input type = "submit" value = "Update"/>
</aui:form>
</body>
</html>
You can use conditional statements to just show the label instead of the input control or disabled the input control, as follows:
<%
String LImageId = String.valueOf(search.getFileEntryId());
long ImageId = Long.valueOf(LImageId);
DLFileEntry image = DLFileEntryLocalServiceUtil .getFileEntry(ImageId );
String imageURL = "/documents/" + image.getGroupId() + "/" + image.getFolderId() + "/" + image.getTitle()+"/"+image.getUuid();
// you can define a flag for the pre-marked attendance
boolean preMarkFlag = isStudentPreMarked(); // have value true (student is premarked) or false (if the student is not pre-maked)
%>
<liferay-ui:search-container-column-text name="Attendance Status">
<label>Present</label>
<input type = "radio"
name ='updateattendance<%=String.valueOf(search.getstudentId())%>'
value = "Present"
<%= preMarkFlag ? "disabled" : "" %> />
<label>Absent</label>
<input type = "radio"
name ='updateattendance<%=String.valueOf(search.getstudentId())%>'
value = "Absent"
<%= preMarkFlag ? "disabled" : "" %> />
</liferay-ui:search-container-column-text>
Or another way is to just show a label and not show the input radio-button at all
<liferay-ui:search-container-column-text name="Attendance Status">
<%
// I am assuming if preMarkFlag is true then the student is absent
// as mentioned in your question
if (preMarkFlag) {
%>
<label>Absent</label>
<%
} else {
%>
<label>Present</label>
<input type = "radio"
name ='updateattendance<%=String.valueOf(search.getstudentId())%>'
value = "Present"
<%= preMarkFlag ? "disabled" : "" %> />
<label>Absent</label>
<input type = "radio"
name ='updateattendance<%=String.valueOf(search.getstudentId())%>'
value = "Absent"
<%= preMarkFlag ? "disabled" : "" %> />
<%
}
%>
</liferay-ui:search-container-column-text>

liferay-ui view selecting a row

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\" : \"\" %>"
/>

Resources