Tuesday, 18 April 2017

how to show/hide divs based on radio button selection using aui script

My requirement is to show/hide div based on aui radio button option.I followed the below steps to do it.

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<portlet:defineObjects />
   
<div class="row">
    <div class="span5">
         <div class="loads">Whether Loads are operational during week-Ends and National Holidays:</div>
         <div id="selectalign">
                   <aui:input type="radio" name="nationalholidays" value="yes"
                                label="yes" />
                   <aui:input type="radio" name="nationalholidays" value="no"
                                label="no" />
         </div>
    </div>
    <div class="span7 running" style="display:none">
         <aui:input type="text"
                            name="whatistheMinRunningloadduringWeekendsandNationalHolidays"
                            label="If yes, what is the Min Running load during Weekends and National Holidays" inlineLabel="true"/>
    </div>
</div>

<aui:script>
AUI().ready('node', 'event', function(A){
    A.all("input[name=<portlet:namespace/>nationalholidays]").on('change', function() {
        var nationalholidaysType = A.one("input[name=<portlet:namespace/>nationalholidays]:checked").get("value");
        if(nationalholidaysType == "yes"){
            A.all('.running').show();
        }else{
            A.all('.running').hide();
        }
        });
   
    });
</aui:script>

Monday, 17 April 2017

Sending email to dynamic address using liferay "web-form-portlet"

I had a requirement to send the filled data on a web form portlet to custom email address. For example a user fills in data and want to receive the same on an email address he / she specifies during filling up the form.
  1.  Create a new field named as "Email" in web-from-portlet. 
  2. Modify the method in "WebFormPortlet.java" as follows
MailMessage mailMessage1 = new MailMessage();
            InternetAddress newToAddress = new InternetAddress(WebFormUtil.getEmailAddress(request, companyId,PortletPropsValues.ADMIN_EMAIL_FROM_ADDRESS),PortletPropsValues.ADMIN_EMAIL_FROM_NAME);
            mailMessage1.setHTMLFormat(true);
            mailMessage1.setFrom(newToAddress);
            InternetAddress toAddress = new InternetAddress(fieldsMap.get("Email"));
            mailMessage1.setTo(toAddress);
            mailMessage1.setBody("Thank you for your Interest");
            mailMessage1.setSubject(subject);
            MailServiceUtil.sendEmail(mailMessage1);


 

Steps to customise "Web form-Portlet" in liferay 6.2

  1. Path for the web form portlet is "../server/tomcat-7.0.42/webapps/web-form-portlet".
  2. Copy all the file which resides under the web-form-portlet to new folder called 'docroot' inside the same portlet.
  3. Create new portlet(new folder) under your sdk manually and place this folder inside your new folder.
  4. Now form your eclipse try to import the newly created portlet.
  5. Deploy the portlet.
  6. If any error while deploying just cleanup the web.xml file and redeploy it.