Foros de discusión

RE: Display and Refresh Values from the DB

thumbnail
David H Nebinger, modificado hace 11 años.

RE: Display and Refresh Values from the DB

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Oops, didn't see this was in the AUI thread, sorry.

Actually I have been thinking about this too. I currently have a timer in place using window.setInterval(), but I'm digging into the AUI code to see if there is a corresponding AUI way to do it.

In the method passed to setInterval(), I'm just calling Liferay.fire() to kick off an event that will trace through to my Vaadin backend code, but I'm betting you could at least trigger the ajax call to the back end either to a service facade that calls XxxLocalServiceUtil or if you have remote services enabled you can call it directly.

Note that if the database is being changed directly, you're going to want to disable caching at the entity level so the service doesn't return stale data.
thumbnail
David H Nebinger, modificado hace 11 años.

RE: Display and Refresh Values from the DB

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Liferay.fire() and Liferay.on() are just browser-side IPC mechanisms. With Vaadin, however, the browser side IPC notification gets automagically handled as a server side event (pretty cool, IMHO).

But I don't think this will help w/ your AJAX-based issue. I'd first solve the AJAX request/response process and, once you have that going, add in the timed refresh.
thumbnail
Hitoshi Ozawa, modificado hace 11 años.

RE: Display and Refresh Values from the DB

Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientes
If you're going to need near realtime values, saving values into database tables and **LocalServiceUtil may not be a good option. Better to save values in beans to write you own service interface to retrieve values.
Mohamed Rizwanuzaman, modificado hace 11 años.

RE: Display and Refresh Values from the DB

New Member Mensajes: 20 Fecha de incorporación: 17/12/09 Mensajes recientes
Hi Eric,
Instead of using action / render method, You can use serveResource method for Ajax call using

<portlet:resourceURL var="ajaxUrl"/>

and you can get the response in in success function of ajax call

 A.io.request('&lt;%=renderResponse.encodeURL(ajaxUrl.toString())%&gt;', {
	 	 method: 'post',
	 	 dataType: 'json',
	 	 data: {
	    	 groupId: groupId
	   		},
	 	 on: {  
	 	 	success: function() {
	 	 	container.empty()
		     	
	     		var url =this.get('responseData').userPhotoUrl ;
	               var title= this.get('responseData').userFullname;
	     		var dispUrl = this.get('responseData').userdisplayUrl;
				A.Node.create("<a href="&quot;+dispUrl+&quot;"><img class="picture" src="&quot;+url+&quot;" title="&quot;+title+&quot;"></a>").appendTo(container);
			
	   		  }
	       }
	  });

In action class

	public void serveResource(ResourceRequest resourceRequest,
			ResourceResponse resourceResponse) throws IOException,
			PortletException {
             //logic for getting thevalue from db using XXXLocalServiceUtil.java
}


after getting the response back you can replace the div to show the latest content from the DB.

Regards,
Rizwan