Sunday, 28 May 2017

How To Import and Export MySql Dump using command prompt

Import Dump into Database:

It will help to import entire database into specified database(eg: "importingDatabaseName").

c:\user\mufas>mysql -uroot  -proot  importingDatabaseName < Desktop/indexes.sql

Export Dump from Database:

It will help to take entire database as a dump.


c:\user\mufas>mysqldump  -u root -proot exportingDatabaseName> Desktop/indexes.sql

Fusion Chart

A simple Column 3D chart showing monthly revenue of Harry's SuperMart for last year.

http://jsfiddle.net/fusioncharts/xL3py/

Sunday, 30 April 2017

Css Sticky

HTML
==============================================
<h4>Scroll to see the sticky element <em>sticking</em></h4>
<div class="extra"></div>
<br />
<div id="wrapper">
  <div id="sticky">
    sticky
  </div>
</div>
<br />
<div class="extra"></div>

CSS
==============================
#sticky {
  position: sticky;
  background: #F762BC;
  width: 100px;
  height: 100px;
  top: 70px;
  left: 10px;
  display: flex;
  justify-content:center;
  align-items:center;
  box-shadow: 0 0 6px #000;
  text-shadow: 0 0 4px #fff
}

#wrapper {
  width: 75%;
  margin: auto;
  height: 400px;
  background-color: #ccc;
}

.extra{
  background: #ccc;
  width: 75%;
  margin: auto;
  height: 100px;
}

body {
  height: 1000px;
  font-family: georgia;
}
h4{
  text-align: center;
}

Sunday, 19 March 2017

Learning - Enterprise portal

View.jsp

<%@page import="com.liferay.portal.security.permission.PermissionThreadLocal"%>
<%@page import="com.liferay.portal.security.permission.PermissionChecker"%>
<%@page import="com.liferay.portal.theme.ThemeDisplay"%>
<%@include file="/html/new/init.jsp"%>


<portlet:defineObjects />
<%
PortletURL complaintBoxURL = renderResponse.createActionURL();
complaintBoxURL.setParameter(ActionRequest.ACTION_NAME, "complaintBox");

PortletURL complaintURL = renderResponse.createRenderURL();
complaintURL.setParameter("jspPage", "/html/new/complaintsView.jsp");


ThemeDisplay themedisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker();
permissionChecker.isOmniadmin();
%>

<div class="row-fluid">
    <div class="span10">
        <h5>Hi&nbsp;<%=themedisplay.getUser().getFirstName() %>, admin only can view your suggestion. So honestly submit your complaints.</h5>
    </div>
    <div class="span2">
        <%if(permissionChecker.isOmniadmin()){ %>
        <a href="<%=complaintURL.toString()%>"><button class="btn-warning">Complaint Box</button></a>
        <%}%>
    </div>
</div>
<hr>




<aui:form name="fm" method="POST" action="<%= complaintBoxURL.toString() %>">

<aui:input type="text" name="name" label="First Name" value="<%=themedisplay.getUser().getFullName() %>" inlineLabel="true" placeholder="Enter your name">
</aui:input>

<aui:input type="text" name="EmployeeId" label="Employee Id" inlineLabel="true" placeholder="Enter your Employee Id">
</aui:input>

<aui:select name="network" label="How is our office network?" inlineLabel="true">
        <aui:option>Select your </aui:option>
        <aui:option value="Excellent">Excellent</aui:option>
        <aui:option value="Verygood">Very good</aui:option>
        <aui:option value="Good">Good</aui:option>
        <aui:option value="Notbad">Not bad</aui:option>
        <aui:option value="waste">waste</aui:option>
</aui:select>

<aui:input type="textarea" name="pantryService" label="How is our pantry?" inlineLabel="true" placeholder="Your suggestion">
</aui:input>

<aui:input type="textarea" name="infrastructure" label="How to improve our infrastructure ?" inlineLabel="true" placeholder="Your suggestion">
</aui:input>

<aui:input type="textarea" name="manager" label="Type about your manager?" inlineLabel="true" placeholder="Please provide a brief summary of your manager">
</aui:input>


<div align="center">
<aui:button type="submit" cssClass="btn-info" value="Save"/>
<aui:button type="reset" cssClass="btn-primary" value="Reset"/>
</div>
</aui:form>



Complaints view

<%@page import="com.service.service.ComplaintBoxLocalServiceUtil"%>
<%@page import="com.service.model.ComplaintBox"%>
<%@include file="/html/library/init.jsp"%>
<%@page import="com.constants.NewConstants"%>


<h3>Complaint list</h3>
<hr>
<%

PortletURL iteratorURL = renderResponse.createRenderURL();
/* iteratorURL.setParameter("jspPage", NewConstants.page_list); */
PortletURL deleteBookURL = renderResponse.createActionURL();
deleteBookURL.setParameter(ActionRequest.ACTION_NAME,NewConstants.Delete_complaint);
/* deleteBookURL.setParameter("redirectURL", iteratorURL.toString()); */




List<ComplaintBox> cb = ComplaintBoxLocalServiceUtil.getComplaintBoxs(-1, -1);
%>


