Fórum

Need help in using Liferay.AutoFields JS function

thumbnail
Srikanth Reddy Sanivarapu, modificado 12 Anos atrás.

Need help in using Liferay.AutoFields JS function

Regular Member Postagens: 203 Data de Entrada: 15/11/08 Postagens Recentes
Hi Team,

I am using the below code for Auto fields generation which is from Liferay and which I have taken from additional_email_addresses.jsp from the enterprise_admin folder.
But when I submit the form, I am not able to access fieldIndexes values in processAction() method. below is the code that I used.
<portlet:defineObjects />

<form action="<portlet:actionURL />" method="post">
<fieldset class="block-labels">

<div class="lfr-form-row">
<div class="row-fields">

<input type="text" value="" id="sss" name="sss"/>
</div>
</div>

</fieldset>
<input type="submit"/>

<script type="text/javascript">
jQuery(
function () {
new Liferay.AutoFields(
{
container: 'fieldset',
baseRows: 'fieldset .lfr-form-row',
fieldIndexes: '<portlet:namespace />emailAddressesIndexes'
}
);
}
);
</script>
</form>

and in processAction() method :

public void processAction(
ActionRequest actionRequest, ActionResponse actionResponse)
throws IOException, PortletException {

System.out.println("---->" + actionRequest.getParameter("emailAddressesIndexes"));
}

Is there any mistake that I am doing? or my assumption itself is not correct? Any help is really helpful. Thanks.

Regards,
Srik
thumbnail
Marcus Andrade Peixoto, modificado 12 Anos atrás.

RE: Need help in using Liferay.AutoFields JS function

New Member Postagens: 5 Data de Entrada: 15/12/07 Postagens Recentes
In your form you must have this snippet (from address.jsp):

&lt;%
String className = (String)request.getAttribute("addresses.className");
long classPK = (Long)request.getAttribute("addresses.classPK");

List
addresses = Collections.EMPTY_LIST; int[] addressesIndexes = null; String addressesIndexesParam = ParamUtil.getString(request, "addressesIndexes"); if (Validator.isNotNull(addressesIndexesParam)) { addresses = new ArrayList<address>(); addressesIndexes = StringUtil.split(addressesIndexesParam, 0); for (int addressesIndex : addressesIndexes) { addresses.add(new AddressImpl()); } } else { if (classPK &gt; 0) { addresses = AddressServiceUtil.getAddresses(className, classPK); addressesIndexes = new int[addresses.size()]; for (int i = 0; i &lt; addresses.size() ; i++) { addressesIndexes[i] = i; } } if (addresses.isEmpty()) { addresses = new ArrayList<address>(); addresses.add(new AddressImpl()); addressesIndexes = new int[] {0}; } if (addressesIndexes == null) { addressesIndexes = new int[0]; } } %&gt; </address></address>


and you must define the input for *indexes:

<aui:input name="addressesIndexes" type="hidden" value="<%= StringUtil.merge(addressesIndexes) %>" />


Finally, you use this code in your processAction method to collect the data:

int[] emailAddressesIndexes = StringUtil.split(ParamUtil.getString(actionRequest, "emailAddressesIndexes"), 0);