Monday 25 May 2015

Liferay Auto-Text-Field Example

<%@page import="javax.portlet.ActionRequest"%>
<%@page import="javax.portlet.PortletURL"%>
<%@page import="java.util.ArrayList"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix = "aui"%>


<%
 PortletURL portalURL = renderResponse.createActionURL();
 portalURL.setParameter(ActionRequest.ACTION_NAME, " getAutoFieldsData");
%>

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


<div id="phone-fields">
    <div class="lfr-form-row lfr-form-row-inline">
      <div class="row-fields" style="display:flex;">
        <aui:input type="text" label="" name="phonesIndexes" id="phonesIndexes" helpMessage="Enter News Event Info " value="" >
<aui:validator name="required"/>
</aui:input>
      </div>
    </div>
  </div>
</aui:form>

<aui:script>

AUI().use('liferay-auto-fields',function(A) {
 new Liferay.AutoFields(
       {
           contentBox: '#phone-fields',
           fieldIndexes: '<portlet:namespace />phonesIndexes'
       }
   ).render();
   });
</aui:script>

#Action Phase :
================
 public void getAutoFieldsData(ActionRequest actionRequest,ActionResponse response)
                                    throws Exception {
                     
String phonesIndexesString = actionRequest.getParameter("phonesIndexes");
System.out.println("=============phonesIndexesString=="+phonesIndexesString);
int[] phonesIndexes = StringUtil.split(phonesIndexesString, 0);
for (int phonesIndex : phonesIndexes) {
String number = ParamUtil.getString(actionRequest, "phoneNumber" + phonesIndex);
System.out.println("=============phoneNumber=="+number);
int typeId = ParamUtil.getInteger(actionRequest, "phoneTypeId" + phonesIndex);
System.out.println("=============typeId=="+typeId);
}
}

2 comments:

  1. Very informative post.This is immense in turn precise here. Thank you for posting them. Great piece of writing given that much approaching into the part.These types of articles are really ready to lend a hand for the mankind and one who are mysterious with these. Professional resume writing service is the biggest system of ensured professional resume authors. Amid the procedure, you will work one-on-one with a guaranteed, experienced professional until you have a resume you are fulfilled by.

    ReplyDelete
  2. how can we get the liferay auto field value in javascript?

    My requirement is that I have resource request to save my data. so how can I get all the dynamic parameter value in javascript?

    ReplyDelete