Sunday, 11 January 2015

Search Container for Boolean value


Here we are storing paymentStatus as boolean(0,1), like 1=true=paid and 0=false=Unpaid when we display data using search Container by using property="paymentStatus"it will display true or false.But we want to dispaly Paid for true and Unpaid for False




<% 
String status;
if(info.getPaymentStatus()){
status="Paid";
}else{
status="Not Paid";
}
%>
<liferay-ui:search-container-column-text name="Payment Status" value="<%=status %>" />

<%
if(select.equalsIgnoreCase("RequestedForCancel")){
%>
<liferay-ui:search-container-column-jsp path="/html/Admin/bookingdetail/actionBookingDetails.jsp" name="Action">
</liferay-ui:search-container-column-jsp>

<%}%>

Wednesday, 7 January 2015

While select value from drop down popup will display

While select value from drop down popup will  display ,that popup is another jsp page you can display data on that popup .


view.jsp

<aui:script>
var myPop;
       function abc(url,abc){
       
              AUI().use('aui-dialog', 'aui-io', function(A)
              {
                 
                  myPop = new A.Dialog({

                  title: 'Nags Admin Reservation',

                  centered: true,

                  modal: true,

                  width: 800,

                  height: 250,

                  }).plug(A.Plugin.IO, {uri: url}).render();

              });

       }

</aui:script>
 

<%

PortletURL popURL = renderResponse.createRenderURL();
popURL.setParameter("jspPage", "/html/Admin/adminreservation/adminPopUp.jsp");
popURL.setWindowState(LiferayWindowState.POP_UP);
List<CarDetails> card= CarDetailsLocalServiceUtil.searchByType(type);

%>
<td>
<b>Model* </b><br><select id="model" name="model"  onchange="javascript:renderCar()" >
<option value="">---select---</option>
  <% for(CarDetails car : card){%>
<option value="<%=car.getModel() %>" <%if(car.getModel().equalsIgnoreCase(model)){ %>selected="selected" <%} %> ><%=car.getModel()%></option>
<%} %>
</select>

</td>



function renderCar() {
var url = "<%=popURL%>";
url = url+"&model="+$("#model").val() + "&type=" + "<%=type%> ";
abc(url);
}

 adminPopUp.jsp

<%@page import="java.util.ArrayList"%>
<%@page import="com.liferay.portal.kernel.util.ParamUtil"%>
<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
<%@page import="javax.portlet.PortletURL"%>
<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@page import="com.slayer.model.CarDetails"%>
<%@page import="java.util.List"%>
<%@page import="com.liferay.portal.kernel.util.WebKeys"%>
<%@page import="com.liferay.portal.kernel.dao.search.ResultRow"%>
<%@page import="com.liferay.portal.kernel.dao.search.SearchContainer"%>
<%@taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%@page import="com.slayer.service.CarDetailsLocalServiceUtil"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:defineObjects/>


<%
        String model = ParamUtil.getString(renderRequest, "model");
        String type = ParamUtil.getString(renderRequest, "type");

        List<CarDetails> carDetails = CarDetailsLocalServiceUtil.searchByModel(model,type);
   
%>

<liferay-ui:search-container  delta="5" emptyResultsMessage="Sorry. There are no items to display." >
        <liferay-ui:search-container-results total="<%=carDetails.size()%>"
            results="<%=ListUtil.subList(carDetails, searchContainer.getStart(),searchContainer.getEnd())%>" />
        <liferay-ui:search-container-row modelVar="car" className="CarDetails">
       
        <liferay-ui:search-container-column-text name="Type" property="type"/>
        <liferay-ui:search-container-column-text name="Color" property="color"/>
        <liferay-ui:search-container-column-text name="Year" property="year"/>
        <liferay-ui:search-container-column-text name="Licence" property="licence"/>
        <liferay-ui:search-container-column-text name="model" property="model"/>
        <liferay-ui:search-container-column-text name = "Select" >
        <input type = "radio" id="<%=car.getLicence() %>" name ='select'
        cartype= "<%=car.getType() %>"
        licence= "<%=car.getLicence() %>"
        Year= "<%=car.getYear() %>"
        Color= "<%=car.getColor() %>"
        value = "<%=car.getLicence() %>" onclick="javascript:choose(this);"/>
        </liferay-ui:search-container-column-text>
       
        </liferay-ui:search-container-row>
    <liferay-ui:search-iterator searchContainer="<%=searchContainer%>" />
    </liferay-ui:search-container> 
   
   
    <script>

function choose(va) {
   
    var typeOriginal = parent.window.document.getElementById("typeOriginal");
    var yearOriginal = parent.window.document.getElementById("yearOriginal");
    var colorOriginal = parent.window.document.getElementById("colorOriginal");
    var licenceOriginal = parent.window.document.getElementById("licenceOriginal");
   
    licenceOriginal.value = $(va).attr('licence');
    typeOriginal.value = $(va).attr('cartype');
    yearOriginal.value = $(va).attr('Year');
    colorOriginal.value = $(va).attr('Color');
   
     window.parent.myPop.close();
}



</script>