Forums de discussion

Pass values while typing

Federico Basanese, modifié il y a 8 années.

Pass values while typing

New Member Envoyer: 1 Date d'inscription: 27/04/16 Publications récentes
Hi

I have an <aui:input> textfield that needs to autocomplete using values found on the Database. I 've already developed the query as finder in the service.xml , now i need to pass what i'm typing in the textfield to the serveResource method. How can i do that?

Thank you
thumbnail
David H Nebinger, modifié il y a 8 années.

RE: Pass values while typing

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
Welcome!

Usually when I'm looking for an example of how to do something, I use the portal source and find an example.

Also google can be a great tool, points to a long discussion here that may give you some ideas of how to proceed.
thumbnail
Andrew Jardine, modifié il y a 8 années.

RE: Pass values while typing

Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
There is also a lot of content of aui autocomplete -- check out this thread for example: https://web.liferay.com/community/forums/-/message_boards/message/32046351
thumbnail
David H Nebinger, modifié il y a 8 années.

RE: Pass values while typing

Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
Hey, Andrew, that's actually the link I posted emoticon
thumbnail
Andrew Jardine, modifié il y a 8 années.

RE: Pass values while typing

Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
LOL -- burn. Here -- let me try a different one emoticon

https://web.liferay.com/web/meera.success/blog/-/blogs/liferay-auto-complete-list-with-ajax
vikas ch, modifié il y a 7 années.

RE: Pass values while typing

New Member Publications: 18 Date d'inscription: 17/07/14 Publications récentes
Hello Fed,

I would suggest you can either use AUI or JQuery for this requirement.First you need to have a on keyup event and call an resource URL (ie: AJAX ) and pass the data from input field to the ajax and call your finder return list or object depending upon you requirement loop that list and form an JSONObject and put that JSONObject inside an JSONArray and use PrintWriter to return it back to the AJAX call and use either JQuery autocomplete or AUI and pass the corresponding JSONArray passing the input id the autocomplete list would render

Please share your code if you need further help.
thumbnail
Andrew Jardine, modifié il y a 7 années.

RE: Pass values while typing

Liferay Legend Publications: 2416 Date d'inscription: 22/12/10 Publications récentes
Hey Vikas,

I thought the PrintWriter class was used for format responses? I've never used it in a serveResource method before -- can you show me an example of how you use it? Normally I just do something like this

    @Override
    public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException, PortletException {
       
        String result = StringPool.BLANK;
    
		// execute logic to get your list of values and set "string" to result
       
        resourceResponse.getPortletOutputStream().write(result.getBytes());
        resourceResponse.getPortletOutputStream().flush();
    }
vikas ch, modifié il y a 7 années.

RE: Pass values while typing

New Member Publications: 18 Date d'inscription: 17/07/14 Publications récentes
Hey Andrew, I generally use it like the below mentioned code btw you have showed me your code thanks learnt a new way emoticon


               PrintWriter writer = null;
		try {
			writer = resourceResponse.getWriter();
			writer.println(jsonArray);
		} catch (IOException e) {
			_log.error(e);
		}