Fórum

Auto complete keypress value

saritha reddy, modificado 10 Anos atrás.

Auto complete keypress value

Junior Member Postagens: 95 Data de Entrada: 27/01/14 Postagens Recentes
Hi
So far I did auto complete, Its working fine upto getting the values from the method, But I want to submit and get the results according to which I selected.

Please Can any one assist me.

My code is here..........

private void getSchools(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, PortletException {

		  JSONArray usersJSONArray = JSONFactoryUtil.createJSONArray();
		  ThemeDisplay themeDisplay = (ThemeDisplay)resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);
		  JSONObject userJSON=null;
		  
		  try {
			  List<south_africa_schools> schoolsList =south_africa_schoolsLocalServiceUtil.getsouth_africa_schoolses(0, south_africa_schoolsLocalServiceUtil.getsouth_africa_schoolsesCount());
			  
			
			  System.out.println("schools length :"+ schoolsList.size());
		   for(south_africa_schools school:schoolsList){
			   userJSON=JSONFactoryUtil.createJSONObject();
			   userJSON.put("natEmis",school.getNatEmis());
			   userJSON.put("province",school.getInstitution());
//			   userJSON.put("firstName",user.getFirstName());
			   usersJSONArray.put(userJSON);
		   }
		  } catch (Exception e) {
			  
		  }
		  PrintWriter out=resourceResponse.getWriter();
	     out.println(usersJSONArray.toString());
		}</south_africa_schools>




 &lt;%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%&gt;
&lt;%@page import="javax.portlet.ActionRequest"%&gt;
&lt;%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %&gt;

<portlet:defineobjects />

&lt;%@page import="com.liferay.portal.kernel.util.Constants"%&gt;
&lt;%@ include file="init.jsp" %&gt;
<portlet:resourceurl var="getSchools">
   <portlet:param name="<%=Constants.CMD%>" value="get_schools" />
 </portlet:resourceurl>

<portlet:renderurl var="submitUrl" windowstate="<%=LiferayWindowState.EXCLUSIVE.toString()%>">
<portlet:param name="mvcPath" value="/html/autocompleteschools/School.jsp" />
</portlet:renderurl>

<aui:form method="post" action="<%=submitUrl%>">
  <aui:input id="schlName" name="schlName" label="Search Institution" helpMessage="Type User Institution in Input Box" styleid="schlName" />
  <input type="hidden" id="schlName" name="schlName">
  <aui:column>
			<aui:button type="submit" value="Search"></aui:button>
		</aui:column>
		
 
  </aui:form>
<aui:script>
AUI().use('autocomplete-list','aui-base','aui-io-request','autocomplete-filters','autocomplete-highlighters',function (A) {
A.io.request('&lt;%=getSchools%&gt;',{
	  		dataType: 'json',
	  		method: 'GET',
	  		on: {
	   			success: function() {
	     			//continents=this.get('responseData');
	     			//alert(continents[0].name);
	     			new A.AutoCompleteList(
							{
							allowBrowserAutocomplete: 'true',
							activateFirstItem: 'true',
							inputNode: '#<portlet:namespace />schlName',
							resultTextLocator: 'province',
							resultHighlighter:['phraseMatch'],
                            resultFilters:['phraseMatch'],
							render: 'true',
							source:this.get('responseData'),
							});
	     			
	    		}
	    		}
			});
			

});

</aui:script>