<%if(cb.isEmpty()){%>
<h3>There is no complaints. your company is going correct way.</h3>
<%}else{ %>


<%for(ComplaintBox complaint : cb){%>

<div>
<% deleteBookURL.setParameter("NId", Long.toString(complaint.getNId()));%>
    <span style="font-weight: bold">User Name :</span><span class="name"><%=complaint.getName()%></span><br>
    <span style="font-weight: bold">EmployeeId :</span><span class="name"><%=complaint.getEmployeeId() %></span><br>
    <span style="font-weight: bold">Office Network :</span><span class="name"><%=complaint.getNetwork() %></span><br>
    <span style="font-weight: bold">How is yor manager :</span><span class="name"><%=complaint.getManager()%></span><br>
    <span style="font-weight: bold">How is our infrastructure  :</span><span class="name"><%=complaint.getInfrastructure() %></span><br>
    <span style="font-weight: bold">How is our pantry :</span><span class="name"><%=complaint.getPantryService() %></span><br>

    <a href="<%= deleteBookURL.toString() %>">Delete</a>
</div>
<hr>
<%}%>

<%} %>

init

<%@taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
<%@taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%@page import="javax.portlet.PortletURL"%>
<%@page import="javax.portlet.ActionRequest"%>
<%@taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<%@page import="com.liferay.portal.kernel.util.WebKeys"%>
<%@page import="com.liferay.portal.kernel.dao.search.ResultRow"%>

controller

package com.test;

import java.io.IOException;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.servlet.http.HttpServletRequest;
import javax.swing.Box;

import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
import com.service.model.ComplaintBox;
import com.service.model.EmployeeDetails;
import com.service.model.impl.ComplaintBoxImpl;
import com.service.model.impl.EmployeeDetailsImpl;
import com.service.service.ComplaintBoxLocalServiceUtil;

/**
 * Portlet implementation class NewPortlet
 */
public class NewPortlet extends MVCPortlet {

    private static final HttpServletRequest Request = null;
   
    public void complaintBox(ActionRequest actionRequest,ActionResponse actionResponse)throws IOException, PortletException {
       
        String pantryService = ParamUtil.getString(actionRequest, "pantryService");
        String infrastructure = ParamUtil.getString(actionRequest, "infrastructure");
        String manager = ParamUtil.getString(actionRequest, "manager");
        String name = ParamUtil.getString(actionRequest, "name");
        String EmployeeId = ParamUtil.getString(actionRequest, "EmployeeId");
        String network = ParamUtil.getString(actionRequest, "network");
       
        ComplaintBox Box = new ComplaintBoxImpl();
       
        Box.setPantryService(pantryService);
        Box.setInfrastructure(infrastructure);
        Box.setManager(manager);
        Box.setName(name);
        Box.setEmployeeId(EmployeeId);
        Box.setNetwork(network);
       
        try {
            ComplaintBoxLocalServiceUtil.addComplaintBox(Box);
        } catch (SystemException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
       
   
       
        Box.getManager();
        Box.getNId();
        Box.getPantryService();
        Box.getInfrastructure();
        Box.getName();
        Box.getEmployeeId();
        Box.getNetwork();
       
       
        }
    public void deleteBook(ActionRequest actionRequest,ActionResponse actionResponse)throws IOException, PortletException, SystemException {
       
        System.out.println("##########################inside delete#####################################");
        long ndId = ParamUtil.getLong(actionRequest, "NId");
       
        try {
            ComplaintBox cmp = ComplaintBoxLocalServiceUtil.fetchComplaintBox(ndId);
            ComplaintBoxLocalServiceUtil.deleteComplaintBox(cmp);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
   
   

}


constants

package com.constants;

public class NewConstants{
    public static final String page_list = "/html/library/complaintsView.jsp";
    public static final String Delete_complaint = "deleteBook";
   
}

Tuesday, 29 November 2016

Input type only numbers(html5)

<input name="termsAndConditionsArticleId" value="${programDetailsForm.termsAndConditionsArticleId}" type="text"  pattern="^[0-9]*$" placeholder="Enter Digits only" title="Please enter numeric value only"/>


Increment & Decrements Hidden
<style>
input[type=number] {
    -moz-appearance:textfield;
}
</style>

Wednesday, 16 November 2016

Using Liferay Services in VM using ServiceLocator

When developing custom themes, we need to use Liferay services in VM. Its quite easy but tricky. So, putting here a simple example-
Write following in init-custom.vm

#set($organizationLocalService = $serviceLocator.findService("com.liferay.portal.
service.OrganizationLocalServiceUtil" )

Now you can use this service as follows:

#set ($org = $organizationLocalService.getOrganization($myPlace.getClassPK($myPlace.getClassPK()))

   

Getting Youtube Video Thumbnail image

<!--  This is for sample test code  -->

  <script type="text/javascript"> function getScreen( url, size ) {
if(url === null){
return "";
}
size = (size === null) ? "big" : size;
var vid;
var results;

results = url.match("[\\?&]v=([^&#]*)");
vid = ( results === null ) ? url : results[1];
if(size == "small"){
return "http://img.youtube.com/vi/"+vid+"/2.jpg"; }
else {
return "http://img.youtube.com/vi/"+vid+"/0.jpg"; }
}
</script>

 <%
  String url = "http://www.youtube.com/watch?v=E88uMNtPjvw";
 %>
<script type="text/javascript">

var imgUrl_small = getScreen("<%=url%>",'small');

 alert("this is image Url :"+imgUrl_small);

document.write('<img src="' + imgUrl_big + '" />');
document.write('<img src="' + imgUrl_small + '" />');

</script>

I hope its usefully for you..