To do this job we will use ajax call to update content on portlet. Post what you learn 3 ways to use serve resource in portal. To make it little complex i have used a java class with a. Aui ajax call in liferay portlet tech blog liferay mvc portlet. I had a difficult time finding good examples working with the jquery portlets, so i created by own. The examples used in this tutorial are available on github. You can refer this link to know more about serve resource phase. Try to drag the boxes back and forth to the left and right. A jquery ui widget which allows you to present entry points or windows into your data that can be served up from a server action or from static html similar to a portlet in portal technology.
Sample jsp portlet for ajax using jquery regular member posts. Download liferay aui auto complete list with ajax from. This five day training class teaches students websphere portal development using jsr 286 portlet api. The data can best be seen in a browser debugger like firebug or a network monitor that shows the response body.
Once portlet successfully deployed drag the portlet in any desired page. Portlet are responsible for producing small portion of whole page. Following figure shows an example of a sample jsr168 portlet that made an asynchronous call with actionurl, causing the entire portal page to be embedded in the portlet window as a part of ajax response. Based on the portlet example, here is source code that demonstrates the following features. Developing portlets using jsf, ajax, and seam part 1 of 3.
You will often need to use ajax calls to get data from the client side. To enable this feature set the asynccontent property on a portlet. Before seeing how to use ajax in liferay portlet, you need to understand portlet namespace. Portlet factory and ajax overview definitions of ajax ajax stands for asynchronous javascript and xml ajax is not a new programming language, but a new way to use existing standards and mechanisms with ajax you can create better, faster, and more userfriendly web applications.
It is therefore allowed for the portlet to return binary content. Key features all required code will be automatically generated for you. The serveresource method can also be used to implement ajax use cases by. I have done same in brand new portlet its working i think some other script or other code may effect you aui ajax call download following portlet and have a look into source code. The class also covers javaserver faces based portal site development and using dojo and ajax with portlets. Hi im trying to set the portlet preferences portletheight through an ajax call. Mxff xxxf rs kbw rvy book catalog portlet example kccb rvrkm re notiyf users. Many times you need to make ajax call to update portlet content. Virtually any type of information can be held in a portlet with help of jquerys builtin ajax support. Ajax is a broad term, lets first start by identifying the things that just work when mixing ajax and wsrp. Learn how to use ajax in liferay portlet with alloyui and jquery. Developing portlets using jsf, ajax, and seam part 3 of 3. Liferay client side portlet communication using ajax roufid. How to pass data from page to portlet class through ajax call.
Within the serveresource method, i then proceed to update my portlet preference as such. Its a long time but i am just describing here with code snippets all you can do with resource method. The calculation is done in the server side and the result is displayed without a page refresh all using ajax call. How to download a file from ajax request in liferay. If the character encoding has already been set by either the portlet container, setcontenttypejava. Content auto update using jquery ajax in liferay plugin portle. I was trying this by creating a simple portlet with serveresourse method.
Ajax in liferay portlet using jquery and alloyui roufid. Set the datatype to text in ajax and does the good mime type before to send the generated file to clientits make the excel file download to be interpreted by the browser as a real excel file. Quick conversion to springmvc portlets isos technology. Liferay serveresource and alloy auiiorequest module made ajax easy to implement in liferay portlet. Although, this was a simple example, fundamentally, as far as asynchronous call processing is concerned, most scenarios are likely to be very similar. Contribute to asotogliferay angularjsexamples development by creating an account on github. In this portlet i have added three links which on click send a request to get user information and display it on the portal using ajax. The portlet programming model also provides events and public render parameters so that you can build larger composite applications out of your portlets and. Portlets provide a presentation layer to information systems. Backed by jquerys ajax libraries, each pane acts independently from other panes achieving a clear separation of concerns continue reading. All labs are done using rational application developer rad 9. Due to this behavior, you should call serveresource method in ajax. All labs are done using rational application developer rad 8. Part 1 part 2 part 3 in this threepart series, the articles describe new features available in the java portlet specification 2.
For that you have to submit the form using ajax via resourceurl. The example consists of a simple portlet with just a link. Jsr 168 and jsr 286 describes portlets as webbased components that enable integration between applications and portals and thus delivery of applications on portals. A portlet is a java technology based web component, managed by a portlet container, that processes requests and generates dynamic content. Jsr286 introduced resource serving and the same method can perform ajax requests as well. A form is displayed on the screen in which the client must fill two fields and submit it to perform the sum. Download portlet you can source or war file to deploy into liferay portal as your convenient. For example, static resources like jpg files packaged in the portlet war should. This article is taken from the book portlets in action from manning publications.
Portlet namespace is a unique value generated and associated to each portlet by the portal. First, wlp comes out of the box with a few built in ajax features. I just took user table example so that when user type anything in input box i just search user. If you have basic knowledge of ajax and you want to learn how ajax call happens by alloy a. After completion of serveresource method, liferay portal will send the output of serveresource method directly to client. A button that says download on the app store, and if clicked it.
The article introducing java portlet specifications. How to download a file from ajax request in liferay serveresource. While it is impossible to examine all conceivable uses of ajax and websphere portal in this tutorial, it was our intention to whet your appetite to learn, and to apply this exciting technology into your future application development toolkit. But i am not sure how to hit the resourseurl from a standalone java class. Rss opens new window jay trivedi, modified 6 years ago. Ajaxing portlets portlets in action livebook manning. Its part of a threepart series that creates a portlet example using the spring 3.
The resourceresponse defines an object to assist a portlet for rendering a resource the difference between the renderresponse is that for the resourceresponse the output of this response is delivered directly to the client without any additional markup added by the portal. Portlets can be sorted into various positions to suit the visitors personal preference. Because of this reason, making ajax call in portlet is slightly different than normal javaj2ee application. Ibm websphere portal javascript api sample portlets.
Before use this portlet please read entire article and use it. Upon selecting, an ajax request is sent to portlet. The method serveresource of the mvcportlet provides data like string. This is the first in a series of 3 articles which will range from basic jsf portlet and portal knowledge through to advanced usage of ajax and seam in a portlet environment. At the end of this article you will be able to know how a. This will invoke serveresource method of portlet which sends a text message containing major cities part of selected country. You can make aui ajax call from jsp to send request to portlet and show the result on page. Sets the character encoding mime charset of the response being sent to the client, for example, to utf8. Download the sample code download consists of a readytodeploy portlet application as web archive war, containing two portlets. Within the serveresource method, i then proceed to update my portlet preference. However, the dynamic nature and rich content of the portlet user interface can be dramatically enhanced by adopting the latest dhtmlajax libraries. The sample shows how to benefit from client side portlet preference handling, background requests using the jsr 286 resource request. This portlet is to help users who want to see ajax working in a liferay portlet using jquery. Liferay ajax server side validations liferay savvy.
There are three ways you can use resource method from your portlet. The portlet is just diplaying a jsp for the ajax lab. The doview method is displayed below as an example of what you should see. This portlet displays a dropdown list to select country. Part 1 provides an overview of the java portlet specifications and explains in detail one of the main features introduced in jsr 286. Because of this reason, making ajax call in portlet is. Previously in liferay 6 handler method was used to handle ajax in the portlet controller. Learn all about the second version of the java portlet specification jsr 286.
Write below code in serveresource method to download the file. Im trying to pass a value in an ajax get request to my portlet class, but i cant quite figure out a way to access such variables value in the class. Hi all, how to download a file from portlet using a standalone java class. Clicking on the link on the portlet will cause an ajax request to target a data api implemented in the jsf portlet.
Either you dont send file at all or ajax is not downloading it. In part 1 and part 2 of this series i explained what the portlet bridge is, how you can install and use it in a basic jsf and richfacesajax based portlet, and the key differences in the portal. A standalone java class to hit this resourseurl to download a file. Its seems ajax jquery complains xml data download but its not accordingly with excel data format. This document and attached sample gives an implementation example of an ajaxenriched portlet application to be used with websphere portal 6. The heart of a portal is a portlet container, and as a servlet container is to servlets, so is a portlet container is to portlets. Ive opted to use the serveresource method of the portlet. The jsr 286 api is a major revision of the portlet specification and contains significant improvements. Content auto update using aui ajax in liferay plugin portlet. Im trying to set the portlet preferences through an ajax call. The same example as alloyui will be taken to perform a form submission using jquery. String with the string of texthtml and calling this method with the string of.
12 285 1446 879 456 459 923 402 1563 265 974 178 51 1576 1401 1153 445 139 637 757 629 559 179 856 904 486 1559 436 439 1374 1276 474 503 552 1474 1397 918 1219 273 1118 1109 655 345