Friday, 6 February 2015

How to embed a Web Content on your theme?

Requirement:
If you want to display any web content in all the pages then embed that web content in to  theme.



Open portal_normal.vm file of your theme(docroot/_diff/templete/portal_normal.vm)

<pre>
<div id="image-slider">





#set ($VOID = $velocityPortletPreferences.setValue('groupId', $themeDisplay.getCompanyGroupId().toString()))
#set ($VOID = $velocityPortletPreferences.setValue('articleId', $webContentID))
#set ($VOID = $velocityPortletPreferences.setValue('portletSetupShowBorders', 'false'))
#set ($portlet_id = '56')
#set ($my_portlet_id = "${portlet_id}_INSTANCE_ABC1")
$theme.runtime($my_portlet_id, "", $velocityPortletPreferences.toString())
$velocityPortletPreferences.reset()
</div>
</pre>


                             likewise 


<pre>
<div id="image-slider">





#set ($VOID = $velocityPortletPreferences.setValue('groupId', $themeDisplay.getScopeGroupId().toString()))
#set ($VOID = $velocityPortletPreferences.setValue('articleId', '16806'))
#set ($VOID = $velocityPortletPreferences.setValue('portletSetupShowBorders', 'false'))
#set ($portlet_id = '56')
#set ($my_portlet_id = "${portlet_id}_INSTANCE_1234")
$theme.runtime($my_portlet_id, "", $velocityPortletPreferences.toString())
$velocityPortletPreferences.reset()
</div>
</pre>

If you want to put two different instance of web content display portlet
 on same page and want to display different web content on it, You'll 
need to modify its instance id.
So make sure value for instance id in header and footer is different.

#set ($my_portlet_id = "${portlet_id}_INSTANCE_1234")


If you have used _INSTANCE_1234 in header then use _INSTANCE_5678 in footer code.

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>