Sunday, 4 June 2023

Docmosis Implementation

 https://resources.docmosis.com/Documentation/Tornado/2.9.2/Tornado-Template-Guide.pdf

Tuesday, 1 February 2022

JavaScript - Single Line IF ELSE

properties['Value'] = (IsItMuted === true) ? 'On' : 'Off';  

The ? : is called a ternary operator and acts just like an if/else when used in an expression

var testValue= (props.brtUser === 'No') ? 'Promote to User' : 'Demote to Contact';

Use this <p>{testValue}</p>

Friday, 7 January 2022

What is OSGI?

 OSGI Lifecycle

Since Liferay has adopted OSGI standards it is necessary for us to know basic's of OSGI.

OSGI-stands for  Open Services Gateway initiative.

OSGI is a Java framework for developing and deploying dynamic modular software applications. 

Basic OSGI Module Lifecycle

OSGI Lifecycle includes following states
  1. Installed
  2. Resolved
  3. Starting
  4. Active
  5. Stopping
  6. Uninstalled


1) Installed
The bundle has been installed into the OSGi container, but some required bundle dependencies is missing the bundle in this state can’t be start.

2) Resolved
When bundle is in resolved state means all the required 
dependencies is available.And bundle is ready to be started.

3) Starting
Bundle is being started and BundleActivator.start() method is 
executed.
Bundle with lazy activation policy stay in this state until one of 
class file is loaded.It is state between resolved and active.

4) Active 
The bundle is active and running.

5) Stopping
Bundle is being stopped & BundleActivator.stop() method is 
executed.After stopping state is complete it again enters in to resolved state,Once enter in resolved state it can again started.

6) Uninstalled
Bundle has been removed from OSGI container.








Wednesday, 23 May 2018

Birthday Portlet

<%
SimpleDateFormat formatter = new SimpleDateFormat("MMM dd");
List<EmployeeDetails> list = EmployeeDetailsLocalServiceUtil.getEmployeeDetailses(-1, -1);
List<EmployeeDetails> blist = new ArrayList<>();
Date date = new Date();
for(EmployeeDetails e : list){
Date dob = e.getDob();
if( dob.getDate() == date.getDate() && dob.getMonth() == date.getMonth()){
blist.add(e);
}
}
%>
<%if(blist.isEmpty()){%>
<b>There is no B day</b>
<%}else if(!list.isEmpty()){
for(EmployeeDetails emp : blist){%>
<%

FileEntry dlfileentry = DLAppServiceUtil.getFileEntry(emp.getFileEntryId());
String imageURL ="/documents/" + dlfileentry.getGroupId() + "/"
+ dlfileentry.getFolderId() + "/" + dlfileentry.getTitle()
+ "/" + dlfileentry.getUuid();
%>
<a href="<%=imageURL%>"><img src="<%=imageURL%>" alt="image" class="mmm"/></a>

<p class="bday nomargin"><%=emp.getEmployeename() %></p>
<b class="wish">Wish you happy B day</b>

<%String dates=formatter.format(emp.getDob()); %>

<p class="bday"><%=dates%></p>
<%} }%>


Search By User Name

In jsp

<%PortletURL userNameURL = renderResponse.createActionURL();
userNameURL.setParameter(ActionRequest.ACTION_NAME, "userfilter");%>
<%
List<Billclaim> bill = null;
if(request.getAttribute("fn") != null){
bill = (List<Billclaim>) request.getAttribute("fn");
}else{
bill = BillclaimLocalServiceUtil.getBillclaims(-1, -1);
}
%>
<aui:form method="POST" name="fm" action="<%=userNameURL.toString() %>" >
<aui:input type="text" label="" name="userName" placeholder="Search By User Name">
</aui:input>
<aui:button type="submit" value="Search"/>
</aui:form>

BillclaimLocalServiceImpl.java
public List<Billclaim> getUserName(String userName){
   return billclaimPersistence.findByuserName(userName);
}

Controller
 public void userfilter(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException, SystemException, PortalException {
  String userName = ParamUtil.getString(actionRequest, "userName");
  List<Billclaim> fn = BillclaimLocalServiceUtil.getUserName(userName);
  actionRequest.setAttribute("fn", fn);
  actionResponse.setRenderParameter("jspPage", "/billView.jsp");
  SessionMessages.add(actionRequest, "searched");
  }

Service.xml
<finder name="userName" return-type="Collection">
<finder-column name="userName"></finder-column>
 </finder>


Wednesday, 25 April 2018

Status Pending & Approved using action

JSP:

<aui:option value="<%=billClaimPortletKeys.pending %>">Pending for approval</aui:option><aui:option value="<%=billClaimPortletKeys.approved%>">Approved</aui:option>

Constants file

public class billClaimPortletKeys {
    public static final String billClaim = "BillClaim";
    public static final String approved = "Approved";
    public static final String pending = "Pending For Approval";
    public static final String medical = "Medical";
    public static final String travel = "Travel";
    public static final String food = "Food";
    public static final String variablepay = "Variablepay";
    public static final String teamouting = "Team Outing";
    public static final String others = "Others";
}


 action.jsp

<%
    ResultRow row = (ResultRow) request.getAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW);
    Billclaim bill = (Billclaim) row.getObject();
   
    long fooId = ParamUtil.getLong(request, "fooId");
    PortletURL approvedURL = renderResponse.createActionURL();
    approvedURL.setParameter(ActionRequest.ACTION_NAME, "approved");
    approvedURL.setParameter("fooId", String.valueOf(bill.getFooId()));
%>

<liferay-ui:icon-menu>

<%{ %>
<liferay-ui:icon  image="delete" message="Delete" url="<%= deleteBillURL.toString()%>" />
<liferay-ui:icon  image="check" message="Approved" url="<%=approvedURL.toString() %>" />
<%} %>

</liferay-ui:icon-menu> 



 Controller

 public void approved(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException, SystemException, PortalException {
          Billclaim billclaim =null;
          String approved = billClaimPortletKeys.approved;
          long fooId = ParamUtil.getLong(actionRequest, "fooId");
          System.out.println("FooooID##################" +fooId);
          billclaim = BillclaimLocalServiceUtil.fetchBillclaim(fooId);
          billclaim.setStatus(approved);
          BillclaimLocalServiceUtil.updateBillclaim(billclaim);
      }


 

Thursday, 19 April 2018

SMS Configuration using sms horizon API

Step 1 - Login Sms horizon & get username & API key (http://smshorizon.co.in/api/sendsms.php?user=Mufas&apikey=LPDkKtHkmkRk8XEtbjrt&mobile=9620367054&message=welcome&senderid=saleem&type=txt)

Step 2 - Create Portet.properties inside resources folder

This is my user name & my api

smsuserid=mufas
password=LPDkKtHkmkRk8XEtbjrt
message= Thank you for submitting you feedback.
smsapi=http://smshorizon.co.in/api/sendsms.php?

Step 3 - Call sendsms() method in controller.

  public void sendMsg() throws UnsupportedEncodingException {
  System.out.println("SMS Working complaint #########################");
  Configuration configuration = ConfigurationFactoryUtil.getConfiguration(PortalClassLoaderUtil.getClassLoader(), "portlet");
 
  String userName = configuration.get("smsuserid");
  String password = configuration.get("password");
  String textMessage = configuration.get("message");
  String smsapi = configuration.get("smsapi");
  StringBuilder smsSenderURLQueryString = new StringBuilder();
  smsSenderURLQueryString.append("user="
+ URLEncoder.encode(userName, "UTF-8"));
smsSenderURLQueryString.append("&apikey="
+ URLEncoder.encode(password,
"UTF-8"));
smsSenderURLQueryString.append("&mobile="
+ URLEncoder.encode("9620367054", "UTF-8"));
smsSenderURLQueryString.append("&message="
+ URLEncoder.encode(textMessage, "UTF-8"));
smsSenderURLQueryString.append("&senderid="
+ URLEncoder.encode("MYTEXT", "UTF-8"));
smsSenderURLQueryString.append("&type=" + "TXT");
String completeSenderURLString = smsapi +smsSenderURLQueryString.toString();
HttpURLConnection connection = null;
URL completeSenderURL = null;
String conncetionResponse = null;
try{
completeSenderURL = new URL(completeSenderURLString);
connection = (HttpURLConnection) completeSenderURL.openConnection();
connection.setDoOutput(false);
connection.setDoInput(true);
conncetionResponse = connection.getResponseMessage();
int responseCode = connection.getResponseCode();
String responseMessage = connection.getResponseMessage();
}catch(Exception e){

}
  }