text;
stringlengths
5
32.6k
middle eastern languages such as hebrew and arabic are written right-to-left many sites that use rtl languages are multilingual, requiring both rtl and left-to-right ltr content. modern browsers support language and adapt and align page content automatically. elements that are absolutely positioned on the page by a style sheet these elements aren't automatically aligned by the browser. your style sheets to handle such elements. designed for ltr languages, the typical challenge is to create alternative versions of the css for rtl languages. thankfully, liferay's right to left language support app automatically adapts your site's content for rtl languages. the app is available on the liferay and deploy the app as described in the leveraging the liferay marketplace chapter of using liferay portal as a before-and-after example, the figure below shows a page displayed in figure 1 here is a site displaying english content left-to-right compare it to the following figure of a page displayed in hebrew, an rtl figure 2 here is a site displaying hebrew content right-to-left using right to left language support the right to left language support rtl support app does the heavy lifting of rendering the rtl content appropriately! note rtl support has been integrated into liferay portal 6.2 ee with portal-50-6210 or higher and liferay portal 6.2 ce ga5 or later. portal will contain rtl support without further configuration, and there is no further need to deploy this standalone app now that you've seen liferay portal and its apps rendered using rtl support, have you wondered how you might leverage rtl support in your custom plugins? you'll learn how to use rtl support with your plugins next you can use rtl support with any plugin type, though theme plugins are the most the following steps focus on using rtl support in a custom theme, but they also mention what's needed to make similar changes to support using rtl support in the other plugin types step 1 deploy the right to left language support app to your application server if upon initial deployment you don't notice any changes when switching to an rtl language, reload the page to force a clean cache note since dynamic generation of css from sass is not yet supported in the context of the rtl support app, the hook loads the current theme's merged css files, disregarding whether is commonly done while debugging for development now that you have deployed the rtl language support app, restart your step 2 extract the contents of the liferay rtl hook web application copy the url and its dependencies, url, url, url and url, from your rtl hook web app's web-inflib folder to the docrootweb-inflib folder of your plugin project step 3 modify your url and url for rtl language support you'll have to add some code to your url and url in order for the rtl language support app to work. here are some filtering elements that must be added to your url before the closing tag in your project's some targets must be added to your url so the rtl css files can be built the following snippet is example code showing targets for a theme if you're using the rtl language support app with another type of plugin project, rename the url dependency target reference appropriately for your plugin type step 4 deploy your plugin to the portal after you've deployed your plugin, you'll notice that ant echoes generated rtl cache for... messages that mention the cache that the rtl hook in your plugin's url folder, the hook creates url versions of each of your .css files you now know how to use the right to left language support app in your custom now it's time to learn how you can extend the right to left language support app's style with your own custom css for rtl languages note you may need to run ant deploy from the command line for the url folder and url files to be generated as you learned in the previous section, the right to left language support rtl support app automatically generates rtl versions of your css files by applying rules, such as changing margin-left to margin-right. to extend the generated css by defining your own custom styles for rtl you can achieve this by following the steps below step 1 create a css file to extend the original and make your edits you'll need to create a css file with the suffix rtl in the same location as a css file that you want to extend. once you have made the rtl version of the css you want to extend, edit the rtl file, adding only your custom styles for rtl languages step 2 deploy your plugin and test it after you have deployed your plugin, check its url folder to see that the generated url file not only contains the css from the original file, but also contains your custom css code at the end add the language portlet to a page and change the current language to an rtl language e.g., hebrew to see your custom rtl styles in this tutorial, you've learned how to adapt your plugin styles for rtl languages, and how to define custom styles for rtl languages. to adapt the portal andor your custom plugins to rtl languages, the rtl support app makes it easy to offer your users the ideal viewing experience as you can see, hooks are a useful way of modifying your portal. customizing jsps by extending the original;;
initially, the layout template's generated tpl files are empty, a fresh canvas on which you can design a page layout template. by the end of this tutorial, you'll be able to build a new layout template and explain how it works. in this tutorial, you'll learn the structure of a layout template and design your own custom layout template before diving into designing your own layout template, you may want to look at an existing one, like liferay's 1-2-1 columns layout ce page layout, to learn how a layout template works from a user perspective. it looks like, populated with some of liferay's portlets figure 1 the 1-2-1 columns layout ce page layout works nicely for spanning portlets accross a page's header and footer and for grouping portlets in the middle of the page the figure above shows a page that uses the 1-2-1 columns layout ce page the first row has one column that spans the width of the page. can hold as many portlets as you like. a breadcrumb portlet was added to this the second row has two columns this row's first column is designed so that it takes up twice as much width as the second column. the first column has a dictionary and quick note portlet stacked in it and the second column has a language and unit converter portlet stacked in it. bottom of the page, the layout's last row is similar to the first row in that it two portlets were added to this column a user statistics as you can see, layout templates give structure to a page by organizing portlets as users drag the portlets onto the different parts of the page's layout layout template you're probably wondering what the source code looks like for this layout like all liferay layout templates, it's specified in a single file here's the content of the 1-2-1 columns layout ce's tpl the tpl uses html tags to specify its rows and columns. columns layout ce page layout has an outter that contains everything. this template's three row s are child elements of the layout template. each row contains one or more column s. attributes in these elements that you'll learn to use as you construct your own page layout templates, next. remember that you can refer to existing page layout tpl code, like the tpl of 1-2-1 columns layout ce page layout, as you design your own layout templates you can follow these steps to design your own templates open your layout template project's.tpl file, found in your project's if you're adding a layout template to the project, create a new.tpl file in the docroot folder create a layout template in which to specify your entire layout you must specify class, id, and role attributes for the. you can assign an arbitrary name to the class, but you must specify idmain-content and rolemain attribute settings. class name my-layout, for example, could look like this within the layout template, specify a for each row of portlets your layout template supports. for example, if it supports only one row of portlets, add one within your layout template. two rows of portlets, add two s, and so on you must apply portlet-layout and row-fluid css classes to each of these within each row, specify one or more column s. supports only one column, add one column. each column column must have a unique css id attribute. convention to follow is to start each id with column-, followed by an integer representing where that column is sequentially located in the for example, you could idenity the first column as idcolumn-1, you could identiry the second column as idcolumn-2, each column must specify the portlet-column css class as a class in addition to that class, if a column is the first, the last, or the only column in a row, you must specify either the portlet-column-first, portlet-column-last, or portlet-column-only css note, that the css class values for a column the column elements in the 1-2-1 columns layout ce source above, provides a good example of specifying the various each column's class attribute must also specify a css class called layout template columns follow a 12 column grid system. width value of each spanwidth must be an integer value between 1 and the sum of all of the span width values of a row's columns must equal if a row only has one column, for example, that one column's span width the span12 css class name means that the column will take up the entire page width if a row has 12 columns, for example, each column must have a span width the point is that the span width values of a row's columns must compliment each other to equal 12 if you wanted a row with four columns of equal page width, for example, you'd divide the twelve grid columns available between them 12 4 3. so, you'd specify a span width value span3 for each of the four columns here's an example of a column, with class name column-4, that is for the last column of four equal width columns in a row you're getting the hang of specifying columns, right note liferay 6.2 themes use a fork of twitter bootstrap v2.3.2 called bootstrap affects liferay's layout templates as well as its themes. 6.2 layout templates use bootstrap's 12 column grid system finally, with each column..., you must include a velocity template directive to render each column's portlets. the column of a page, the directives of the layout template's columns renders for example, the directive for a layout's first column with id column-1 in a row that only has one column could use a directive like the url function takes two arguments. css column id and the second is a list of css classes. pass portlet-column-content in the second argument. first, last, or only column in a row, you also have to pass both portlet-column-content and portlet-column-content-firstlastonly in the second argument, separated by a space believe it or not, you've just created a layout template! it to your portal and apply it to your portal's pages if you want to see more examples of layout templates, check out the page layouts section of liferay marketplace or look at the source of liferay's layout templates available in the liferay portal ce's core layout template files are available in the note, to save time, you can copy an existing layout template and modify it to since you're now a master at designing layout templates, go out there and generate some positive feng shui with your eye-pleasing layout templates! embedding portlets in a layout template developing liferay layout template plugins with maven;;
a number of variables are available for you to use in your custom tpl files. your convenience, they're all listed in the table below now you have a better understanding of the variables available to you making themes configurable with settings creating a layout template project in the plugins sdk;;
the liferay mobile sdk lets you connect your android and ios apps to a liferay by accessing built-in portal services through liferay's prebuilt mobile sdk, your apps can access the out-of-the-box functionality in a but what if you want to call custom services that in this case, you need to build your own mobile sdk that can call these custom portlet services note that when you build a mobile sdk for a portlet, it contains only the classes needed to call that portlet's remote services. liferay's prebuilt mobile sdk in your app. it contains the framework required to construct remote service calls in general the liferay mobile sdk project contains a mobile sdk builder that generates a custom mobile sdk for the android and ios platforms. does this by generating client libraries that let your native mobile apps invoke think of the mobile sdk builder as a service builder on the client side to learn about service builder this tutorial covers how to build a custom mobile sdk for android and ios. you'll begin by making sure the remote services are configured for any custom for the mobile sdk builder to discover a portlet's remote services, the services must be available and accompanied by a web service deployment descriptor wsdd. for instructions on creating a portlet's remote services and building its wsdd, next, you'll download the liferay mobile sdk's source code to build a mobile sdk for your custom portlet's services, you need to have the liferay mobile sdk's source code this code also contains the mobile sdk builder. get this code by cloning the mobile sdk project via git, or by downloading it to clone the mobile sdk project with git, open a terminal and navigate to the directory on your machine in which you want to put the mobile since the mobile sdk changes frequently, you should check out the mobile sdk builder's latest stable release. to see the list of available stable releases. stable builder releases correspond to github tags that begin with builder and end with the builder version. builder version's first two digits indicate the compatible liferay portal for example, the builder-6.2.0.18 tag corresponds to version 6.2.0.18 of the liferay mobile sdk builder, which is compatible with liferay portal 6.2. to check out this tag in a new branch of the same name, you can use this alternatively, you can download the zip or tar.gz file listed under the builder now you're ready to build the mobile sdk! after you've downloaded the mobile sdk's source code, you must build the module in which you'll build your custom portlet's mobile sdk. comes with a command line wizard that helps you build this module. wizard, run the following command in the builder's root folder this starts the wizard with the most common properties it needs to generate code if you need more control over these properties, run the same the wizard should look similar to this screenshot. in square brackets with blue text figure 1 the mobile sdk builder's wizard lets you specify property values for building your module so what properties are available, and what do they do? can set the following properties during or after running createmodule. want or need to set these properties after running createmodule, you can do so the values in parentheses are the context context your portlet's web context. generating a mobile sdk for liferay portal's calendar portlet, which is generally deployed to the calendar-portlet context, then you should set the context value to calendar-portlet. if there are no services available at the specified context, you may have forgotten to generate your portlet's wsdd platforms platforms the platforms to build the mobile sdk for. default, you can generate code for android and ios android,ios server url url your liferay portal instance's url. services, the mobile sdk builder tries to connect to this instance at the filter filter specifies the portlet entities the mobile sdk can access. blank value specifies all portlet entity services. portlet's entities include calendarbooking and calendarresource. a mobile sdk for only the calendarbooking entity, set the filter's value to module version version the version number appended to your mobile sdk's the sections on packaging your mobile sdk package name packagename on android, this is the package your mobile sdk's classes are written to ios doesn't use packages. portal version is appended to the end of the package name. you're using liferay portal 6.2 and specify url as the package name, the mobile sdk builder appends v62 to the package name, yielding this prevents collisions between classes with the same name, which lets you use mobile sdks for more than one portal version you can use the portal version property to change the portal note that there's also a destination property that can only be set in the this property specifies the destination for the you won't generally need to change this after you set the properties you need, the mobile sdk builder generates your module in the folder modulesyourportletcontext now you can build your mobile sdk. to do this, navigate to your module and run by default, the builder writes the source files to androidsrcgenjava and iossource in your module's folder if you update your portlet's remote services on the server side and need to update your mobile sdk, simply run....gradlew generate again now you know how to create and regenerate a mobile sdk for your custom next, you'll finish by packaging your mobile sdk for to package your mobile sdk in a jar file for use in an android project, run the following command from your module's folder this packages your mobile sdk in the following file to call your portlet's remote services, you must first install this file in your to do so, copy the file into your android app's applibs note that you must also install liferay's prebuilt mobile sdk in your also note that if you regenerate your mobile sdk to include new functionality, you can update your module's version in its url file. example, if you added or changed a service method in the mobile sdk you initially built, you could update it's version by setting version1.1 in your to learn how to use the mobile sdk in your android app, to see the rest of the android mobile sdk documentation. mobile sdk to create custom screenlets in liferay screens. to see the liferay screens documentation for android to package your mobile sdk in a zip file for use in an ios project, run the to do so, simply unzip it and add its files to your xcode to learn how to use the mobile sdk in your ios app, to see the rest of the ios mobile sdk documentation. to see the liferay screens documentation for ios creating android apps that use the mobile sdk creating ios apps that use the mobile sdk android apps with liferay screens;;
the mobile sdk also allows sending requests in batch. efficient than sending separate requests. for example, suppose you want to delete ten blog entries in a site's blogs portlet at the same time. making a request for each deletion, you can create a batch of calls and send this tutorial shows you how to implement batch processing for your ios app. assumed that you already know how to invoke liferay services from your ios app. invoking liferay services in your ios app. objective-c is used in the code snippets that follow. making service calls in batch only requires two extra steps over making them one the rest of the steps are the same as making other service calls. a service object, and you still need to call its service methods. here's a code snippet from an app that deletes a blogs portlet's blog entries after the import, lrbatchsession is used with a liferay instance's url and a user's credentials to create a batch session. can alternatively pass a pre-existing session to the constructor. useful when you already have a session object and want to reuse the same next, the service calls are made as usual in this case, with asynchronous calls, these methods return nil finally, call batch invokeerror. containing the results for each service call the return type for batch calls is since there are three deleteentrywithentryid calls, the entries array contains three objects. the order of the results matches the if you want to make batch calls asynchronously, set the callback to the session now you know how to utilize batch processing to speed up your app's invoking liferay services in your ios app creating android apps that use liferay;;
"json web services are enabled on liferay portal by default. disable them, specify this portal property setting next, let's look at strict http methods all json web services are mapped to either get or post http methods. service method name starts with get, is or has, the service is assumed to be read-only and is bound to the get method; otherwise it's bound to post by default, liferay portal doesn't check http methods when invoking a service call; it works in non-strict http method mode, where services may be invoked if you need the strict mode, you can set it with this when using strict mode, you must use the correct http methods in calling service when strict http mode is enabled, you still might have need to disable http when strict http method mode is enabled, you can filter web service access based on http methods used by the services. for example, you can set the portal json web services to work in read-only mode by disabling http methods other than get. now all requests that use http methods from the list above are ignored next, we'll show you how to restrict public access to exposed json apis each service method knows if it can be executed by unauthenticated users and if a user has adequate permission for the chosen action. read-only methods are open to public access if you're concerned about security, you can further restrict public access to exposed json apis by explicitly stating which methods are public i.e., accessible to unauthenticated users. use the following property to specify your the property supports wildcards, so if you specify get,has,is on the right hand side of the symbol, all read-only json methods will be publicly all other json methods will be secured. exposed methods, you can leave the right side of the symbol empty; to enable access to all exposed methods, specify";;
even though liferay developed liferay screens for xamarin with great care, you may still run into some common issues. this tutorial lists tips and solutions for these issues, as well as answers to common questions about screens for before exploring specific issues, you should first make sure that you've installed the correct versions of visual studio and the mono.net framework. each screenlet's reference documentation available for it may also help to investigate the sample xamarin.android and xamarin.ios apps both are good examples of how to use screenlets, views if you get stuck at any point, you can post your question on our running clean in visual studio may not be enough. remove all the bin and obj folders that weren't removed by the clean, this error occurs when liferay screens for ios has a wrong module name in an you must solve this in xcode, removing the module name in the xib file's custom class assignment in interface builder the selector is already registered error in xamarin.ios this error occurs because one or more methods share the same name. this, the binding file must be updated. xamarin.ios crashes unexpectedly without any error messages in the console on mac os, do this via the console. in the app, you must click user reports and then look for note that there may be more than one log file the app doesn't call delegate methods in xamarin.ios when you implement the delegate methods in your view controller, make sure to annotate them with export.... you must also set the view controller to the screenlet instance's delegate property. view controller that implements login screenlet's delegate, for a better understanding of xamarin code and example apps, see this list to compare type mapping between platforms. you must write xamarin apps in c, which has some differences compared to native code delegate ios or listener android classes these classes are important because they listen for a screenlet's events. liferay screens for xamarin, screenlet delegates and listeners are prefixed with an i. for example, login screenlet's delegate in native code is loginscreenletdelegate, while in xamarin it's iloginscreenletdelegate. similarly, login screenlet's listener in native code is loginlistener, use a similar naming scheme when you define a classinterface pair where the class is a standard implementation to get or set a value in native code, you use its getter and setter methods. in liferay screens for xamarin, you should convert such methods to if you have only one of these methods, you can call the method c code is usually written in pascal case. case for protected instance fields or parameters protocols in swift are analogous to interfaces in c initializers in swift are analogous to constructors in c to learn more about language equivalents between swift and c, see to extend or implement a class or interface, java requires that you use the extends or implements keywords. to learn more about language equivalents between java and c, see the c for java developers cheat sheet no, but we strongly recommend it. if you wish, however, you can use xamarin studio or visual studio code instead what's the meaning of export... above delegate method names in short, this attribute makes properties and methods available in explains this attribute in detail preparing xamarin projects for liferay screens using screenlets in xamarin apps creating xamarin views and themes;;
"when developing ios projects with liferay screens, there are a few best practices that you should follow to ensure your code is as clean and bug-free as note that this tutorial doesn't cover swift coding conventions for contributing to the liferay screens project on github. using the naming conventions described here leads to consistency and a better understanding of the screens library. this makes working with your screenlets your screenlet folder's name should indicate your screenlet's functionality. login screenlet's folder is named loginscreenlet if you have multiple screenlets that operate on the same entity, you can place them inside a folder named for that entity. they're therefore in the screens library's naming screenlets properly is very important; they're the main focus of liferay your screenlet should be named with its principal action first, its screenlet class should also follow this pattern. principal action is to log users into a liferay instance. you should place view models in your screenlet's root folder and name them and is named forgotpasswordviewmodel you should place your screenlet's interactors in a folder named interactors in you should name each interactor with its action name your connectors with the same naming conventions as interactors, replacing precede connector with liferay. the connector commentaddliferayconnector adds comments to an asset in a liferay instance. webpage's title from any url would be called getwebsitetitleconnector place your screenlet's themes in a folder named themes in your screenlet's if you're creating a group of similarly styled themes for multiple screenlets, however, then you can place them in a separate themes folder outside of your screenlets' root folders. this is what the screens library does the default and flat7 folders each contain similarly styled themes for also note that each screenlet's theme is in its own folder. the folder themesdefaultauthforgotpasswordscreenlet. note that the auth folder is the screenlet's module. and themes in modules isn't required recall that a theme consists of an xib file and a view class. your screenlet, but with view instead of screenlet. also be suffixed with yourthemename. for example, the xib file and view class for forgot password screenlet's default theme are using constants instead of hard coded elements is a simple way to avoid bugs. constants reduce the likelihood that you'll make a typo when referring to common they also gather these elements in a single location. add an action to your screenlet, each screenlet action used as a restorationidentifier in the view class is defined as a constant in the screenlet class. createinteractor method then uses the constants to distinguish between the if you instead typed each action manually in both places, a typo could break your screenlet and would be difficult to track down. in one place via constants avoids this potentially maddening complication screenlet attributes, like those listed in each screenlet's are another good example of this. although you can set these directly in interface builder, it's better to set them via constants in a plist file. puts all your screenlets' attributes in a single location that is also subject for instructions on setting attributes in a plist file, see the configuring communication with liferay section of the tutorial on preparing ios projects for liferay screens to retrieve these values in your code, you can use the following liferayservercontext methods for example, the following code retrieves the galleryfolderid value and sets it to image gallery screenlet's folderid attribute when accessing variables that belong to other screenlet components, you should avoid those outside your current screenlet layer. decoupling between the layers, which tends to reduce bugs and simplify for an explanation of the layers in liferay screens, see for example, you shouldn't directly access view variables from an interactor. this interactor's start method gets a view instance and accesses its title instead, you should pass the variable to the interactor's initializer. interactor now contains its own title variable, set in its initializer the screenlet class's createinteractor method calls this initializer when creating an instance of the interactor. also note that the screenlet's view model is used to retrieve the view's title. supporting multiple themes in your screenlet, a view model serves as an abstraction layer for your view, which lets you use different themes with a screenlet there are, however, a few places where you can break this rule otherwise it wouldn't be possible for layers to interact the screenlet class's createinteractor method. method must access the view's computed properties the interactor's onsuccess closure in the screenlet class. retrieve the interactor's result object when using a connector, the interactor's completedconnector method. method, you must retrieve the connector's result object the screenlet class's view model references. screenlet to communicate with the view supporting multiple themes in your screenlet create and use a connector with your screenlet architecture of liferay screens for ios";;
"your ios app is no doubt pretty great, or at least off to a great start. want it to access liferay services. you must install the correct mobile sdks in your ios project to call the remote services you need in your app. install liferay's prebuilt mobile sdk. this is required for any app that to call your custom portlet's services, you also need to install the mobile sdk that you built for it. mobile sdk for your custom portlet, see the tutorial this tutorial shows you how to install liferay's prebuilt mobile sdk, and any to install liferay's prebuilt mobile sdk. you'll then learn how to install a mobile sdk manually, which is required for installing any custom built mobile now go forth and fear no remote service! using cocoapods is the simplest way to install liferay's prebuilt mobile sdk. the steps for doing so are shown here create a file called podfile in your project. run pod install from your project's directory. version of the liferay ios mobile sdk and creates a.xcworkspace file. cocoapods also downloads all the necessary dependencies and configures your note that you may have to run pod repo update before running pod install; this ensures you have the latest version of the cocoapods use the.xcworkspace file to open your project in xcode if you're importing dependencies as frameworks useframeworks! in your podfile, you need to import the lrmobilesdk module for more information on how cocoapods works, see their next, you'll learn how to install a mobile sdk manually you can also install mobile sdks manually. this is required if you built one for your custom portlet's services. you can also install install liferay's prebuilt mobile sdk manually if you don't want to use cocoapods to install liferay's prebuilt mobile sdk, first the latest version of the liferay ios mobile sdk zip file. own mobile sdk, find its zip file on your machine. unzip the file into your xcode project within xcode, right-click on your project and click note the v62 folder's name can change for in this example, the sdk is built for liferay 6.2 if you're manually installing liferay's prebuilt mobile sdk, it also requires add its source code to your project now you know how to manually install a mobile sdk in your ios apps each liferay mobile sdk is designed to work with a specific liferay portal the liferay mobile sdk version number reflects this. digits of each mobile sdk's version number correspond to the compatible liferay for example, a mobile sdk version 6.2. is compatible with liferay 6.2, while a mobile sdk version 7.0. is compatible with liferay 7.0. digits after the first two correspond to the internal liferay mobile sdk build the mobile sdk's service class names are also suffixed with the mobile sdk's this lets your app support several liferay versions. example, you can add mobile sdk versions 6.2.0.22 and 7.0.3 to the same the mobile sdk service classes supporting liferay portal versions 6.2 and 7.0 end in v62.m and v7.m, respectively. versions your app connects to, use the the liferay ios mobile sdk is compatible with ios versions 7.0 and up. versions may work, but compatibility is untested if you want to invoke remote web services for your custom portlet, then you need to generate its client libraries by building an ios mobile sdk yourself. building an sdk is covered in the tutorial once you build an sdk to a zip file, you can install it using the manual installation steps above make sure to use the zip file you built instead of note that because your custom built sdks contain only the client libraries for calling your custom portlet services, you must install them alongside liferay's prebuilt sdk. liferay's prebuilt sdk contains additional classes that are required to construct any remote service call creating android apps that use liferay";;
"once the appropriate mobile sdks are set up in your ios project, you can access and invoke liferay portal's services in your app. through the steps you must follow to invoke these services since some service calls require special treatment, this tutorial also shows you note that the code snippets in this tutorial are written in first, you'll learn about securing liferay portal's json web services in the the liferay mobile sdk calls liferay portal's json web services, which are the web services you call via the mobile sdk must remain enabled for those calls to work. it's possible, however, to disable the web services that you don't need to call. for instructions on this, see the tutorial portal configuration of json web services a session is a conversion state between the client and server, consisting of multiple requests and responses between the two. requests between your app and the mobile sdk. in most cases, sessions need to be created with user authentication. the imports and code required to create a the lrsession object is created with initializers specifying the liferay instance to connect to and the credentials of the user to authenticate. initwithserver parameter sets the url of the liferay instance you're in this case, the liferay instance is running on the ios emulator is also running on the same machine. next, the authentication parameter takes an lrbasicauthentication instance with the credentials of the user to authenticate. authentication method used by your liferay instance, you need to provide the user's email address, screen name, or user id to the initwithusername you also need to provide the user's password to the password using lrbasicauthentication tells the session to authenticate each service call with basic authentication. the mobile sdk also supports oauth authentication, as long as the oauth provider portlet is deployed to your to learn how to use oauth authentication with the mobile sdk, warning be careful when using administrator credentials on a production liferay instance, as you'll have permission to call any service. of course, the default administrator credentials should be disabled on a production liferay instance if you're building a sign in view for your app, you can use the lrsignin utility class to check if the credentials given by the user are valid the mobile sdk doesn't keep a persistent connection or session with the server. each request is sent with the user's credentials except when using oauth. however, the signin class provides a way to return user information after a you can persist credentials with lrcredentialstorage. username and password in the keychain after credentials are stored, you can retrieve them with alternatively, you can create an lrsession instance directly with next, you're shown how to create an unauthenticated session in the limited cases in some cases, it's possible to create an lrsession instance without user however, most liferay remote methods don't accept unauthenticated making a call with an unauthenticated session generates an authentication access required exception in most cases unauthenticated service calls only work if the remote method in the portal or your plugin has the annotation. hypothetical class fooserviceimpl and its method bar to make such a call, you need to use the constructor that accepts the server now that you have a session, you can use it to call liferay's first, you should determine the liferay services you need to call. the available portal and plugin services at be sure to replace in this url with your server's once you determine the services you need to call, add their imports. example, if you're building a blogs app, you can import lrblogsentryservice note that the liferay version v62 is used in the service class's name. corresponds to the liferay version it's compatible with. is used, which means this mobile sdk class is compatible with liferay 6.2. because service class names contain the liferay version they're compatible with, you can use several mobile sdks simultaneously to support different liferay once you have a session and have imported the service class, you're ready to this is done by creating a service object for the service you want to call, and then calling its service methods. creating a blogs app, you need to use lrblogsentryservice to get all the blogs this is demonstrated by the following code this fetches all blog entries from the guest site. note that many service methods require you can get the user's groups by calling service method return types can be void, nsstring, nsarray, nsdictionary, nsnumber, and bool this lrblogsentryservice call is a basic example of a synchronous service the method in a synchronous service call returns only after the request is there are some special cases in which service method arguments aren't in these cases, you should use lrjsonobjectwrapper. you must pass a dictionary containing the object's properties and their values. on the server side, your object is instantiated and setters for each property are called with the values from the dictionary there are some other cases in which service methods require interfaces or since it's impossible for the sdk to guess which implementation you want to use, you must initialize lrjsonobjectwrapper with the server looks for the class name in its classpath and instantiates the object it then calls setters, as in the previous example. orderbycomparator is a good example of this. on the server side, orderbycomparator is an abstract class. pass the name of a class that implements it. if the service you're calling accepts null for a comparator argument, pass you may want to set the ascending property for a comparator. of liferay 6.2, most liferay orderbycomparator implementations don't have a setter for this property and it isn't possible to set from the mobile sdk. future portal versions will address this. orderbycomparator that has a setter for ascending. for more examples, see the test case another non-primitive argument is servicecontext. attention because most liferay service methods require it. required to pass it to the sdk; you can pass nil instead. creates a servicecontext instance for you, using default values if you need to set properties for servicecontext, you can do so by adding them to a new nsdictionary and then passing it as the servicecontext argument some liferay services require binary argument types like nsdata or the mobile sdk converts nsdata instances to nsstring before hello datausingencodingnsutf8stringencoding becomes a json array such as the mobile sdk does this for you, so you don't have worry about it; you only need to pass the nsdata instance to the method however, you need to be careful when using such methods. allocating memory for the whole nsdata, which may cause memory issues if the other portal service methods require url.file as an argument. cases the mobile sdk requires lruploaddata instead. the first constructor accepts an nsdata argument, while the second accepts as you can see, you also need to pass the file's mime type and the length is the size in bytes of the content being sent. a multipart form request to the portal. on the server side, a file instance is created and sent to the service method you're calling it's also possible to monitor service calls that upload data to liferay. to listen for upload progress to create a progress bar, you can create a lrprogressdelegate delegate and set it to an lruploaddata object. onprogressbytes method is called for each byte chunk sent. bytes that were sent, the total number of bytes sent so far, and the total for more examples of this, see the test case creating android apps that use liferay";;
the main drawback of using synchronous requests from your app is that each request must terminate before another can begin. number of synchronous requests, performance suffers as a bottleneck forms while each one waits to be processed. to do so, you need to set a callback to the if you want to make synchronous requests again, you can set the with the following steps, this tutorial shows you how to implement asynchronous objective-c is used in the code snippets that follow. to configure asynchronous requests, first create a class that conforms to the when implementing this callback class, you need to implement its onfailure and onsuccess methods. determine what your app does when the request fails or succeeds. side exception or a connection error occurs during the request, the onfailure method is called with an nserror instance that contains information about the note that the onsuccess result parameter doesn't have a specific type. when deciding what to cast it to, you need to check the type in the service the example code here implements a callback class for an app that retrieves blog the service method for this call is getgroupentrieswithgroupid, which returns an nsarray instance. onsuccess method's result parameter is therefore cast to this type now you have a callback class that you can use with the session next, create an instance of this callback and set it to the session. haven't created a session yet, do so now. invoking liferay services in your ios app shows you how to create a session. now you're ready to set the callback to the for example, this is done here for blogsentriescallback now you're ready to make the service call last but certainly not least, make the service call. calling any other service create a service object from the session and use it this is also described in the tutorial invoking liferay services in your ios app. here, an example service call that gets all the blog entries from a site's blogs since the request is asynchronous, getgroupentrieswithgroupid immediately once the request finishes successfully, the onsuccess method of your callback is invoked with the results on the main ui thread now you know how to make asynchronous requests in your ios apps. there's another way to accomplish the same thing. instead of implementing a separate callback class, you can use an objective-c an example of this is shown here for an asynchronous call note that this includes all the code required to when using a block as a callback, take care not to also set an lrcallback blocks works the same way as described in the previous sections now you know two different ways to make asynchronous service requests in creating android apps that use liferay;;
a session is a conversation state between the client and server. consists of multiple requests and responses between the two. communication, the session must have the server ip address, and a user's login liferay screens uses a liferay session to access and query the json web services provided by liferay portal. when you log in using a liferay session, the portal returns the user's information name, email, user id, screens stores this information and the active liferay session in the sessioncontext class is very powerful and lets you use screens in many for example, you can use sessioncontext to request information with the json ws api provided by liferay. sessioncontext to create anonymous sessions, or to log in a user without this tutorial explains some common sessioncontext use cases, and and also describes the class's most important methods when working with liferay screens, you may wish to call the remote json web services provided by the liferay mobile sdk. every operation with the liferay mobile sdk needs a liferay session to provide the server address, user credentials, and any other required parameters. creates a session when a user successfully logs in, you can retrieve this session with the sessioncontext method createsessionfromcurrentsession. you can then use that session to make the mobile sdk service call. example shows this for calling the mobile sdk's bookmarksentryservice if you need to check first to see if a user has logged in, you can use now you know how to retrieve an existing session in your app. you're not using the login screenlet? there won't be an existing session to you can still use sessioncontext to create one manually. the next section shows you how to do this if you don't use the login screenlet, then sessioncontext doesn't have a in this case, you must create one manually. do this with the sessioncontext method createbasicsession. a username and password as parameters, and creates a session with those if you also need to access a user's information, you must manually call the user json web service, or call url. following code creates a session with createbasicsession and then uses setloggeduser to set the user in sessioncontext note that you can achieve the same thing by calling the interactor directly now you know how to create a session manually. how to implement auto-login, and save or restore a session although the login screenlet is awesome, your users may not want to enter their credentials every time they open your app. it's very common for apps to only to implement this in your app, see in short, you need to pass a storage type to the login screenlet, and then use exist, load the stored session from credentialsstorage with typical implementation of this now you know how to implement auto-login in your liferay screens apps. for more information on available sessioncontext methods, see the next, you'll learn how to implement relogin for cases where a user's credentials change on the server while they're logged in a session, whether created via login screenlet or auto-login, contains basic user data that verifies the user in the liferay instance. in the server, then your session is outdated, which may cause your app to behave also, if a user is deleted, deactivated, or otherwise changes their credentials in the server, the auto-login feature won't deny access because it doesn't perform server transactions it only retrieves an existing this isn't an optimal situation! for such scenarios, you can use the relogin feature. in a simple method that determines if the current session is still valid. session is still valid, the user's data is updated with the most recent data if the session isn't valid, the user is logged out and must then log in again to create a new session to use this feature, call the sessioncontext method relogin, with an object that implements the loginlistener interface as an argument this method handles success or failure via the listener's onloginsuccess and onloginfailure methods, respectively. note that this operation is done asynchronously in a background thread, so the listener is called in that thread. if you also want to perform any ui operations, you must do so in your ui thread. now you know how to implement relogin in your app. additional sessioncontext methods, and some more detail on the ones used in sessioncontext source code in github using screenlets in android apps;;
you can extend the functionality of the web page that the screenlet renders. this lets you tailor that page to your app's needs you'll get started by installing and configuring cordova. do this automatically, or manually. the automatic method is covered first follow these steps to automatically create an empty android project configured create the file url in the folder you want to create your in this file, add all the cordova plugins you want to use in for example, you can add plugins from cordova or github in the folder containing your url file, run screens-cli to this creates your project in the folder platformsandroid. you can open it with android studio to install and configure cordova manually, follow these steps the cordova getting started guide to install cordova, create a cordova project, and add the android platform install any cordova plugins you want to use in your app. the cordova plugin cordova-plugin-call-number you can use cordova plugin to view the currently installed plugins copy the following files and folders from your cordova project to your you should also review other files like url, resource some plugins add permissions or styles in such files that you may need to copy for those plugins to work correctly in your android now that you've installed and configured cordova in your android project, you're ready to use it with web screenlet. insert and configure web screenlet in your app when you set web screenlet's parameters via the calling the enablecordova method with a cordovalifecycleobserver cordovalifecycleobserver informs cordova about the activity you can create an instance of this observer by using its for example, this code creates a cordovalifecycleobserver object that it then uses with enablecordova when setting web screenlet's parameters override the following activity methods to call their corresponding note, however, that you may also need to invoke cordova from a javascript file, depending on what you're doing. the cordova plugin cordova-plugin-call-number to call a number, you must add a javascript file with the following code if you run the app containing this code and wait three seconds, the plugin activates and calls the number in the javascript file now you know how to use web screenlet with cordova rendering web pages in your android app;;
"when developing android projects with liferay screens, there are a few best practices that you should follow to ensure your code is as clean and bug-free as you should first make sure that you have the latest tools installed. you should use the latest android api level with the latest version of android although screens may work with eclipse adt or manual gradle builds, android studio is the preferred ide when updating an app or screenlet to a new version of liferay screens, make sure this article lists changes to screens that break functionality in prior in most cases, updating your code is relatively straightforward using the naming conventions described here leads to consistency and a better understanding of the screens library. this makes working with your screenlets also note that liferay screens follows for android, with tabs as separator. the configuration for idea, findbugs, pmd, and checkstyle is available in the project's source code your screenlet folder's name should indicate your screenlet's functionality. login screenlet's folder is named login if you have multiple screenlets that operate on the same entity, you can place them inside a folder named for that entity. they're therefore in the screens library's naming screenlets properly is very important; they're the main focus of liferay you should name your screenlet with its principal action first, its screenlet class should also follow this pattern. principal action is to log users into a installation. screenlet class is therefore loginscreenlet name your view models the same way you name screenlets, but substitute also, place your view models in a view folder in for example, login screenlet's view model is named place your screenlet's interactors in a folder named interactor in your name each interactor first with the object it operates on, followed by its action and the suffix interactor. also put each interactor in its own folder named after its action. each is in its own folder inside place views in a view folder in the screenlet's root folder. creating a view set, however, you can place its views in a separate viewsets folder outside your screenlets' root folders. this is what the screens library its material and westeros view sets. the material and westeros folders contain those view sets, respectively. also note that in each view, each screenlet's view class is in its own folder. for example, the view class for the folder viewsetsmaterialsrcmainjavacomliferaymobilescreensviewsetsmaterialauthforgotpassword. note that the auth folder in this path is the screenlet's module. your screenlets and views in modules isn't required. is in viewsetsmaterialsrcmainreslayout name a view's layout xml and view class after your screenlet, substituting view for screenlet where necessary. the layout's filename should also be for example, the xib file and view class for forgot password screenlet's material view are url and using constants instead of hard-coded elements is a simple way to avoid bugs. constants reduce the likelihood that you'll make a typo when referring to common they also gather these elements in a single location. ddl form screenlet's screenlet class defines the following constants for the user action names to ensure that the network or background operation isn't lost when the device for this to work, however, you must ensure that your interactor's request is stateless if an interactor needs some piece of information, you should pass it to the interactor via the start call and then attach it to the event. example of this in the sample add bookmark screenlet from the screenlet creation tutorial. the onuseraction method in the screenlet class addbookmarkscreenlet passes a bookmark's url and title from the view model to the interactor via the the start method calls the interactor's execute method in a background the execute method in add bookmark screenlet's interactor addbookmarkinteractor creates a basicevent object that contains the when accessing variables that belong to other screenlet components, you should avoid those outside your current screenlet layer. decoupling between the layers, which tends to reduce bugs and simplify for an explanation of the layers in liferay screens, see for example, don't directly access view variables from an interactor. pass data from a view model to the interactor via the interactor's start the example onuseraction method in the previous section illustrates liferay screens for android troubleshooting and faqs architecture of liferay screens for android";;
to reuse your screenlet in another app or distribute it, you can package it in a you can optionally share it with other developers via developers can then use your screenlet by adding its module as a project dependency in their apps. package and distribute screenlets by following these steps now get ready to package and distribute screenlets like a pro! android studio's create new module wizard can automatically create a module select android library in the more modules section, and click next. name your module and click next. the wizard's final step lets you add a new since your module doesn't need one, select blank activity and click android studio creates a new url file with an android library configuration and adds the new module to your url file if you prefer to create a new module manually, examine the url file after creating the module, import it into your project by here's an example configuration now that you have a module, you're ready to configure its dependencies next, you must configure your app to use the module. compile statement to your url file's dependencies your module must also specify dependencies for overriding existing screenlets this usually requires adding liferay screens and the view sets your screenlet currently uses to your url file's dependencies. to add liferay screens as a dependency, add to your url file's dependencies the following project compile statement now you're ready to share your screenlet with the world! to make your module available to anyone, you can upload your module to jcenter before doing so, you must configure your url file appropriately for those repositories. use the material or westeros view set's after entering your bintray api key, execute gradlew bintrayupload to upload your project to jcenter. screenlet as any other android dependency by specifying its repository, artifact, group id, and version in their gradle files. preparing android projects for liferay screens using screenlets in android apps;;
the liferay faces bridge component suite provides many portlet 2.0 uicomponent tags that are useful for jsf development. in this tutorial, you'll learn about if the var attribute is present, the portletresourceurl tag introduces an el variable that contains a url.actionurl, adequate for obtaining otherwise, the url is written to the response you've been introduced to a new liferay faces bridge uicomponent tag, and have can now implement it into your jsf portlet!;;
liferay screens supports push notifications in android apps. them, you must configure some apis and modify your app to consume andor this tutorial shows how to do all these things your first step is to create and configure a google project to use google cloud to configure the liferay push app to use the project's gcm api follow these steps to create and configure a google project to support cloud create a configuration file by clicking get a configuration file. screen that appears, set your app name and android package name, and then click continue to choose and configure services. copy and save the server api key and sender id values you're presented you'll need to use these values later as the push notifications api now that you've set up your google project, you can configure the liferay push app to use the project's gcm api. install the liferay push app from the in the portal's control panel, set the push notifications api key to the value of the server api key you generated in your google project. number of retries in the event that sending a notification fails figure 2 in the portal, you can configure the api key for the liferay push app to send notifications to your android apps your portal is now ready to send push notifications to your android apps! streamlines registering a device with the portal for receiving and sending push the steps for using the client are explained in detail but the main steps are demonstrated here in your android application's gradle build file, add a new dependency on the make sure your app's url file specifies the push notifications portlet as a required deployment context next, you can learn how to register listeners for push notifications first, register your device in gcm with the senderid you generated if you're using liferay screens to maintain a session, you can retrieve it and use it instead of creating a new one if you use these example lines of code, make sure to replace yourserver, youruser, yourpassword, and yoursenderid with your own values you can attach a listener to store the registration id or to process the notification sent to the activity using onpushnotification . also register a receiver and service to process the notification. project especially its pushactivity class as an example push notifications it's time to learn how to implement sending push notifications using the liferay push app, sending notifications to your app's users is you can specify the user ids along with the message content notification each time a user creates a new ddl record or updates an existing in your app's url file, you can add a listener for a class by property, set to a comma separated list of intended listener classes. now you know how to configure your android apps to receive push in this tutorial, you've configured your portal to accommodate push notifications, registered notification listeners, and implemented sending push notifications. preparing android projects for liferay screens using screenlets in android apps;;
interactors are screenlet components that implement server communication for a for example, the login screenlet's interactor calls the liferay mobile sdk service that authenticates a user to the portal. calls the liferay mobile sdk service that adds a bookmark to the bookmarks that's all fine and well, but what if you want to customize a screenlet's server what if you want to use a different back-end with a screenlet? you can implement a custom interactor for the screenlet. different interactor that makes its server call by using custom logic or network to do this, you must implement the current interactor's interface and then pass it to the screenlet you want to override. app's code, either in an inner class or a separate class in this tutorial, you'll see an example interactor that overrides the login screenlet to always log in the same user, without a password. note that this example implements the custom interactor in an inner class of an you must inherit the original interactor's call the interactor's listener. in your custom logic, you must call the in this example, you must call onloginfailure and onloginsuccess, depending on your custom logic's result return your interactor in the custom listener. setcustominteractorlistener to set a specific listener that expects an interactor created with actionname a string now you know how to implement custom interactors for android screenlets. the next example builds on this by showing you how to access non-liferay backends with a custom interactor custom interactors are also capable of communicating with non-liferay backends. the following example illustrates this by creating a custom interactor for the you can find this example's complete code baseremoteinteractor, the base class of all interactors, with addbookmarklistener as a type parameter. the base code for this new interactor is in this example, you must implement the code for accessing delicious and inserting a new bookmark with the delicious api. to pass the api your bookmark's url and description. notify your app of the results. you should use the eventbusutil class to use the event to let other classes listen for the the following code uses url to post the event, and the onevent method to notify the listener uses the custom bookmarkadded class to model the operation's results in the activity or fragment you're using the screenlet in, implement you must also reference your new custom interactor and connect it to the screenlet now you know how to create a custom interactor that can communicate this opens up even more possibilities for your apps architecture of liferay screens for android;;
articles as journalarticle entities. liferay screens provides several ways to render these entities in your apps the simplest way to display a journalarticle's html in your app is to use this screenlet is very powerful and supports several complex use cases to fit to display lists of web content articles. this tutorial shows you how to use both screenlets to display web content in your apps web content display screenlet's simplest use case is to render a simply provide the journalarticle's articleid in the screenlet xml, and the screenlet takes care of the rest including decorating itself with the css needed to render it in a small display. the following screenlet xml shows this to render the content exactly as it appears on your mobile site, however, you must provide the css inline or use a template. the html returned isn't aware of a liferay instance's global css you can also use a listener to modify the html, as explained in the in the default security policy, an android webview doesn't execute a page's you can enable such javascript execution by setting the javascriptenabled property via xml alternatively, you can set this property in your app's fragment or activity class that contains the screenlet you can also use the isjavascriptenabled method to check this property's as you can see, this is all straightforward. a common mistake is to use the default groupid instead of the one for the site that contains your journalarticle entities if you need to use a default groupid in the rest of your app, but render another site's html, you can set the web content display screenlet's groupid with the appgroupid attribute. you can alternatively use the setgroupid method in the activity or fragment code that uses the screenlet web content display screenlet can also use for example, your liferay instance may have a custom template specifically designed to display content on mobile devices to use a template, specify its id in the screenlet xml's templateid property since mobile devices have limited screen space, you must often display only the most important parts of a web content article. you can do this by using web content display screenlet to display only specific fields from a journalarticle's structure. the simplest way to do this is to specify the structure's id and a comma-delimited list of fields in the screenlet xml's structureid and labelfields attributes, respectively. you can also use your own layout to render the structure fields exactly how you to do this, your layout should inherit from webcontentstructureddisplayview and read the information parsed and stored in by displaying two structure fields with such a custom contains a complete example of this sets the custom layout's functionality layoutid attribute specifies the custom layout to use now you know how to use structured web content with web content display next, you'll learn how to display a list of web content articles in the preceding examples show you how to use web content display screenlet to display a single web content article's contents in your app. want to display a list of articles instead? web content list screenlet can retrieve the contents of a web content folder and display only the labels you want. content, so you can render each row with certain structure fields. to use a web content folder with web content list screenlet, specify the folder's id in the screenlet xml's folderid attribute. structure field for each article in the list, specify that field in the screenlet xml's labelfields attribute. you can also see an example of this in the test app's also note that several methods in help you render content from different locales. getlocalizedname receives a field's name and returns the value in the mobile such methods help you render a custom view without worrying about the underlying structure, xml parsing, or http calls to render a list of different assets in your app, including web content articles, you can use asset list screenlet. list of any assets from a liferay instance. can also access a web content article's structure fields, or use a custom layout using screenlets in android apps using views in android screenlets;;
many apps display a progress indicator while performing an operation. example, you've likely seen the spinners in ios apps that let you know the app is performing some kind of work. the ios human interface guidelines article on progress indicators you can display these in screenlets by using classes that conform the liferay screens includes two such classes shows a message with a spinner in the middle of the screen. shows this presenter by default shows the progress using the ios network activity indicator. this tutorial shows you how to use and create progress presenters, using code advanced version of the sample add bookmark screenlet first, you'll learn how to use progress presenters contains the default progress presenter functionality. than the default mbprogresshudpresenter, your view class must therefore in your view class, override the basescreenletview method createprogresspresenter to return an instance of the desired presenter. example, to use networkactivityindicatorpresenter in the sample add bookmark screenlet, you must override the createprogresspresenter method in addbookmarkviewdefault to return a networkactivityindicatorpresenter in your view class, override the basescreenletview property progressmessages to return the messages you want to use in the presenter. if the presenter doesn't display messages, then return an empty string. progressmessages property should return the messages as string progressmessages, where string is the screenlet's action name. progressmessages is a type alias representing a dictionary where the progress type is the key, and the actual the three possible progress types correspond to the screenlet action's status working, failure, or success. progressmessages property therefore lets the presenter display the appropriate message for the screenlet action's current status for example, the following code overrides the progressmessages property in add bookmark screenlet's view class addbookmarkviewdefault . screenlet action addbookmarkaction and gettitleaction , a message noprogressmessage is assigned to the screenlet operation's working since noprogressmessage is an alias for an empty string, this tells the presenter to display no message when the screenlet attempts to add note, however, that the presenter still displays to display a message, replace noprogressmessage with your message. example, the following code defines separate messages for working, now you know how to use progress presenters. creating your own progress presenter isn't as complicated as you might think. recall that a presenter in liferay screens is a class that conforms the you can create your presenter by conforming this protocol from scratch, or by extending one of screens's existing presenters that already conform this protocol mbprogresshudpresenter or networkactivityindicatorpresenter . most cases, extending mbprogresshudpresenter is sufficient add bookmark screenlet's addbookmarkprogresspresenter extends mbprogresshudpresenter to display a different progress indicator for the screenlet's get title action. use the following steps to create a progress presenter that extends from an existing presenter. extend mbprogresshudpresenter to add a progress indicator for the get title in your view's xib file, add the activity indicator you want to use. example, the xib file in add bookmark screenlet contains an ios uiactivityindicatorview over the get title button figure 1 the updated add bookmark screenlet's xib file contains a new activity indicator over the get title button in your view class, create an outlet for the xib's new activity indicator. for example, add bookmark screenlet's view class addbookmarkviewdefault contains an for the uiactivityindicatorview from the xib now you must create your presenter class. you'll do this here by extending an use the following steps to do this extend the existing presenter class you want to base your presenter on. presenter class must contain properties for your presenter's activity indicator and any other ui components. it must also contain an initializer extends mbprogresshudpresenter and contains properties for the get title button and uiactivityindicatorview. its initializer sets these properties implement your presenter's behavior by overriding the appropriate methods from the presenter class that you're extending. showhudinview and hidehudfromview methods. method hides the button and starts animating the activity indicator. overridden hidehudfromview method stops this animation and restores the now you can use your presenter the same way you would any architecture of liferay screens for ios;;
liferay screens typically receives entities from a liferay instance as stringanyobject, where string is the entity's attribute and anyobject although you can use these dictionary objects throughout your screenlet, it's often easier to create a model class that converts each into an object that represents the corresponding liferay entity. this is especially convenient for complex entities composed of many note that liferay screens already provides several model at this point, you might be saying, ugh! i have complex entities and screens doesn't provide a model class for them! i'm just going to give up and watch although we'd never come between you and football, creating and using your own model class is straightforward advanced version of the sample add bookmark screenlet as an example, this tutorial shows you how to create and use a model class in first, you'll create your model class your model class must contain all the code necessary to transform each stringanyobject that comes back from the server into a model object that represents the corresponding liferay entity. holding each stringanyobject, and initializer that sets this constant, and a public property for each attribute value for example, the sample add bookmark screenlet adds a bookmark to a liferay since the mobile sdk service method that adds the bookmark also returns it as stringanyobject, the screenlet can convert it into an object that represents bookmarks. this class extends nsobject and sets the stringanyobject to the attributes constant via the initializer. this class also defines computed properties that return the attribute values for each bookmark's name and url next, you'll put your model class to work now that your model class exists, you can use model objects anywhere your exactly where depends on what screenlet components for example, add bookmark screenlet's connector, interactor, delegate, and screenlet class all handle the screenlet's results. the steps here therefore show you how to use model objects in each of these note, however, that your screenlet may lack a connector or delegate variations on these steps are therefore noted create model objects where the string anyobject results originate. example, the string anyobject results in add bookmark screenlet therefore, this is where the screenlet creates the following code in the screenlet's connector addbookmarkliferayconnector does this. service call casts the results to string anyobject, calls the bookmark initializer with those results, and stores the resulting bookmark object to the public resultbookmarkinfo variable. note that this is only the code that makes the service call and creates the bookmark object. click here to see the complete addbookmarkliferayconnector class if your screenlet doesn't have connector, then your interactor's start method makes your server call and handles its results. process for creating a bookmark object from string anyobject is the handle your model objects in your screenlet's interactor. processes your screenlet's results, so it must also handle your model if your screenlet doesn't use a connector, then you already did this in your interactor's start method as mentioned at the end of the previous if your screenlet uses a connector, however, then this happens in your interactor's completedconnector method. completedconnector method in add bookmark screenlet's interactor addbookmarkinteractor retrieves the bookmark via the connector's this method then assigns the bookmark to the interactor's public resultbookmark variable. code that handles bookmark objects. click here to see the complete addbookmarkinteractor class if your screenlet uses a delegate, your delegate protocol must account for skip this step if you don't have a delegate. the delegate's first method does this via its get the model object from the interactor in your screenlet class's you can then use the model object however you for example, the url closure in add bookmark screenlet's screenlet class addbookmarkscreenlet retrieves the bookmark from the interactor's resultbookmark property. note that in this example, the closure is in the screenlet class's interactor method that adds a bookmark be sure to get your model object wherever the url closure is in your screenlet class. click here to see the complete addbookmarkscreenlet now you know how to create and use a model class in your screenlet architecture of liferay screens for ios;;
it's very common for mobile apps to display lists. lets you display asset lists and ddl lists in your ios app by using screens also includes list screenlets for displaying lists of other liferay entities like web content articles, images, and more. the screenlet reference documentation lists all the screenlets included with liferay screens. screenlet for the entity you want to display in a list, you must create your own a list screenlet can display any entity from a liferay instance. for example, you can create a list screenlet that displays standard liferay entities like user, or custom entities from custom liferay apps this tutorial uses code from the sample bookmark list screenlet to show you how to create your own list screenlet. this screenlet displays a list of bookmarks from liferay's bookmarks portlet. you can find this screenlet's complete code note that because this tutorial focuses on creating a list screenlet, it doesn't explain general screenlet concepts and components. therefore read the following tutorials this tutorial uses the following steps to show you how to create a list first though, you should understand how pagination works with list screenlets to ensure that users can scroll smoothly through large lists of items, list support for this is built into the list screenlet framework. you construct your list screenlet recall that a model class transforms each stringanyobject entity screens receives into a model object that represents the corresponding liferay entity. for instructions on creating your model class, see the tutorial creating and using your screenlet's model class. the example model class in that tutorial is identical to bookmark list next, you'll create your screenlet's theme recall that each screenlet needs a theme to serve as its ui. xib file to define the ui's components and layout. displays a list of entities, its xib file must contain a table view. steps to create your theme's xib file in xcode, create a new xib file and name it according to for example, the xib for bookmark list screenlet's default theme is in interface builder, drag and drop a view from the object library to the then add a table view to the view resize the table view to take up the entire view, and set the constraints the table view needs to maintain this size dynamically. the list fills the screenlet's ui regardless of the ios device's size or bookmark list screenlet's xib file uses a uitableview inside a parent view to show the list of bookmarks now you'll create your theme's view class. every theme needs a view class that since the xib file uses a uitableview to show a list of guestbooks, your view class must extend liferay screens provides this class to serve as the base class for list since baselisttableview provides most of the required functionality, extending it lets you focus on the parts of your view class that are unique to your screenlet. you must also configure the xib file to follow these steps to create your screenlet's view class and configure the xib create your theme's view class, and name it according to since the xib uses uitableview, your view class must extend for example, this is bookmark list screenlet's view now you must override the view class methods that fill the table cells' there are two methods for this, depending on the cell type normal cells the cells that show the entities. use uilabel, uiimage, or another ui component to show the entity. override the dofillloadedcell method to fill these cells. bookmark list screenlet's view class overrides dofillloadedcell to set each cell's textlabel to a bookmark's name progress cell the cell at the bottom of the list that indicates the list is loading the next page of items. override the dofillinprogresscell for example, bookmark list screenlet's view class overrides this method to set the cell's textlabel to the string return to the theme's xib in interface builder, and set the view class as the the parent view's custom class. for example, if you were doing this for bookmark list screenlet you'd select the table view's parent view, click the identity inspector, and enter bookmarklistviewdefault as the custom with the theme's xib still open in interface builder, set the parent view's to do this, select the parent view and click the connections inspector. in the outlets section, drag and drop from the tableview's circle icon it turns into a plus icon on mouseover to the new outlet then appears in the connections now that your theme is finished, you can create the connector recall that connectors make a server call. screenlet's connector class must extend the the connector class must also contain any properties it needs to make the server call, and an initializer that sets them. to support pagination, the initializer must also contain the following arguments, which you'll pass to the superclass for example, bookmark list screenlet must retrieve bookmarks from a bookmarks portlet folder in a specific site. the screenlet's connector class must therefore have properties for the groupid site id and folderid bookmarks folder id, and an initializer that sets them. superclass initializer with the startrow, endrow, and computerowcount next, if you want to validate any of your screenlet's properties, override the validatedata method as described in the tutorial on creating connectors. note that bookmark list screenlet only needs to validate the folderid lastly, you must override the following two methods in the connector class doaddpagerowsservicecall calls the liferay mobile sdk service method that the doaddpagerowsservicecall method's startrow and endrow arguments specify the page's first and last entities, make the service call as you would in any screenlet. example, the doaddpagerowsservicecall method in bookmarklistpageliferayconnector calls the service's getentrieswithgroupid method to retrieve a page of bookmarks from the folder specified by note that you don't need to do anything in the catch statement because the request is sent later, in batch. you'll receive the request's results elsewhere, once the doaddrowcountservicecall calls the liferay mobile sdk service method that retrieves the total number of entities. service call as you would in any screenlet. doaddrowcountservicecall in bookmarklistpageliferayconnector calls the service's getentriescountwithgroupid method to retrieve the total number of bookmarks in the folder specified by folderid now that you have your connector class, you're ready to create the interactor recall that interactors implement your screenlet's actions. loading entities is usually the only action a user can take. class of a list screenlet that implements fluent pagination must extend the your interactor class must also contain any properties the screenlet needs, and this initializer also needs arguments for the following properties, which it passes to the superclass initializer for example, bookmark list screenlet's interactor class contains the same groupid and folderid properties as the connector, and an initializer that this initializer also passes the screenlet, page, and computerowcount arguments to the superclass initializer the interactor class must also initiate the server request by instantiating the connector, and convert the results into model objects. createlistpageconnector method to create and return an instance of your this method must first get a reference to the screenlet via the when calling the connector's initializer, use url to convert the page number page to the page's you must also pass the initializer any other properties createlistpageconnector method does this to create a next, override the convertresult method to convert each stringanyobject the screenlet calls this method once for each entity convertresult method converts the stringanyobject result into a to do so, the interactor must override the cachekey method to return a cache key unique to your screenlet. bookmarklistpageloadinteractor's cachekey method returns a cache key that includes the screenlet's groupid and folderid settings next, you'll create your screenlet's delegate recall that a delegate is required if you want other classes to respond to your create your delegate by following the first step in the tutorial on adding a screenlet delegate. a list screenlet's delegate must also define a method for responding to a list for example, bookmark list screenlet's delegate needs the the bookmarklistscreenletdelegate protocol defines these methods next, you'll create the screenlet class now that your list screenlet's other components exist, you can create the a list screenlet's screenlet class must extend the and define the configurable properties the screenlet needs. these as ibinspectable properties. if you want to support offline mode, you should also add an offlinepolicy property bookmark list screenlet's screenlet class contains the ibinspectable properties groupid, folderid, and next, override the createpageloadinteractor method to create and return the if your screenlet supports offline mode, you should also use offlinepolicy to pass a cachestrategytype object to the interactor. example, the createpageloadinteractor method in bookmarklistscreenlet creates and returns a bookmarklistpageloadinteractor instance. also sets the interactor's cachestrategy property to a cachestrategytype object created with offlinepolicy now get a reference to your delegate. baselistscreenlet extends, already defines the delegate property for the every list screenlet therefore has this property, and any app developer using the screenlet can access it. to avoid casting this property to your delegate every time you use it, add a computed property to your screenlet for example, the following bookmarklistdelegate property in bookmarklistscreenlet casts the delegate property to next, override the baselistscreenlet methods that handle the screenlet's because these events correspond to the events your delegate methods handle, you'll call your delegate methods in these baselistscreenlet methods onloadpageresult called when the screenlet loads a page successfully. override this method to call your delegate's bookmarklistscreenlet's onloadpageresult method onloadpageerror called when the screenlet fails to load a page. this method to call your delegate's screenletonbookmarklisterror for example, here's bookmarklistscreenlet's onloadpageerror onselectedrow called when an item is selected in the list. method to call your delegate's screenletonbookmarkselected method. example, here's bookmarklistscreenlet's onselectedrow method your list screenlet, like any other screenlet, is a ready-to-use component that you can add to your storyboard. package it using the same steps you use to package a theme, and then contribute it to the liferay screens project or distribute it with supporting multiple themes in your screenlet create and use a connector with your screenlet creating and using your screenlet's model class using custom cells with list screenlets creating complex lists in your list screenlet architecture of liferay screens for ios;;
"in most list screenlets, including those that come with liferay screens, the default theme uses the default cells in in the list screenlet creation tutorial also instruct you to use these cells. you can, however, use custom cells to tailor the list to your needs. from a theme that uses uitableview's default cells. extending a list screenlet's default theme. create such an extended theme that contains a custom cell for your list as an example, this tutorial uses code from the sample bookmark list you can refer to this theme's finished code note that besides creating your custom cell, this tutorial follows the same for creating an extended theme. determine where to create your theme, and create your theme's xib and view class first, you'll create your theme's custom cell decide where to create your theme, first, create your custom cell's xib file and its companion the naming conventions in the best practices tutorial. after defining your cell's ui in the xib, create as many outlets and actions as you need in its companion class. also be sure to assign this class as the xib's custom class in interface builder. note that if you want to use different layouts for different rows, you must create an xib file and companion class for for example, the following screenshot shows the xib file url for bookmark list screenlet's custom cell. this cell must show a bookmark's name and url, so it contains two labels figure 1 the xib file for bookmark list screenlet's custom cell this xib's custom class, bookmarkcelldefaultcustom, contains an outlet for the bookmark variable also contains a didset observer that sets the bookmark's name and url to the respective label next, you'll create the rest of your now you're ready to create your theme's xib file and view class. by copying the parent theme's xib and making any changes you need. need to make any changes besides the file name and custom class name. example, the custom cell is the only difference between bookmark list screenlet's custom and default themes. therefore identical besides their name and custom class; the size and position of their ui components are the same now create your view class by extending the parent theme's view class. should also add a string constant to serve as the cell id. use this constant to register your custom cell. bookmark list screenlet's custom theme bookmarklistviewdefaultcustom extends the default theme's view class bookmarklistviewdefault and defines the string constant bookmarkcellid next, override the doregistercellnibs method to register your custom cell. this method, create a uinib instance for your cell and then register it with when registering the nib file, you must use the string constant you created earlier as the forcellreuseidentifier. doregistercellnibs method in bookmarklistviewdefault-custom also in your view class, override the dogetcellid method to return the cell id all you need to do in this method is return the string constant for example, the dogetcellid method in bookmarklistviewdefault-custom returns the bookmarkcellid constant now override the dofillloadedcell method to fill the cell with data. this method isn't called for in-progress cells; it's only called for cells that also note that this method's object argument contains the data you must cast this to your desired type and then set it to the for example, the dofillloadedcell method in bookmarklistviewdefault-custom casts the object argument to bookmark and then sets it to the cell's bookmark variable methods are also available in your view class. you can override any of them if you need to check first to make sure they're not already overridden. example, bookmarklistviewdefault-custom implements the following method to use a different cell height for each row when you finish, set your view class as your xib file's custom class now you know how to implement your own custom cells for creating complex lists in your list screenlet";;
to sort your list screenlet, you must point it to a comparator class in your a comparator class implements the logic that sorts your entities. can create your own comparator class or use those that already exist in your once your list is sorted, you can split it into sections. shows you how to sort your list screenlet with a comparator and create sections note to create a new comparator, you must create a class that extends the with your entity as a type argument. then you must override the methods that sorts bookmarks in liferay's bookmarks portlet by url first, you'll learn how to use a comparator to sort your list screenlet to use a comparator, you must set the list screenlet's obcclassname property to the comparator's fully qualified class name. when inserting the screenlet in an app, just as you would set any other for example, to set the sample bookmark list screenlet to sort its list of bookmarks by url, you must set obc class name to figure 1 to use a comparator, set the obc class name property in interface builder to the comparator's fully qualified class name note that although all list screenlets inherit the obcclassname the list screenlet must also make its service call with this property. to see which list screenlets included with liferay screens support the also, 's comparator classes can change between if you're using one of these comparators, make sure you specify the one that matches your version dividing lists into sections that contain like elements is common in ios apps. to do this in list screenlets, first use a comparator to sort the list by the criteria you'll use to create the sections. sectionforrowobject method in your list screenlet's interactor. called for each item in the list and should return the information necessary to the sample bookmark list screenlet's interactor overrides the sectionforrowobject method to group results by hostname note that this only produces predictable results when bookmark list screenlet is sorted by entryurlcomparator as detailed in the preceding section now you know how to sort and section your list using custom cells with list screenlets creating complex lists in your list screenlet;;
most list screenlets' themes use although uitableview is great for this, it's not so great for complex lists like grids or stacks. this tutorial shows you how to create such a theme, using the sample bookmark list screenlet's collection theme first, you'll create the list's cell you'll create your list's cell with used to create any list screenlet's cell. note, however, that how you perform these steps is a bit different define your cell's ui in a new xib file. because this cell is part of a theme that uses uicollectionview, you can shape it however you want. here's the url file for the cell in bookmark list screenlet's collection theme. displays the bookmark's url and the url's first letter figure 1 the xib file for the cell in bookmark list screenlet's custom view create your xib file's class by extending uicollectionviewcell. many outlets and actions as you need for your ui components and write the logic required for your cell's ui to function. bookmarkcelldefaultcollection is the xib file's class in bookmark list this class extends uicollectionviewcell and contains outlets for the url urllabel and the url's first letter the bookmark variable's didset observer sets the bookmark's name and url to the respective label. overridden prepareforreuse method resets the labels for reuse now that your cell exists, you can create the rest of your theme you'll create the rest of your theme with used to create any list screenlet's theme. like creating the cell, how you perform these steps is a bit different because your theme uses first, define your theme's ui in a new xib file. for bookmark list screenlet's custom theme contains a collection view instead of extending baselisttableview, this the baselistcollectionview class implements most of the code necessary to use uicollectionview in your screenlet. by extending it, you can focus on the code your view class should also contain a string constant you'll use this constant when you register your cell. for example, the view class in bookmark list screenlet's collection theme bookmarklistviewdefaultcollection extends baselistcollectionview and defines the string constant bookmarkcellid in interface builder, set this new class as the xib's custom class next, override the doregistercellnibs method to register the cell you created in this method, create a uinib instance for your cell and then register it with the uicollectionview instance collectionview inherited from baselistcollectionview. when registering the nib file, you must use the string constant you created earlier as the forcellreuseidentifier. example, here's the doregistercellnibs method in also in your view class, override the dogetcellid method to return the id you for example, the dogetcellid method in bookmarklistviewdefaultcollection returns the string constant next, override the dofillloadedcell method to fill the cell with data. method's object argument contains the data as anyobject. to your desired type and then set it to the appropriate cell variable. example, the dofillloadedcell method in bookmarklistviewdefaultcollection casts the object argument to bookmark and then sets it to the cell's the layout object is a key part of uicollectionview. position of the ui elements, their size, and more. object, override the docreatelayout method in your view class. the docreatelayout method in bookmark list screenlet's view class this is a basic layout that gives you a simple way to customize things like item size, spacing between items, scroll direction, and the same way you would any other if you want to package your theme to contribute it to the liferay screens project or distribute it with cocoapods, see the tutorial on packaging themes using custom cells with list screenlets;;
"your theme is a code library that you can package using follow the steps below to package your theme for use with cocoapods. it's important that you use the same names and identifiers described in these create an empty cocoa touch framework xcode project figure 1 choose cocoa touch framework when creating a project for your theme name your project liferayscreensthemename, replacing name with your you can specify any name, but it's a best practice to use your theme's xcode name, capitalizing its first letter. configure liferay screens for cocoapods, using the steps described in preparing ios projects for liferay screens prepare your theme's classes and resources by making sure your classes compile successfully in xcode and by explicitly specifying a valid module for the custom classthe grayed-out current default value only suggests a figure 2 this xib file's custom class's module is not specified in the following screenshot, the setting for the custom class is correct figure 3 the xib file is bound to the custom class name, with the specified module in your project's root folder, add a file named url change name to your theme's cocoapods namethe value you used to replace name in step 2. your the.podspec file's name and the project's name with liferayscreens add the following content to the file make the following substitutions in the.podspec file commit your changes and push your project's branch to your git repository your theme is now available for other developers to pull from your git you can, alternatively, publish your theme as a public pod. instructions, see the chapter deploying a library in the developers can now use your theme by adding the following line to their app's podfile; they must, of course, change name to the theme's cocoapods name and yourrepositoryurl to your repository's url now you know how to package and distribute screenlet themes with architecture of liferay screens for ios preparing android projects for liferay screens";;
"liferay screens provides several ways to render for historical reasons, web content articles are journalarticle using web content display screenlet is a simple and powerful way to display html from a journalarticle in your app. needs, this screenlet supports several use cases. the simplest use case for web content display screenlet is to retrieve a web content article's html and render it in a to do this, provide the web content article's id via the article id attribute the screenlet takes care of the rest. rendering the content to fit mobile devices, performing any required caching, to render the content exactly as it appears on your mobile site, however, you must provide the css inline or use a template. the html returned isn't aware of a liferay instance's global css you can also modify the rendered html with a delegate, as explained in the as you can see, this is all fairly straightforward. a common mistake is to use the default site id groupid instead of the one for the site that contains your web content articles. using a default groupid in your app, but use a different one for web content display screenlet, assign the screenlet's group id property in interface web content display screenlet can also use for example, your liferay instance may have a custom template specifically designed to display content on mobile devices. use a template, set the template's id as the screenlet's templateid property template id in interface builder recall that structured web content in liferay can have many templates. create your own template if there's not one suitable for displaying web content web content in web content display screenlet, you must create a custom theme also, you must create a custom theme for each structure you in this case, you may find it convenient to create each theme inside a single parent theme and use compound naming to indicate this for example, if you have structures in your liferay instance called book, employee, and meeting, you must create a custom theme for if you create these themes as children of another custom theme called mytheme, you could name them url, url, and regardless of where you create your themes or what you name them, use the following steps to create them if you've already created your own theme, you can in your theme, create a new class called webcontentdisplayviewthemename, extending from basescreenletview. this class will hold the outlets and actions associated with the web content's ui create the ui in the url file. should have a uiview that contains the components you need to render the web content's structure fields. for example, if your structured web content component to render the map point once your components are ready, change the root view's class to webcontentdisplayviewthemename the class you created in the first step, and create the outlets and actions you need to manage your ui components conform the webcontentdisplayviewmodel protocol in the this protocol requires you to add the htmlcontent and recordcontent properties. is intended for html web content; this isn't your theme's use case. theme must display structured web content; use the recordcontent property in this property, set the structure field's value as the next, you'll learn how to display a list of web content articles in your app the preceding examples show you how to use web content display screenlet to display a single web content article's contents in your app. want to display a list of articles instead? first, you'll learn how to use web content list screenlet web content list screenlet lets you retrieve and display a list of web content articles from a web content folder. follow these steps to use the screenlet insert web content list screenlet in your view controller configure the group id and folder id properties in interface builder. folder id is the id of the web content folder you want to display articles to use the root folder, use 0 for the folder id to receive events related to the list, conform the events contain the webcontent for more information on the screenlet and its supported functionality, see the asset list screenlet is similar to web content display screenlet in that it can display a list of items from a liferay instance. since web content is an asset, you can use asset list screenlet to show a list of web content articles. in the delegate, screenletonassetlistresponse gets an array of asset objects that represent webcontent objects. of asset, you can cast the asset objects to webcontent. webcontent object has the html, structure, or structuredrecord to render asset list screenlet with webcontent objects, you must create your create a class in your theme that extends assetlistviewdefault, and override the dofillloadedcell method. in this method, cast the object parameter as webcontent and then retrieve field values from the web content's structuredrecord property. if you want custom cells, you can also override the doregistercellnibs and docreatecell methods. for more details on customizing your asset list";;
you can extend the functionality of the web page that the screenlet renders. this lets you tailor that page to your app's needs. follow these steps to automatically create an empty android project configured create the file url in the folder you want to create your in this file, add all the cordova plugins you want to use in for example, you can add plugins from cordova or github note that the wkwebview engine plugin is mandatory in ios in the folder containing your url file, run screens-cli to this creates your project in the folder platformsios run the following in platformsios open the.xcworkspace file with xcode follow these steps to install and configure cordova the cordova getting started guide to install cordova, create a cordova project, and add the ios platform to install any other cordova plugins you want to use in your app. cordova plugin to view the currently installed plugins copy the following files and folders from your cordova project to your ios in the url file you just copied to your ios project's root folder, now that you've installed and configured cordova in your ios project, you're ready to use it with web screenlet. insert and configure web screenlet in your app when you set web screenlet's parameters via the webscreenletconfigurationbuilder object, call the enablecordova for example, this code adds a local javascript file via addjs and then calls enablecordova before loading the configuration and the note, however, that you may also need to invoke cordova from a javascript file, depending on what you're doing. the cordova plugin cordova-plugin-call-number to call a number, then you must add a javascript file with the following code if you run the app containing this code and wait three seconds, the plugin activates and calls the number in the javascript file now you know how to use web screenlet with cordova rendering web pages in your ios app;;
screenlet delegates let other classes respond to your screenlet's actions. lets the app developer implement methods that respond to login success or for each screenlet that comes with liferay screens lists the screenlet's you can also create a delegate for your own screenlet. through the steps required to do this, using code from the advanced version of the sample add bookmark screenlet all the example code in this tutorial resides in this screenlet's screenlet class. also note that this sample screenlet has two actions adding a bookmark to a liferay instance's bookmarks portlet, and retrieving a bookmark's title from its this tutorial only details creating a delegate for adding a bookmark follow these steps to add a delegate to your screenlet define a delegate protocol that extends the in this protocol, define success and failure methods so the conforming class can respond to the server call's success and failure, respectively. as parameters, these methods should take a screenlet instance and the success addbookmarkscreenletdelegate defines the following success and failure both take an addbookmarkscreenlet instance as their first for their second argument, the success method contains the bookmark added to the server, and the failure method contains the nserror object. note that in this example, the methods are optional. delegate class doesn't have to implement them in your screenlet class, add a property for your delegate. should return basescreenlet's delegate property as an instance of your for example, the addbookmarkdelegate property in addbookmarkscreenlet returns the url property as also in your screenlet class, invoke the appropriate delegate methods in your for example, the url closure in addbookmarkscreenlet calls the delegate method that responds when the screenlet successfully adds a bookmark. calls the delegate method that responds when the screenlet fails to add a note that in this example, these closures are in the screenlet class's interactor method that adds a bookmark be sure to call your delegate methods wherever the appropriate interactor's closures are in your screenlet class now you know how to add a delegate to your screenlets architecture of liferay screens for ios;;
"select lists are ui components that present collapsible groups of options. select list initially shows a single default option. when an option is selected, it collapses to display only it's handy for getting user input while conserving this tutorial shows you how to implement select lists using the alloyui taglib you'll learn how to add a select list to your ui and how to retrieve the option a user selects here's how to implement select lists in a portlet's view using auiselect and create or edit a jsp file where you want to add a select list add an auiselect element and name it for each option listed in the select, insert an auioption element between the starting and ending auiselect tags. here's an example select list with now you know how to create a select list and populate it with it's important to note, however, this example skims only the surface of the auiselect and auioption tag capabilities. far, you've seen nothing that regular html can't do. auiselect tag's configurable attributes give you lots of flexibility to so, make sure to check out its reference documentation adding the select list to your ui is first part of creating a fully functional next, you'll learn how to implement retrieval of the selected there are a couple of ways to retrieve a select list's selected option. both are viable and achieve the same goal. the other way does so using javascript inside the portlet's each approach has its benefits the auiscript tag gives you access to the server side state and its utilities and methods; url gives you cacheability, a separation of concerns with your code, and is shareable generally, you should write as much of your javascript as possible inside url so that the code can be cached. need an initialization point for your code or have to pass data from the server, you should write your javascript inside the auiscript tags. sections that follow cover both techniques up to this point, the select list has been shown as a stand-alone component. since select lists are typically used in forms, this tutorial demonstrates implementing a fully functional select list in a form. next, you'll see how to retrieve a select list's selected option by leveraging the alloyui modules in an auiscript tag inside a jsp this example retrieves the select list's selected option and displays the option's value to the user in an alert add an auiscript element in your jsp and set the use attribute to node the node and event packages can be used to retrieve the button node and inside the auiscript element, retrieve the event's node. the event is attached to a button that has an id btnsubmit the url method retrieves the button with the id btnsubmit. this method returns the first matching node add a variable to represent the select list node as with the button, the select list can be referenced by its id. as part of the argument value passed to the url method. portletnamespace tag is part of the id. with other elements and portlets on the same page. is associated with the select list's id, the portletnamespace tag is a required qualifier for retrieving the select list. in greater detail later in this tutorial. you can also read more about it in below the variables you just declared, attach a function to the node for retrieving the selected option. the example here attaches a click event to the button node assigned to variable btn inside the function, retrieve the select list's selected option by the example here uses the method alert to notify the user about the selected option you can use the val method to get and set the value attribute of its since this example calls the val method without parameters, it you can, alternatively, use the following code note that while the val method can get only the value of the node's value attribute, the attr method can get the value of any of the node's to use the attr method to retrieve a node attribute's value, you must pass that attribute's name as the argument to the method. example, attr'value' retrieves the value of the value attribute. attr method can also be used to set the value of an attribute. this by passing a second argument, which serves as the attribute's new for example, the following code sets selector as the value of the if you're following along with the example in this tutorial, the finished redeploy your portlet, select an option from the select list, and perform the action that calls your script. for this example, click the submit button after selecting an option from the select list as you can see, it takes little effort to implement an alloyui script to retrieve a select list's selected option. achieve the same results using javascript in your portlet's url file you can also use javascript in your url file to retrieve a select because the url file is loaded after the jsp, you have to pass the portletnamespace to the url file. leverage the example form shown at the start of this section to demonstrate how to get a select list's selected option open the url file from your portlet's docrootjs folder add the following code to your url file. the portlet namespace, while the get function retrieves the value of the make sure to replace your-portlet-name with your portlet's name and options with your auiselect element's id value the init function is attached as a method to url. the namespace is set up to be passed as the argument for the init the instance.namespace variable is assigned the the get function uses this variable to add the portletnamespace to the select list's id. variable is declared and set to keyword this from within the jsp containing your select list, you must link to the javascript in url the component that produces the event e.g., a the jsp in the example form has the following button using an alloyui script in the select list's jsp, you can register to from within an alloyui script, you can initialize the javascript you wrote in url and make accessible its function that gets for example, here's an alloyui script that calls the javascript from the when setting the auiscript, make sure to set its use attribute to also make sure to replace yourportletname with your portlet's name and set btnsubmit to your button's id the url method uses the button's id btnsubmit to retrieve the button. the init function is called inside the script and sets the namespace to. the get variable is then set to the get method make sure to match the name of the function you implemented to handle the select option to the name of the function redeploy the portlet, select an option from the select list, and perform the if you're following along with this example, the method is called when you click the submit button now you know how to retrieve the options users choose from your this tutorial's example demonstrates only getting the option and alerting the user of that option. these principles to use the select list's input in your app's business logic. learn how to do this, check out the article writing your first liferay application or dive in to the learning path writing a data-driven application user interfaces with the liferay ui taglib customizing liferay portal with hooks";;
alloyui is liferay's user interface framework. while you can use any framework to develop a user interface for your application, alloyui is an excellent choice since it's already used by the portal. using alloyui minimizes the amount of extra javascript code that you need to add to your application. minimizes the impact your application has on page load time. easy-to-use framework with a uniform api that's based on yui. already using alloyui, choosing alloyui for your application allows your application's look and feel to closely match liferay's styling mechanisms. more information about alloyui, please visit in earlier learning paths, you created a guestbook application, used service builder to generate a data model along with service and persistence layers, integrated your application with liferay's permission system, implemented portlet actions, and a created a user interface for your application. created a guestbook admin control panel portlet, implemented search and indexing for your application, and integrated your application with liferay's asset in this learning path, you'll explore a few alloyui modules and learn how to use alloyui to implement form validation. alloyui to handle events and manipulate dom nodes. interface development of the guestbook application in this learning path.;;
say goodbye to sleepless nights tossing, turning, and worrying about the potentially daunting task of arranging content in your portlets! alloyui's auicol and auirow tags simplify organizing this tutorial shows you how to use these tags in your portlet here's how to add rows and columns of content to your portlet create or edit the jsp file in which you want to organize content reference the alloyui taglib aui by adding the following directive add an auirow tag for each row of content you want. below create placeholders for two rows of content insert and configure auicol tags between each row's starting and ending you can define each column's width using a width or span the width attribute takes precedence over the span attribute if they're both specified in a column the width value represents a percentage of the row's width. represents the number of parts a column uses, out of the twelve parts in which the containing row is divided. specifies a column to use 412, or 13, of the row's width note before a column is rendered, every width attribute is automatically the width attribute's value is divided by 100, multiplied by 12, and rounded to the nearest whole number. the width value in column is divided by 100 and multiplied by 12 resulting in 3.96, which is then rounded up to a span value of 4 the column is rendered across 412 the row's width rows and columns are easy to use. as an example, here are a couple rows of columns that demonstrate setting column widths using width and span in the above example, the portlet's first row has three columns of equivalent the second row's first column uses 13 of the row's width and its second column uses the remaining 23 of the row's width figure 1 here's what the example's rows and columns look like now you know how to organize your portlet's content using;;
would you like to provide instant feedback to users when they fill out a form do you like to use strongly-typed fields and show clear consistent messages to users when they enter the wrong type of data? formvalidator class answers the call! typically you'd have to write tedious complicated validation functions, making sure to dot all your i's and cross all your t's in order to get the functions to thankfully alloyui simplifies form validation with its formvalidator class that is easy to configure and use. accepts predefined properties that have helpful default validation and the form validator gives you flexibility to override the default messages with your own custom messages figure 1 alloyui's formvalidator shows applicable default messages for all kinds user input violations you're probably chomping at the bit to start using formvalidator. tutorial shows you how to use it well. it's time to implement form validation in your portlet with alloyui's formvalidator here are the steps to follow to implement form validation in your portlet you'll start by creating your form if you haven't done so already, create an html. form to facilitate selecting it from the alloyui script that you'll write. lastly, name each of the form's fields that you want to validate here's a form, for example, that has input fields firstname, email, and note that the form has an id attribute and each of the form's input the name attributes of the tags are required for form validation. the validator applies rules to each input field based on its name. more about applying rules shortly now that you have a form, you can add an instance of the follow these steps to add a formvalidator to your jsp add the alloyui taglib aui to the beginning portion of your jsp, if it's not specified in your jsp already add... tags to the bottom of your jsp, unless inside the... tags, instantiate a form validator that follows this format, replacing formid with your form's id value the aui object uses the aui-form-validator module to create a new as the bounding box for the validator. the validator can apply rules, that you'll add to the rules parameter in the next step save the changes to the jsp file if you deploy the portlet at this point, your fields won't get validated. is because the form has no specified rules. this step is where validation really comes into play. implement here control what users can submit in the form here's a list of form validation rules available for alloyui's formvalidator acceptfiles a list of accepted file types defaultempty alpha a boolean value that determines if a field should contain only alphabetic characters defaultnone alphanum a boolean value that determines if a field should contain only date a boolean value that determines if a field should contain only a date digits a boolean value that determines if a field should contain only email a boolean value that determines if a field should contain only an equalto determines if a field's contents are equal to the specified value. iri a boolean value that determines if a field should contain only an max determines if the integer value is greater than the specified value. maxlength determines if the length of the field's contents are greater than min determines if the integer value is less than the specified value minlength determines if the length of a field's contents are less than the number a boolean value that specifies a field should contain only numeric range determines if the integer value in the field is within the rangelength determines if the length of a field's contents is within the required determines if the field is required for submission url a boolean value that determines if a field's contents are a url to apply a rule to an input field, add the field's name in the rules attribute of your jsp and assign the field one or more of the rule values listed above for example, the following code applies required, rangelength, and alpha rules to an input field named firstname if a user breaks any of the validation rules, a message is shown next to the only one message is displayed by default. messages, you can specify showallmessages true when creating the formvalidator, as in the example code snippet below in addition to using the static default messages, you can customize validation messages by using the fieldstrings attribute the fieldstrings attribute lets you specify your own message text for a rule, instead of using the rule's default message text for example, the following code populates a variable named fieldstrings that can be used to apply custom messages for the required and rangelength rules, for a form's firstname input field you can create variables for your rules and field strings, and then pass those variables as arguments to formvalidator's constructor in the example aui script code below, the variable rules holds rule specifications for inputs named firstname, email, and age. fieldstrings holds custom messages for the firstname input. doesn't specify a value for the input or if the user enters a string less than 2 characters or greater than 20 characters long, the respective custom message is as you see from the previous code, declaring variables for rules and field strings helps to organize your code and makes it easier to understand now that you've had a chance to implement a formvalidator, it's time to deploy your portlet and test its form validation figure 2 here, the aui form validator is used to display multiple custom validation messages for an input field as you can see, using the alloyui form validator is a no-brainer for;;
enabling your app's entities to support workflow is so easy, you could do it in workflowized? entities require a workflow handler class to interact with liferay's workflow back end and the entity's service layer. extra fields in their database table that help keep track of their status. service builder is used to create those fields. it needs code to populate the new fields when entities are added to the database, it needs to send the entity through liferay's workflow, and it needs to handle the workflow status of the entity when it's returned by the workflow handlers are your application's way of interacting with the workflow they must implement the workflowhandler interface. abstract class, baseworkflowhandler, provides a base implementation you can extend this class and implement only the methods not included in it's most common to create the workflow handler class in a workflow package in your portlet's docrootweb-infsrc folder, something like this in this example, foo is the portlet name here's how an entire workflow handler class minus imports might look all the interesting work here is done in the updatestatus method. call to the local service utility's method of the same name, so the status returned from the workflow back end can be persisted to the entity table in the the workflow handler needs to be registered with liferay. fully qualified class name for a class that implements the workflowhandler interface refer to the for the proper placement of the tag. declared, the workflow handler declaration goes right to fully implement workflow, the service layer also needs updating there are four database fields your entity should include for workflow add them to each entity's url file run service builder, and each entity now has these fields, though there's no to the addfooentity method, add code to set the initial workflow status as a draft, wherever you're now setting the other database fields your setter method calls, such as also in the addfooentity method, a call to the startworkflowinstance the startworkflowinstance call goes directly before the return statement the service layer should contain all calls to your persistence code. workflow handler is going to get the workflow status back from the workflow back end, then pass it to your service layer to persist it to the database create an updatestatus method in the entity's -localserviceimpl class this method is where the workflow fields are set, then persisted in the database with a call to the persistence layer's update method when the workflow status was set initially in addfooentity, if you're into fake code, it was just to get the initial status set as a draft for the once the entity is run through the workflow process the status is returned and these fields can be properly set aside from setting the database fields, the if-else block of updatestatus is you can see the update method is called before the if statement. the work is done as far as the entity database is concerned. asset enabled, however, you might want to stop it from appearing in the asset publisher unless it's approved in the workflow. field called visible, which marks each asset as visible, or invisible. the if statement above, the display of asset enabled entities in the asset publisher accounts for workflow status after following these steps, an entity is fully workflow enabled. layer, however, likely requires some work to make sure that only approved entities are presented to the app's users make sure that you account for the workflow status in your app's ui. involves creating a new finder method that accounts for workflow status, exposing the finder by creating a getter in the local service implementation, then calling the new getter method in the view layer, populating the ui with for an example of using service builder to create a finder that takes workflow status into account, check out the appropriate section of the learning path on workflow if your app includes an admin portlet in liferay's site administration console, consider displaying all entities, regardless of workflow status. of liferay's portlets take this approach, displaying the entities in a search container and including the workflow status as a column figure 1 the message boards admin portlet displays the workflow status of its entities to make your admin portlet's status field look like liferay's core portlets, now you know how to workflow enable any entities you create. liferay's workflow capabilities in this tutorial, by learning to develop your own workflow definitions, and use scripting to make them more robust approving content with workflow;;
an unfamiliar ui can be tricky to navigate. your users can feel as though they are lost in a jungle, wandering around aimlessly, desperately trying to get the liferay-ui tag library offers a helpful solution in the form of the liferay-uiicon-help tag. the icon help tag creates a handy tooltips are a useful way to communicate additional information to your users in a unobtrusive way. the tooltips render as an easy to identify question icon that informs the user through a informational pop-up on mouse now that you have a better understanding of the liferay-uiicon-help tag and all its informational powers, you can learn how to configure it to pack your user's heads full of information! the example here shows how to add and use the liferay-uiicon-help tag in the first, you need to reference the liferay-ui taglib. the following steps show you how to do this add a directive to reference the liferay-ui taglib note if you have installed a custom theme you may also need to add the following imports to your url for the liferay-uiicon-help tag to work you can now use the liferay-ui tags in your portlet! and configure the liferay-uiicon-help tag inside the url of your portlet, add the liferay-uiicon-help tag at now that you have your tag placed, you can add the message attribute. message attribute is required and contains the text to display to users on add the message attribute to the liferay-uiicon-help tag and give it the text you want to display for the tooltip the message is supplied as a string at the moment. you should supply the message via a language key. in order to supply the language key for the help message you will need to create follow the steps below to create the language key hook set the project name as help-message-language-hook and display name set the proper sdk and runtime, select hook for the plugin type, and the skeleton for the hook is complete. now you need to configure the hook to modify the existing language properties. in this case you'll be modifying the english us language properties, but the process can be used to hook into right-click the language key hook you just created in the package explorer on the left and select new liferay hook configuration with help-message-language-hook set as the hook plugin project select language properties for the hook type and click next leave the default content folder and click add enter url for the property file, click ok and open the docrootweb-infsrc folder of the help-message-language-hook and open the url file in the content package add the following language key to the file and save it now that you have the language key defined you can update the tag to use it in your url, update the liferay-uiicon-help tag to look like the redeploy the portlet, hover over top of the help icon. uses the language key you just created! it's important to note that the question icon for the liferay-uiicon-help tag shows wherever you put it in your jsp. in other words, if you want it to be associated with a given ui element, you have to place it next to that ui element for example, the figure below shows what the configuration above looks like when the liferay-uiicon-help tag is placed next to a default user figure 1 with the configuration above your tooltip should look like this liferay portal uses the liferay-uiicon-help tag to display tooltips for figure 2 here's an example of how liferay portal uses tooltips you can now arm your users with the information they need to using the alloyui form validator in a portlet using liferay ui tabs and sections;;
in this tutorial, you'll learn how to internationalize your jsf portlet. you're unfamiliar with the term localization, you can learn the basics about it the recommended way to handle internationalization with jsf portlets is this method integrates jsf and liferay seamlessly because it lets you hook into thousands of existing internationalized keys that liferay portal includes, and allows you to add your own keys. the following steps demonstrate inside your portlet plugin and make sure to add a language-properties element for each locale that your portlet supports. url file that hooks into a liferay portal language properties file can be found in the jsf-registration-portlet create internationalized language properties files for each locale and add use the built-in i18n keyword expression language el in your facelet for example, for an element declaring the header title as the variable new-user-registration, the declaration would look like this as an example of using the built-in i18n keyword, you can refer to example from the demonstration portlet jsf-registration-portlet internationalizing your portlets is especially easy to do using the options that you now know how to internationalize your jsf;;
you need to create asset renderer classes for your guestbook and guestbook entry entities and register them with liferay. without these classes, liferay's asset renderer portlet is unable to display your entities. fields as title, description, and summary. portlet uses these fields to display assets, regardless of the actual type of entity represented by the asset. these fields are not columns of the database tables of the entities themselves e.g., they are not columns in the journalarticle table in the case of web content articles or of the gbguestbook table in the case of your guestbook entities. are stored in the assetentry table create a new package called url in your create a guestbookassetrenderer class that extends liferay's baseassetrenderer is an abstract class that implements the assetrenderer interface. you gain a head-start on implementing the assetrenderer interface by having your guestbookassetrenderer extend replace the contents of your guestbookassetrenderer class your guestbookassetrenderer class contains a private guestbook variable. most of the methods in this class are simply getters that return fields from liferay's asset renderers follow the factory pattern so you'll have to create a guestbookassetrendererfactory that will be responsible for instantiating the guestbookassetrenderer's private guestbook the baseassetrenderer abstract class that you're extending contains dummy implementations of the haseditpermission and hasviewpermission you override these dummy implementations with actual permission checks using the guestbookpermission class that you created in an earlier learning the render method just returns a string that represents the path to the jsp that should be used to render the guestbook asset. publisher portlet tries to display the full content of an asset, it invokes the asset renderer class's render method and passes a string parameter called template that equals fullcontent. render method returns url when the fullcontent template string is passed as a parameter. jsp later when you're updating your application's user interface next, you need to create the factory class for your asset renderer. class called guestbookassetrendererfactory that extends liferay's replace its contents with the following code this is the class that you need to register with liferay. baseassetrendererfactory which is an abstract class that implements the assetrendererfactory interface. implement getclassname and gettype methods among others which ensure that your custom asset is associated with the correct entity since guestbookassetrendererfactory is a factory class, it needs to be able to the method that's responsible for constructing new guestbookassetrenderer s. uses the classpk primary key parameter to retrieve the guestbook from the then it calls the guestbookassetrenderer's constructor, passing the retrieved guestbook as an argument. guestbookassetrendererfactory also needs to implement a haspermission method. you can easily implement this by using to actually register your guestbookassetrendererfactory, you need to add the url file and add the following element inside of the element corresponding to the guestbook admin portlet this entry should go just below the element and factory will be registered the next time you re-deploy your plugin next, you need to implement an asset renderer and an asset renderer factory for in the url package, create an entryassetrenderer class that extends liferay's baseassetrenderer class. replace the contents of your entryassetrenderer class with the following code this class is very similar to the guestbookassetrenderer class. url method, you're returning a summary that displays both the entry name the name of the user who created the entry and the entry url just returned a summary that url returned the guestbook name. of the methods of entryassetrenderer are nearly identical to those of next, you need to create the factory class for the guestbook entry asset in the url package, create a class called entryassetrendererfactory that extends liferay's this class is nearly identical to the guestbookassetrenderer class. step is to actually register your entryassetrendererfactory. project's url file and add the following element inside of the element corresponding to the guestbook this entry should go just below the element and just above the will be registered the next time you re-deploy your plugin. guestbook project's entities have been fully asset-enabled. functionality that you added, add the asset publisher portlet to a page of your locally running liferay portal instance. then add a few guestbooks and guestbook then check the asset publisher portlet. default, the asset publisher is configured to dynamically display assets of any figure 1 after you've implemented and registered your asset renderers for your custom entities, the asset publisher can display your entities confirm that the asset publisher is displaying the guestbooks and guestbook you can configure custom icons for your guestbook and guestbook admin portlets. to do so, just open your project's url, and update the paths inside of the elements inside of the elements corresponding to the guestbook and guestbook admin portlets note the recommended size for your portlet icons is 16 by 16 pixels. your portlet icons are a different size, they might not be displayed correctly here is a sample icon for the guestbook portlet that's intended to represent a download this icon and add it to your guestbook-portlet figure 2 this is the icon for the guestbook portlet that represents a guestbook entry here is a sample icon for the guestbook admin portlet that's intended to figure 3 this is the icon for the guestbook admin portlet that represents a guestbook the default contents of each element is url. to url for the guestbook portlet's element and to url for the guestbook portlet to make these new icons appear when guestbooks and guestbook entries are displayed by the asset publisher, you need to take one more step. guestbookassetrenderer and add the following method as the last method of the class, just above the log variable declaration next, open entryassetrenderer and add the following method as the last method of the class, just above the log variable declaration confirm that the asset publisher now uses the correct icons when displaying guestbook and guestbook entry assets figure 4 after you've implemented the geticonpath method in your assetrenderer classes, your custom icons are displayed with your custom assets in the asset publisher in the next section, you'll update your portlets' user interfaces to use several features of liferay's asset framework comments, ratings, tags, categories, and related assets.;;
liferay's user interface can be wrapped in permission checks pretty easily. this last step of this learning path, you'll learn how as you've probably noticed, liferay's coding style differs somewhat from the mainstream, borrowing instead practices from other open source platforms like for this reason, you see scriptlets in liferay's jsps, both in the product itself and in various plugins you can check out from github or download from you can mitigate this somewhat by using the standard jstl tags with we'll show you both the scriptlet method and the jstl method, and that way you can decide which style you prefer the usual way of enabling a feature in a web application is to copy its.jar to your lib folder, and if it's a tag library, declare it. way, but liferay makes it a lot easier to do if the library you want to use is already used by liferay in the web-inf folder of your project, double-click on the this file opens in a customized editor in the portal dependency jars section on the top right, click the add you'll see a list of all the.jar files available from the version of liferay portal you're developing for select both url and url from the list and click ok. they then appear in the portal dependency jars list just below this is a section for portal dependency tlds. you'll see a list of available tag library definition pick url from the list and click ok figure 1 the url editor in liferay idedeveloper studio makes it easy to configure new.jars and tag libraries in your applications you've now successfully configured your application to use the jstl tags. that you just used a graphical editor to configure a properties file. not using liferay's developer tools, you can edit the file manually to create now the only thing you have left to do is declare the tag library in your url file so it is made available to all your other jsps now you're ready to use jstl in your liferay jsps. add some more imports that you'll need later they're the permissions helper classes you just created. it's time to implement your permission checks now that it comes to implementing permissions, you'll want to review exactly what it is you want to protect. in the first part, you identified three areas the tabs across the top of your application the first area you want to tackle, then, is the tabs across the top. is already implemented as a scriptlet, this is where you'll add the scriptlet version of the permission check open url and find the scriptlet that uses the for loop to process the list of guestbook entities into tabs. that checks to see if this is the active guestbook, add another if then, after the and tags, modify the closing scriptlet to close both if statements you've now implemented your first permission check. straightforward to do, thanks to the static methods in your helper classes. code above shows the tab if the current user has the view permission for the guestbook and omits it if the user does not next, you'll add permission checks to the add guestbook and add entry buttons scroll down in the file to the line that reads. just below this line, add the following after this is the code that creates the url and the button. button tag, add the closing tag for the statement you've now implemented your permission check for the add guestbook button using adding the check for the add entry button is very similar just after your closing statement, add another one that checks for tag, add the closing tag for the statement you've now implemented all the permission checks you'd defined for save the file and test your application with different users. administrative users see all the buttons, regular users see the add entry button, and guests see no buttons at all but can navigate the next learning path covers action buttons;;
as a liferay application developer, using liferay's permissions system isn't your only option for controlling access to the features of your application. can allow access to your portlet's features to be configured through portlet preferences are properties for storing you can make portlet preferences configurable by adding them to a setup tab in your portlet's configuration menu. permission to access your portlet's configuration menu can adjust the in the screenshot below, configurable portlet preferences are shown for several features of the asset framework figure 1 configurable portlet preferences give you fine-grained control over specific features in your portlet read on to learn about the benefits of using configurable portlet preferences to control access to your portlet's features. with liferay, it's easy to create portlet preferences and allow users to configure them. configurations in no time flat! so why bother with configurable portlet preferences for controlling access to preferences can be a simpler approach. you only have to worry about one permission the permission to access your portlet's configuration window. user with permission to access your portlet's configuration window can adjust any of your portlet's preferences. for example, administrators can allow certain users access to the portlet's configuration window without also allowing them to edit to the portlet's permissions by default, liferay stores a set of portlet preferences for each user, for each however, this can be adjusted by changing the following url settings of your portlet from these defaults you shouldn't use portlet preferences as a substitute for permissions. however, if you want to control access to certain portlet features via portlet preferences, make sure you understand how these settings affect your portlet's a second reason to use portlet preferences is that if you have lots of features, defining explicit permissions for each feature of your portlet can quickly crowd configurable portlet preferences, as is shown in the following screenshot. implementing each of these settings as a separate permission isn't a feasible figure 2 the configurable portlet preferences for liferay's blogs portlet now that you understand how portlet preferences can be useful, it's time to implementing configurable portlet preferences is a straightforward task. instructions, see the tutorial using configurable portlet preferences. keep in mind that unless you need to use the portlet preferences with some additional logic in your controller, you can skip the third step of that once you've created your configuration jsp and any additional control logic that you need, you can use your portlet preferences to control access to the features implemented in any other jsp. to do so, simply wrap each feature in a tag that checks the value of the appropriate preference. the following code gets the hypothetical portlet preference showyourfeature and then uses it with a tag to determine if the given feature should be administrators can then use the portlet's permissions tab in the configuration menu to set the roles that can access the configuration menu. to the configuration menu are then able to set any preferences defined in the figure 3 the permissions tab of the portlet's configuration menu now you know when and how to use configurable portlet preferences to control access to your portlet's features;;
"if you've already used service builder to define your model entities and have implemented business logic for creating and modifying those entities, you might have some ideas for helping users to submit valid model entity data. example, suppose you're working on a calendar app where users can select a date how can you specify that only future dates are selectable? liferay service builder's portlet model hints provide a single place in your portlet project where you can specify entity data portlet model hints are specified in a single file called url in your project's docrootweb-infsrcmeta-inf liferay calls them model hints because they suggest how entities portlet model hints let you to configure how the alloyui tag library, aui, shows model fields. as liferay portal displays form fields in your application, it first checks the model hints you specified and customizes the form's input fields based on these hints. used to specify the size of the database columns used to store the entities and to specify other entity details note service builder generates a number of xml configuration files in your these files to manage spring and hibernate configurations. spring or hibernate configuration files; your changes will be overwritten the next time service builder runs. however, you can safely edit the let's look at the model hints file that service builder generated for the created the url file with the following contents the root-level element is model-hints. all your model entities are represented by model sub-elements of the model-hints element. have a name attribute specifying the fully-qualified model class name. model has field elements representing its model entity's columns. field element must have a name and a type. types correspond to the names and types specified for each entity's columns in service builder generates all these elements to add hints to a field, add a hint tag inside its field tag. you can add a display-width hint to specify the pixel width that should be used when displaying the field. the default pixel width is 350. string field with 50 pixels, we could nest a hint element named display-width and give it a value of 50 for 50 pixels. using the display-width hint in a field element in order to see the effect of a hint on a field, you must run service builder again and redeploy your portlet project. changing the display-width doesn't actually limit the number of characters that can be entered into the name field; it's just a way to control the width of the field in the alloyui input to configure the maximum size of a model field's database column i.e., the maximum number of characters that can be saved for the field, use the the default max-length value is 75 characters. wanted the name field to persist up to 100 characters, you'd add a remember to run service builder and redeploy your portlet project after updating so far, we've mentioned a few different hints. the following table describes the portlet model hints available for use model hint values and descriptions liferay portal has its own model hints xml configuration file called url which is in liferay's portal-implclassesmeta-inf liferay's model hints configuration file contains many hint examples, so you can reference it when customizing your url file you can use the default-hints element to define a list of hints to be applied for example, adding the following element inside a model element applies a display-width of 300 to each field you can define hint-collection elements inside the model-hints root-level element to define a list of hints to be applied together. for example, liferay's url defines the you can apply a hint collection to a model field by referencing the hint like the one above in your model-hints element, you can apply it to your event model's date field by using a hint-collection element that references as always, remember to run service builder and redeploy your project after suppose you wanted to use a couple of model hints in the guestbook portlet. you'd start by providing users with an editor for filling in their comment if you wanted to apply the same hint to multiple entities e.g. to the guestbook entity and to the guestbookentry entity, you could define it as a then you could reference the hint collection in each entity model-hints root element in the url file. to reference a hint collection for a specific field, add the hint-collection element inside of the field element of the field after defining hint collections and adding hint collection references, rebuild your services using service builder, redeploy your portlet project, and check that your the hints defined in your hint collection have taken effect. guestbook example, you should check that the size of the comment text area has changed as specified in the model hints well, you've learned the art of persuasion through liferay's model hints. you can not only influence how your model's input fields are displayed but you can also can set its database table column sizes. individual hints directly into your fields, apply a set of default hints to all of a model's fields, or define collections of hints to apply at either of those you've picked up the hints on how liferay portlet model hints specify using the alloyui from validator in a portlet";;
liferay faces 3.2 and 4.2 are compatible with liferay portal 6.2 see the for more info on liferay portal compatibility. 3.24.2 from liferay faces 3.1 requires a few changes to ensure your projects this tutorial covers the following migration topics first, you'll learn how to upgrade your url file liferay portal 6.2 has two compatible liferay faces versions 3.2 and 4.2. liferay provides liferay faces 3.2 for compatibility with jsf 2.1 and liferay faces 4.2 for compatibility with jsf 2.2 see the for more info on liferay portal and jsf compatibility. using liferay faces 3.1 and are interested in upgrading from liferay portal 6.1 to 6.2, but aren't interested in compatibility with jsf 2.2, you should upgrade but, if you want to use jsf 2.2 in addition to liferay 6.2, you must upgrade to liferay faces 4.2 note this guide only addresses upgrading as it relates to liferay portal. upgrading from jsf 2.1 to 2.2 may require additional changes. upgrading to jsf 2.2 you should check out jsf specific upgrade guides liferay portal 6.2 can enforce namespacing of portlet request parameters, but you must turn this off for your jsf portlets by specifying element of your portlet project's url here's a snippet that specifies this descriptor turning off the parameter namespace requirement is all you need to do to upgrade your jsf portlets to liferay faces 3.2 or 4.2, for use in liferay portal 6.2 as an example jsf portlet that runs on liferay portal 6.2, check out the your url file is now migrated to liferay faces 3.24.2. alloyui was upgraded from alloyui 1.5 to alloyui 2.0 between liferay portal 6.1 the alloyui changes include the deprecation and removal of some javascript functionality, and the addition of some javascript widgets. as a result, in liferay faces 3.2 and 4.2, corresponding liferay faces alloy tags are deprecated and some are replaced. in this section, you'll go over the liferay faces alloy tag changes that you'll need to accommodate in your first, you'll look at the changes to the aui namespace tags the following table identifies the aui tags that are deprecated in 3.24.2 and each tag's replacement, if a replacement exists tag deprecations in the aui namespace note the auicolumn tag must be replaced by an auicol tag that is also, because auicol has completely different attributes than auicolumn, you must account for the auicol attributes. auicol tag, see the vdldocs for liferay faces 3.2 next, you'll look at the changes to the tags in the aui-cc namespace below is a table of the aui-cc tags that are deprecated or removed with respect to the liferay faces 3.2 and 4.2 releases tag deprecations in the aui-cc namespace note the aui-ccmessage and aui-ccmessages tags have been completely removed in 4.2 because no analogous tags in liferay portal exist for them and their functionality is already implemented in the bridge's hmessage and you're now familiar with the alloyui related migration changes, in addition to other changes required to migrate to liferay faces 3.24.2 creating and deploying jsf portlets;;
the liferay faces project originated from the url on april 3, 2012 liferay announced that it would be assuming leadership for the url community. url were repackaged under the liferay faces umbrella project and underwent the following name changes portletfaces bridge provided a class named url.bridgerequestattributelistener but liferay migrate to the new class, you'll need to refactor to the new package namespace, as a deprecated class has not been provided as an example, the code snippet below conveys how the bridgerequestattributelistener was specified in portletfaces bridge that listener-class declaration is replaced in the url by the liferay faces bridge version of bridgerequestattributelistener as you can see, migrating from portletfaces bridge to liferay faces bridge is a portletfaces bridge provided several configuration options for use within the migration, the configuration option names have been reproduced in the liferay it is recommended that the new configuration option names be used, as shown in the following listing by making these changes, you're well on your way to migrating configuration option names to the liferay faces project portletfaces bridge provided classes named url.uploadedfile, but liferay faces bridge uses migrate to the new classes, you need to refactor to the new package namespace, as deprecated classes have not been provided for example, the following import statements must be converted to the new once you've refactored to the new package namespace, you've completed the migrating process for file uploading to liferay faces the projects at url provided several uicomponents and composite components for use within facelet views. the tag library documentation for these components has been migrated to vdl documentation for each version of the each link for the vdl documentation contains information about all the aui, aui-cc, bridge, liferay-ui, liferay-util, and liferay-security tags for that version of the liferay faces bridge, so each vdl documentation link basically holds the entirety of the portletfaces tag library documentation with the exception of certain tags which are excluded from certain versions of the by using the vdl documentation, your migration of the facelet tag library namespaces from portletfaces to liferay faces is a snap! portletfaces bridge provided its own url.genericfacesportlet class, but the liferay faces bridge uses the jsr 329 standard migration, the old class still exists in liferay faces bridge although it has it is recommended that the standard class name be used in all the url file's portlet-class entries as an example, the code snippet below conveys how the genericfacesportlet portlet-class was specified in portletfaces bridge that portlet-class declaration is replaced in the url file by the liferay faces bridge version of genericfacesportlet after completing the above steps, you've officially migrated your genericfacesportlet class to liferay faces! portletfaces provided a class named faces portal uses the url.liferayfacescontext in order to ease migration, the old class still exists in liferay faces portal although it has been deprecated. it is recommended that the standard for example, the following import statement must be converted to the new migrating process for liferayfacescontext the portletfaces-logging project at url has been moved into the in order to keep using this logging api in your portlets, you'll need to refactor to the new package namespace, as deprecated portletfaces provided its own url.logger and url.loggerfactory classes, but the liferay faces bridge you've officially migrated logging to liferay faces url.preference class but liferay faces bridge uses the jsr 329 standard url.preference class. order to migrate to the standard class, you'll need to refactor to the new package namespace as deprecated classes have not been provided with the new converted namespace, you've migrated portlet preferences to liferay that wraps up your migration from portletfaces to liferay faces. specifying the url file for your jsf portlet;;
"you may have several reasons for downloading and building liferay faces from its for this tutorial, you'll learn how to access the liferay faces source code and the liferay faces source code is organized into several first, you'll start with installing a liferay faces project it's important to install the version of liferay faces that you want. to confirm the version of liferay faces you can either install the project by cloning it from github or by downloading both options are demonstrated below cloning the project from github cloning the project requires that you set up git once you've set up git, you can download a liferay faces project from github and work with a particular branch of the project, following execute the following command from your terminal replace the project variable with the liferay faces project you desire navigate into that directory by executing cd liferay-faces-project checkout the branch master is the default branch you want to use for example, to use the 3.x version of source code, execute the following downloading the project as a.zip file to download the liferay faces project as a.zip file, follow these visit the liferay faces project's github page click on the branch drop-down menu and select the branch or tag for the version of the project that you'd like to use click on the clone or download download zip button on that right side of the page to download the branchtag name.zip file for that branch extract the.zip file contents to a location on your machine in a terminal window, navigate into the liferay faces project's root now that you've installed the liferay faces project, you can configure your environment for building the project. in the next section of this tutorial, you'll explore building liferay faces with maven maven is required to build the liferay faces project. is recommended to place your maven installation's bin directory in your system's path, so you can run the maven executable mvn easily from your some liferay faces project should rely on liferay's repository to download maven artifacts over using maven central. to download from liferay's repo, add the following code snippet to your if a url file does not exist in your home.m2 folder, create make sure you're in your liferay faces project directory and, then, build the source with maven by executing the following command maven builds the liferay faces artifacts contained in that project. running mvn clean package in the root folder of the liferay-faces-bridge-impl project produces the generated in other liferay faces projects follow a similar folder path that's it; you've built liferay faces from source! creating and deploying jsf portlets developing liferay faces portlets with maven";;
is normally used to present internationalized jsf views is based on the in order to use the portal user's language preference, liferay faces portal automatically registers the this phase listener modifies the locale inside the based on the user's language preference, which is accessed via the now you're familiar with another key utility that you can access through liferay;;
using the jsr 329378 approach for supporting portlet 2.0 events and portlet 2.0 home page to see portlets that demonstrate the ipc techniques described in this at that location, you'll also find portlets that implement ajax push for ipc, using icefacesicepush and primefacesprimepush for the first tutorial, you'll learn how to use portlet 2.0 public render the public render parameters technique provides a way for portlets to share data by setting publicshared parameter names in a url controlled by the portal. while the benefit of this approach is that it is relatively easy to implement, the drawback is that only small amounts of data can be shared. kind of data that is shared is simply the value of a database primary key. required by the portlet 2.0 standard, public render parameters must be declared this example excerpt from a url descriptor demonstrates setting a public render parameter for a customer id, shared between a customers portlet and a bookings portlet fortunately, the jsr 329378 standard defines a mechanism for you to use portlet 2.0 public render parameters for ipc in a way that is more natural to jsf section 5.3.2 of this standard requires the bridge to inject the public render parameters into the model concern of the mvc design pattern as in jsf model managed-beans after the restoreview phase completes. accomplished by evaluating the el expressions found in the... section of the url descriptor. descriptor excerpt below demonstrates using this mechanism for the example customers and bookings portlets section 5.3.2 of the jsr 329378 standard also requires that if a bridgepublicrenderparameterhandler has been registered in the url descriptor, then the handler must be invoked so that it can perform any processing that might be necessary. implement and register a bridgepublicrenderparameterhandler for processing params for the bookings portlet's currently selected customer could be stubbed out like the following class code for the bridgepublicrenderparameterhandler to be invoked, it must be registered in an element within the portlet's element note for a complete example demonstrating public render parameters and a bridgepublicrenderparameterhandler, see the now that you've explored public render parameters for jsf in ipc, you'll learn in portlet 2.0, you can leverage a server-side events technique that uses an event-listener design to share data between portlets. ipc, the portlet container acts as a broker and distributes events and payload one requirement of this approach is that the payload must implement the url.serializable interface since it might be sent to a portlet in another.war file running in a different classloader. the portlet 2.0 standard requires the events to be declared in the url descriptors of the involved portlets the following example url descriptor snippets define an ipc event for when a customer is edited in the example bookings portlet. bookingsportlet portlet is registered as the event's publisher or sender. the customersportlet portlet, on the other hand, is registered as a processor or listener for that event type. consequently, when a customer is edited in the bookingsportlet portlet, that portlet publishes the event and the customersportlet portlet is notified for processing the event here's a snippet from the customers portlet's the snippet from the bookings portlet's is similar, except it is specified as a publisher optionally, you can implement a bridgeeventhandler for an event type and register the handler in the url descriptor. bridgeeventhandler has been registered in the url descriptor, section 5.2.5 of the jsr 329378 standard requires that the handler must be invoked so that it can perform any event processing that might be when the customer's details such as first namelast name are edited in the bookings portlet, the event named url is sent back to the customers portlet and is processed by the following and here's the descriptor for registering the customereditedeventhandler class as a bridge event handler for the customers portlet. belongs in the customers portlet's element, in the note for a complete example demonstrating jsf 2 ipc events, see the you've explored some common basic jsf portlet development topics dealing with these techniques should help launch you into development of your own jsf contexts and dependency injection for jsf portlets;;
in december 2009, jsr 299 introduced the contexts and dependency injection cdi 1.0 standard into the java ee 6 cdi to version 1.1 for java ee 7. the jsf 2.2 specification which is another component of java ee 7, introduced a dependency on the cdi api for the url.viewscoped annotation and for the faces flows feature. weld is the reference implementation ri for cdi, and apache openwebbeans is another open still wondering what cdi accomplishes? to learn more about cdi and why it has become a popular component for jsf this tutorial covers the following topics first, you'll configure your portlets to use a cdi implementation, such as jboss several app-serverportalcdi-implementation combinations support using cdi with for liferay portal 6.2, you can use one of these combinations for liferay portal 6.1, you can use one of these combinations when developing portlets with cdi 1.0, you must include a url descriptor in your jsf portlet plugin's.war deployment, so that when the cdi implementation scans the classpath it detects the cdi-related annotations of here's an example url descriptor for a portlet plugin if you're deploying your portlet on jboss as 7, you must also include a url descriptor in your portlet plugin's.war deployment to include the cdi-related modules. for a portlet to use weld on most app servers excluding resin, the portlet's url descriptor must include the following filter and filter portlets on resin can use the candi implementation of cdi, which resin includes by default if you're running on tomcat and you choose not to include weld in tomcat's global classpath, then you must include it in the portlet's classpath by adding it to the portlet's web-inflib folder if you're on tomcat and you're using a maven project for your portlet plugin, you must specify the weld servlet as a dependency. maven pom file that exemplifies specifying the weld servlet dependency if you're on tomcat you must also add a weld servlet listener in your portlet's next, you'll learn how to configure the liferay cdi portlet bridge the liferay cdi portlet bridge makes it possible to use cdi with your jsf your jsf portlet projects must include the liferay cdi for example, to specify the bridge dependency in a maven project for liferay 6.2, add to your pom's dependencies element a dependency like the following the url descriptor of the portlet must include the following additionally, the portlet's url descriptor must include the tip the liferay faces project features the demo which is a variant of the it's a good idea to download and deploy the jsf2-cdi-portlet demo in your development environment in order to verify that cdi functions properly you've completed configuring the liferay cdi portlet bridge for you jsf portlet. now that everything is configured, you are ready to begin development with cdi when developing portlets with cdi, you can annotate java classes as cdi managed in addition to cdi scope annotations, it's important to understand jsf 2 annotations and their equivalence to cdi annotations url.requestscoped no such equivalent, since url.requestscoped does not span portlet lifecycle phases. this should help with your understanding of cdi and jsf annotations. you've also seen in this tutorial, configuring cdi for your jsf portlets and configuring the liferay cdi portlet bridge is a snap! communicating between jsf portlets using ipc;;
liferay faces portal provides access to the liferay themedisplay object and the current theme's images liferay faces portal provides the url method for accessing the themedisplay java object and the url exception language el variable for accessing the object in facelets additionally, liferay faces portal provides the url and url facelet el variables for gaining access to theme image you can use these urls as attribute values for facelet composite component the liferay-uiicon tag encapsulates an html img tag whose src attribute can be set to a fully qualified url of an icon image in the current liferay theme by using some of these features, you'll be able to access the current liferay;;
for this tutorial, you'll learn how to dynamically add portlets to liferay here are the places in which you can add a portlet faces-244, dynamically adding jsf portlets doesn't work very well. it's actually not limited to jsf portlets this problem happens with any portlet that needs to add jscss resources to the... section of the portal page. the url resource to perform ajax requests, the url resource must be loaded when the portal page is initially rendered for plain jsf portlets, add a element for the url resource in the... section of the url or prevent double-instantiation in case it gets included multiple times on a this can occur when a jsf portlet is dynamically included and another jsf portlet is added statically. unfortunately, this approach doesn't work for primefaces, since url does not prevent double-instantiation in order to avoid the you do not have the roles required to access this portlet error message, add the following directive to the alternatively, you can place the portlet alone on a hidden portal page and then use a portlet url referring to the plid of the hidden portal page. approach is more appropriate for portlets that perform security-sensitive note, when an end-user dynamically adds any jsf 2 portlet to a portal page, the jsf 2 standard url javascript code is not automatically executed. for the url to be executed, the page must be fully refreshed as a workaround, liferay portal provides configuration parameters that allow the developer to specify that a full page refresh is required. ensures that jsf 2 is properly initialized. now, you know the options you have in dynamically adding your jsf portlets at;;
for this tutorial, you'll learn about the predestroy and bridgepredestroy annotations and how to use them when jsf developers want to perform cleanup on managed-beans before theyre destroyed, they typically annotate a method inside the bean using the section 6.8.1 of the jsr 329378 standard, however, note for an in-depth discussion of this issue, please refer to in order to understand this requirement, it's necessary to differentiate between local portals and remote portals. local portals invoke portlets that are deployed in the same local portlet container. that are deployed elsewhere via wsrp web services for remote portlets. introduced into the jsr 329378 standard primarily to support wsrp in remote that being the case, the standard indicates that developers should however, takes a different approach rather than assuming the remote portal use-case, liferay faces bridge assumes the local portal use-case. developing with a local portal like liferay portal, liferay faces bridge ensures that the standard annotation works as expected. is no reason to use the annotation with a local portal when using liferay faces bridge. annotations for wsrp, you must manually configure liferay faces bridge via the portlet project's url in the below declaration taken from a url, the default value of the context-param is false, meaning that liferay faces bridge invokes methods annotated with over those annoated with setting the value of the context-param instructs liferay faces bridge to prefer the annotation over the standard annotation, in order to support a wsrp remote portal environment the following listener from a url demonstrates supporting the the url value can, alternatively, be specified on a portlet-by-portlet basis in the portlet project's be learning these requirements, you're able to perform cleanup on managed-beans you can do all of this while still abiding by section 6.8.1 of the jsr 329378 standard;;
"important the skinny json provider is a labs application. designated as labs includes experimental features and is not supported by this status may change without notice. labs apps allow us to accelerate the availability of useful and cutting-edge features, but these apps are not yet hardened like standard liferay ee apps. please download and use labs apps at it's the classic story of a superhero trying to maintain his secret identity as a mild-mannered reporter. he's trying to make a living while enter the overbearing boss, with furled brow and a hey you! barks the boss, i want coverage on the hoopla going on in the right away, sir, says the hero as he fuddles around for his pen and you better shoot straight this time. the hero grabs his coat and clumsily knocks into the corner of his desk as he before walking out, he pauses in the doorway to look at his boss and says, sir; i won't let you down. the hero cowers away quickly in a hurried mess maybe you've been asked to get the skinny on liferay portal data. boss demands it or you're personally anxious to get the data to use in a slick either way, you want information from the portal the skinny json provider app is your ticket to getting the skinny json provider offers web services for retrieving web content articles and ddls, but returns them in a simplified, skinny json fashion. convenience, the skinny json provider performs additional parsing and processing, to return the bare essentials of each article and ddl. content article representation is comprised of its associated web content each ddl record representation is comprised of its data the returned values are light-weight and easy to read, making them ideal to use in browsers and mobile applications the skinny json provider app is available through the liferay marketplace. you'll find it categorized as a utility app. to learn how to install it, you can downloading and installing apps the app adds two new web service apis that you can configure like other liferay here is the context and the class name that you must specify to to retrieve web content articles, use the get-skinny-journal-articles service. to retrieve dynamic data lists, use the get-skinny-ddl-records service. that both services include skinny in their names. from liferay's json web service console figure 1 you can access skinny json web services from javascript, curl, urls in your browser, and from liferay's trusty json web service api browser interface before invoking the get-skinny-journal-articles and get-skinny-ddl-records services, you should understand how to use the skinny json provider anonymously and how to use it in a cross-site request forgery csrf protected environment retrieving data through an anonymous request to a web service is a typical use you can configure liferay to allow anonymous access to the skinny json provider. the configuration varies depending on the version of liferay you are using for liferay 6.2 and later, the app is preconfigured to allow anonymous access by the underlying implementation uses the annotation note that this preconfiguration can only be changed by modifying the plugin's source code and recompiling the plugin for liferay 6.1, you must add the value getskinny as a public json web service method entry in your url file to enable anonymous even if you've made authentication required for the skinny provider methods, all of liferay's json web services require you to use a pauth token for csrf protection in environments that pass sensitive per-user data, like browser if your application is running in such an environment e.g., javascript in a browser and you're calling liferay's json web services, you should never the table below shows various ways that you can specify a pauth token you can substitute value with the value of your pauth token if your app is running in a simpler environment like that of a custom mobile app, and you're okay with foregoing the risks involved with disabling csrf protection, you can disable that protection. the mechanism for disabling csrf protection varies depending on the version of liferay you are using for liferay 6.2 and later, you can disable csrf protection for services that you to disable csrf protection for the skinny provider's services, you can open access to the app's plugin context and service class by adding their values to the list of url values for liferay 6.1, the only way to disable csrf checking and disable the pauth token requirement is by globally disabling them. by specifying the following setting in your url note that we do not recommend that you disable csrf checking. information about cross-site request forgery, please see the wikipedia article now that you've configured appropriate access for your skinny json provider app, it's the moment you've been waiting for getting skinny streamlined representations of web content articles and dynamic data lists. following sections, you'll learn how to invoke their services and also how to find values to populate the service parameters. returned json objects look like. if you're itching to access ddls, then you might want to skip ahead to the section retrieving skinny dynamic data lists. the next section shows you how to access skinny web content articles the get-skinny-journal-articles service is designed to retrieve all web content articles that are based on a given web content structure, in a given to retrieve skinny web content articles, you must specify values for the following parameters to demonstrate using the web service, imagine a web content structure that has say you have many articles based on this structure, and you wish to retrieve them through the get-skinny-journal-articles service. example javascript invocation to retrieve the articles you could make the same service invocation by specifying the following url in note that the url above specifies the ddm record id parameter ddm-structure-id, which has a slightly different name than the javascript also, when invoking a service via a url, make sure to url-encode any parameters that contain special characters now that you've seen a couple example invocations, you're might be wondering how to get the different id values to pass in to the service. here are steps you can follow to find that id to view your user account, click on your profile picture and select my note the numeric value of your user id in your browser's address bar, specify the url to your portal's json web here's an example url for services on port 8080 of a portal with the slash character selected as the context path, search for service get-user-roles and select the link to the service under role specify your user id in the userid field and click on invoke from the result text area, copy the value returned next to the note your portal's company id so that you can specify it when invoking skinny as mentioned previously, you'll need to know your web you'll learn how to get that next on adding or editing a web content article, you can select a structure for the the structure selection screen displays a listing of web content each web content structure has an id that you can give to the skinny provider web service as a ddm structure id value figure 2 on adding or configuring a structure for web content, the structure's id is displayed. you can specify the id as the value for the ddm structure id in querying for the articles associated with the structure now that you know your portal's company id and your ddm structure's id, you can invoke skinny provider's get-skinny-journal-articles service services, such as skinny provider's services, via the json web services console erroneously returns empty result sets the get-skinny-journal-articles service returns a jsonarray object the following example return value shows a jsonarray object that includes web content articles each web content article representation is comprised of its associated web the service returns an empty array if no if you think getting web content articles through skinny provider is easy, you'll find it a snap to get dynamic data list records the get-skinny-ddl-records service retrieves all records found in a specified each ddl is globally recognized by its unique idno company id or group name is required to locate them. support localization, no locale argument is needed dynamic data list records can be retrieved using the ddl's record set id. can find the id from within the dynamic data lists app. id that you can supply to the skinny provider web service as the ddl record set figure 3 on adding or configuring lists in liferay's the dynamic data list app, each list's id is displayed. you can specify this id as the value for the ddl record set id in querying the list from the skinny web service now that you know how to get a ddl record set id, you can specify it in calling the get-skinny-ddl-records service for example, imagine that you have a simple ddl based on the following data if the ddl's record set id is 15002, for example, you can retrieve its records by invoking javascript code like this in javascript, you pass the ddl record set id via parameter ddlrecordsetid if you want to retrieve ddl records using a url, you can specify a url like this make sure to specify your ddl record set id as the value for the url parameter the skinny provider's get-skinny-ddl-records service returns a jsonarray object containing zero or more dynamic data list records. shows a jsonarray object that includes several dynamic data list records each ddl record representation is comprised of its data definition fields. service returns an empty array if the ddl has no records each value returned by the service is a json object that you can parse e.g., by invoking javascript's url method on it. group id and uuid of the target image. you can use the group id and uuid to construct a url of the format below to access the image as a recap, the skinny json provider app helps you retrieve lightweight skinny representations of dynamic data list records and web content articles. what a great way to access these core liferay entities! creating ios apps that use liferay creating android apps that use liferay writing a data-driven application";;
"liferay's developers use a tool called service builder to build services. you build services with service builder, all remote-enabled services i.e., url entities with the property remote-servicetrue are exposed as when each url interface is created for a remote-enabled service, the annotation is added on the class all of the public methods of that interface become registered and available as json web services the url interface source file should never be modified by the user. if you need more control over its methods e.g., if you need to hide some methods while exposing others, you can configure the serviceimpl class. the service implementation class serviceimpl is annotated with the annotation, the service interface is ignored and the service implementation class is used for configuration in its place. annotations in the service implementation override any json web service configuration in the service interface when you start liferay portal, it scans service classes for annotations more about scanning later. annotation is examined and its methods become exposed via the as explained previously, the serviceimpl configuration overrides the service interface configuration during registration liferay portal, however, does not scan all available classes for the instead, it only scans services. classes, including plugin classes, registered in the portal's application all classes that are available to the beanlocator are scanned. practically, this means that the portal scans all classes registered in its spring context and the spring context of its plugins. to build plugin services, the services are automatically registered to the spring context and are made available to the beanlocator. that you can register any object in the spring context of your plugin and the portal scans it for remote services! we are not forcing you to use service we recommend using it because it easily does so many things with regards to your remote services note liferay's developers use service builder to expose their services if you haven't used service builder before, please see defining an object-relational map with service builder ok, now let's see how you can register your plugin's remote services as json web keep in mind that liferay's developers use this same mechanism. is why liferay portal's remote service are exposed as json web services let's say you have a portlet named suprasurf that has some services. decide to expose them as remote services. after enabling the remote-service attribute on its surfboard entity, you rebuild the services. regenerates the surfboardservice interface, adding the this annotation tells the portal that the interface's public methods are to be exposed as json web services, making them a part of the by default, scanning of the portlet's services is disabled. you need to add an appropriate filter definition in the portlet's url fortunately, liferay provides a way to automatically add the filter. click the build wsdd button in liferay ide while editing the url file in overview mode, or just invoke the build-wsdd ant target. the wsdd, liferay's plugins sdk modifies the portlet's url and enables the json web services for the plugin. under the hood, the plugins sdk registers the securefilter and the jsonwebserviceservlet for the plugin. if your portal server isn't running, start it up. to get some feedback from the portal on registering your plugin's services, configure the portal to log the plugin's informational messages i.e., its info... messages. see the section on liferay's logging system in to test liferay's json web service registration process, add a simple method to edit your serviceimpl class and add the following rebuild the services and re-deploy your plugin. notice that the portal prints a message like the one below informing us that an action was configured for the this indicates that the service method is now registered as a json web this same mechanism registers liferay portal's own service actions. conveniently enabled by default, so you don't have to configure them next, let's learn how to form a mapped url for the remote service so we can you can form the mapped url of an exposed service by following the naming let's look at the last three bracketed items more closely we'll demonstrate these naming conventions by mapping a service method's url using the naming conventions both on a created plugin service and on a portal for our created service method, the url looks like note the context name part of the url. portal service method we want to access here is that portal service method's url each service method is bound to one http method type. starting with get, is, or has is assumed to be a read-only method and is mapped as a get http method by default. all other methods are mapped as post as you may have noticed, plugin services are accessed via the portal context. conveniently, requests sent this way can leverage the authentication credentials associated with the user's current portal session next, we'll learn to how to list json web services available from our portal to see which service methods are registered and available for use, open your browser to the following address the api page lists the portal's registered and exposed service methods. each method's details, click on the method name. of the method, all of its arguments, and a list of exceptions that can be for additional information about remote service methods, you can look up from within your browser, you can even invoke service methods. portlet services, this can be quite handy for testing the same api page lists remote services of plugins, too. with remote services enabled have been deployed, click on the context path this selector lists all of the available plugin context paths including the portal's path. the portal's context path to list all of the remote services available within as discussed in the registering json web services section, you can control registration by using the annotation in your serviceimpl this overrides any configuration defined in the interface. control the visibility of methods using annotations at the method level let's find out how to ignore a specific method to keep a method from being exposed as a service, annotate the method with the methods with this annotation don't become part of the json web service api let's learn how to define custom http method names and url names at the method level, you can define custom http method names and url names. use an annotation like this one in this example, the plugin's service method addboard is mapped to url can be accessed using the http put method if the url method name in a json web service annotation starts with a slash character , only the method name is used to form the service url; the class similarly, you can change the class name part of the url, by setting the value this maps all of the service's methods to a url class name sbs instead of the default class name surfboard next, we'll show you a different approach to exposing your methods as we discuss up to now, it is assumed that you want to expose most of your service methods, while hiding some specific methods the blacklist approach. sometimes, however, you want the opposite to explicitly specify only those methods that are to be exposed the whitelist approach. too, by specifying manual mode on the class-level annotation. you to annotate only those methods that you want exposed now only the addboard method and any other method annotated with will be part of the json web service api; all other methods of this service will be excluded from the api";;
this tutorial provides examples of invoking liferay's json web services via getting a user and adding a user are used for each method of invocation so that you can understand the differences between them. includes an example of using javascript to invoke liferay's json web services liferay web pages use the alloyui javascript framework. objects created for each liferay page is a liferay object. includes a service function that can be used to invoke liferay's api. invoke liferay web services via liferay.service..., your javascript context must include the alloyui javascript framework. if you're working in a jsp, you can load the alloyui taglib and wrap your to load specific aui modules, specify them via the use attribute. the tag includes the base aui module. aui node and event modules, wrap your code like this if you're not working in a jsp, you won't have access to taglibs. you can create an aui context manually. for example, use the following html fragment to load the aui seed and css files then you can create an aui context like this now you're ready to invoke liferay's json web services let's examine a simple json web service invocation in javascript if you run this code, the email user json object is logged to the the liferay.service... function takes three arguments the callback function takes the result of the service invocation as an argument here's an example json web service invocation in javascript that adds a new it requires a lot more parameters than the one for retrieving a user! including the specified servicecontext object assigns the test tag to note that you can use json syntax to supply values for example, to supply a value for the servicecontext object, you use curly brackets and . a value for the assettagnames array, you use square brackets and . thus, the line servicecontext assettagnames 'test' indicates that servicecontext is an object containing an array named assettagnames you can adapt the example from the previous section for use in a custom portlet. for example, the jsp page below provides a form that allows a first name, middle name, last name, screen name, and email address to be specified. clicks the add user button, these values are used to create a new user in this example, it's assumed that the jsp page is part of a portlet plugin that uses or extends liferay's mvcportlet class. mvcpath url parameter is used in the snippet above. jsp code is in a file named url and that there are also url and url files in the same directory. to view a sample portlet that uses the code above, please refer to the if you want to deploy the portlet, make sure to first read the deployment here's a simple json web service invocation via url that returns the user with this web service invocation returns the email user. provided by liferay's jsonws api page when you click on url example after invoking a service omits the pauth url query parameter. remember that you must be logged in as a user with the required permission in order to be able to invoke a web service. supply the pauth token as a url parameter. tutorial for information on finding the pauth token value that corresponds to if you read the invoking json web services tutorial, you learned that you can supply parameters as either url path parameters or as url query parameters. in the example above, the company id and email address are supplied as url path parameters. here's an equivalent example using url query parameters next, you'll consider an example that requires a lot more parameters! here's an example json web service invocation via url that adds a new user with and here's the same example using url query parameters instead of url path here's an example json web service invocation via the curl tool that returns the user with the specified email address you can execute the command above from a terminal here's an example json web service invocation via the curl tool that adds the user with the specified attributes now you've seen how to invoke liferay's json web services from;;
you can access liferay's services via simple object access protocol soap the packaging protocol is soap and the transport protocol is note an authentication related token must accompany each liferay web for details, read the section on service security layers as an example, let's look at the soap web service classes for liferay's company, user, and usergroup portal services to execute the following list each user group to which user test belongs add a new user group named mygroup add your portal's administrative user to the new user group. demonstration purposes, we'll use an administrative user whose email address we'll use these soap related classes can you see the naming convention for soap related classes? all have suffixes -servicesoapservicelocator, -servicesoap, and -soap. -servicesoapservicelocator class finds the -servicesoap by means of the the -servicesoap class is the interface to the services specified in the web services definition language wsdl file for the -soap classes are the serializable implementations of the let's look at how to determine the urls for these services you can see a list of the services deployed on your portal by opening your note prior to liferay 6.2, there were two different urls for accessing remote liferay services. was for services requiring authentication and was for services that didn't require authentication. as of liferay 6.2, all remote liferay services require authentication and the url is here's the list of secure web services for usergroup note liferay's developers use service builder to expose their services if you haven't used service builder before, please see defining an object-relational map with service builder each web service is listed with its name, operations, and a link to its wsdl the wsdl file is written in xml and provides a model for describing and here's a wsdl excerpt of the addusergroup operation of usergroup to use the service, you pass in the wsdl url along with your login credentials to the soap service locator for your service. we'll show you an example in the next, let's invoke the web service! you can easily set up a java web service client to access liferay's remote in eclipse, you can use the new web service client wizard to either create a new web service client project or add a client to an existing you need to add a new web service client to your project for each service that you need to consume in your client code. build a web service client to invoke the portal's company, user, and to create a new web service client project in eclipse, click file new other..., then expand the web services category. for each client you create, you're prompted to enter the service definition wsdl for the desired service. since our example web service client will use liferay portal's company, user, and usergroup services, we'll need to when you specify a wsdl, eclipse automatically adds the auxiliary files and libraries required to consume that web service. web service client project using one of the above wsdls, you need to create additional clients in the project using the remaining wsdls. additional client in an existing project, right-click on the project and select the code below locates and invokes operations to create a new user group named myusergroup and add a user with the screen name test to it. url file in your web service client project and add the if you create this class in a package other than the one that's specified in the code below, replace the package with your package. run the client from eclipse, make sure that your liferay server is running, right-click on the url class, and select run as java check your console to check that your service calls succeeded running this client should produce output like the following example the output tells us the user had no groups, but was added to usergroup you might be thinking, but an error was thrown! an error was thrown url.remoteexception , but we're sitting here as cool as an ice cream sandwich all the same. the exception was thrown simply because the usergroup check was invoked before the usergroup was created. because the very next line of the output says added user group named..., we're here are a few things to note about this example the operations getcompanybyvirtualhost, getuseridbyscreenname, usergroupservicesoap in the wsdl files. parameter order, request type, response type, and return type are conveniently specified in the wsdl for each liferay web service. next, let's implement a web service client in php you can write your client in any language that supports web services invocation. let's invoke the same operations we did when we created our java client, this time using php and a php soap client remember, you can implement a web service client in any language that supports to learn how to implement oauth so that you can access third-party services, please see the authorizing access to services with oauth finding and invoking liferay services;;
"suppose you wanted users to authenticate to your liferay portal plugin from a you might think that you'd need to store the user's credentials e.g., the user's twitter account name and password, so you could pass them along with requests to the service provider and log them in. the third party is a moving target what happens when they modify their site, and your slick authenticator stops working? additionally, you might receive some criticism from your users for asking them to give their twitter credentials to you so you can use them to log in. this is where oauth comes into play, taking a approach oauth delegates user authentication to the service provider. plugin uses a token to prove it is authorized to access the user's third-party profile data and invoke authorized services. plugin, you get the best of both worldsaccess to an outside service provider, and your users' trust that the plugin won't have access to their protected in addition, liferay portal instances can act as oauth service providers you can provide a means for your users to use their portal credentials to access other services that have oauth configured. the oauth framework lets liferay service portal administrators specify well-defined service authorizations. the users can invoke the services via oauth clients, such as the oauth-enabled plugin that you'll learn about in this section note to learn more about the oauth framework, liferay oauth app, registering your oauth app, or activating it from a portal page, please refer to to access portal services using oauth, you'll need to create a client that uses an oauth cycle implementation, along with a user interface to lead your users in this section, you'll see an example of a portlet accessing json web services from a remote portal. let's get started by first selecting and implementing services of an oauth client library in order for your portlet to use oauth, it must have a reference to oauth you can offer your portlet an oauth client library by specifying a single jar file. in this example, scribe is chosen as the oauth library because it's available in liferay portal and can be easily to use the scribe oauth client library, open your plugin's url file and insert the url file as a your portlet now has access to scribe's oauth next, you'll implement scribe's oauth service interface now that your portlet can access an oauth client library, you need to implement the oauth services in your portlet. the following code demonstrates implementing a scribe oauth service api in this code snippet, the portlet provides the service platform's oauth urls to scribe to acquire the access token and request token from the service a request token is a value the portlet uses to obtain user it is exchanged for an access token. value the portlet uses to gain access to protected resources on behalf of the the exchange of a request token for an access token replaces the need for supplying the user's service provider credentials in addition to the tokens, you'll also need to provide the callback url so that the service platform can redirect the user's browser back to your portlet, once authentication and authorization is complete. the callback url can be provided in an authorization request as a parameter, or it can be specified when registering your application through liferay's oauth admin menu. that a callback url provided via an authorization parameter overrides the callback setting specified in the oauth admin menu. url as an authorization parameter in your portlet's url file. here's a code snippet that uses the callback url and request token in acquiring the oauth service besides authorizing the callback url, you're also implementing methods to acquire the oauth service, submit the request to that service, and obtain tokens from by doing this, you provide oauth services to your portlet. you're not quite done yet; you still need to provide information about the oauth first, you need to specify the oauth protocol context paths for your urls. the case of using liferay portal as a service platform, the default paths for the oauth portlet are specified in the url portal property found section of portal's url file. require authentication to access you'll need to transfer these oauth related constants to your portlet's here's an example code snippet of what these now your oauth services are implemented and oauth constants are your portlet can now take part in the oauth authorization process! you'll just need to set up a simple user interface to start the oauth cycle. your portlet's user interface must initiate the oauth cycle the first time it accesses the oauth platform for each specific user. render the oauth authorization ui automatically when the portlet does not possess the access token and access secret. the jsp code snippet below initiates the oauth authorization process on successfully getting authorization from the service provider, the oauth platform redirects the user back to the callback url, which in this case is a url for the setupoauth portlet action. this action method uses the request token it stores the token secret and the token itself. a snippet of the portlet action method the figure below shows the oauth authorization user interface figure 1 when your portlet is granted access to the service provider, it acquires the access token and access secret on completing initial oauth authorization via the ui and on the user revisiting the portlet instance thereafter, the portlet should render its normal ui. once your portlet is granted access, the oauth platform redirects the user back to the callback url you specified during the portlet's registration once you have the access token and access secret stored, your portlet can use them to access services such as json web services. you've implemented an oauth client library, created a service implementation, and developed a user interface to present the oauth cycle. course, this example and its code snippets are not compatible for all use cases, but they demonstrate configuring an oauth-ready application for liferay portal";;
in this learning path, you'll use service builder to create remote web services when you're finished, authorized clients, such as mobile devices, will be able to consume your application's web services. means that mobile application developers will be able to create apps which can interact with your application. for example, android or ios developers could create guestbook apps which allow users to view and add entries to your guestbook application from their smartphones or tablets read on to learn how to create consumable services for your liferay;;
you can find liferay's services by searching for them in the javadocs below, we'll show you how to search for portal services and portlet services let's start by finding a portal service liferay's javadocs are easy to browse and well-organized. in your browser, open up the javadocs under portal services, click on the link for the url package, since the services for the organization entity belong to the portal scope find and click on the serviceutil class in this case, organizationlocalserviceutil in the class summary table or the classes list at the bottom of the page what if you want to find portlet services searching for one of liferay's built-in plugin services is also easy. clicking the link for the service package of the portal, click the link for the service package of the portlet. the portlet service packages use the naming convention url.portlet-name.service, where portlet-name is replaced with the actual name of the portlet here's how you find services for a user's blogs statistics in your browser, open the javadocs under portlet services, click on the link for the url package in the packages frame, since the services are a part of the blogs portlet find and click on the serviceutil class in this case blogsstatsuserlocalserviceutil in the class summary table or the now you're ready to invoke liferay services. remotely, your liferay instance must be configured to allow remote web service every liferay service provides a local interface to clients running in the same many local services localserviceutil classes are called by remote services serviceutil classes. complexity of the local service implementations and include permission checks. the core liferay services that are provided as part of liferay portal were generated by the same service builder tool that you can use in your you can invoke a remote liferay service by calling the appropriate demonstrates how to get a list of the most recent bloggers from an organization. note that only a local service, not a remote service, is available for this jsp code invokes the static method getorganizationstatsusers from the in addition to any services you create using service builder, your applications can access a variety of services built into liferay. many default liferay services are available as web services. web services via soap and json web services. if you're running liferay locally on port 8080, visit the following url to browse liferay's default soap web to browse liferay's default json web services, visit this url by default, the context path is set to which means that core liferay you can select a different content path to view the e.g., set the context path to calendar-portlet to view the services of liferay's calendar portlet click on the name of a service method to view details about it. path to the service's impl class is displayed along with the method's parameters, return type, and possible exceptions. can use to enter values for the method's parameters and actually invoke the note that you must be logged in a user that has permission to invoke the service for your service invocation to succeed the web interface for json web services is very handy for development and however, liferay web services are designed to be invoked by client liferay's web services apis can be accessed by many different kinds of clients, including non-portlet and even non-java clients. information on how to develop client applications that can access liferay's json for information on how to develop client applications that access liferay's soap web services, please see the working with soap web services to learn how to create remote web services for your own application, for more information on liferay services, see the liferay portal ce javadocs at or the liferay portal ee javadocs included in the liferay portal ee documentation.zip file that you can download from the customer portal on invoking liferay services in your android app invoking liferay services in your ios app;;
"liferay ide's integration of tern provides many valuable front-end and back-end development tools for code inference and completion. tutorial covers how to enable tern features for your projects before beginning this tutorial, make sure your ide instance has the necessary development tooling and tern integration installed. installation details and search for liferay ide alloyui under if you have it installed, you can continue to the setting up tern features section; if you do not, you'll need to install it by following navigate to the help install new software... menu and copy in the following link in the work with field make sure the liferay ide alloyui option is checked and finish the figure 1 the liferay ide alloyui option is actually a sub-option listed within the liferay ide option now that the necessary features are installed, follow the steps below to learn how to enable tern's code assist features in your project tern features are enabled on a project-by-project basis. features are already enabled for liferay portlet plugins. types, you'll need to follow the steps below right-click on your project and select configure convert to tern your project is now configured to use tern features. project configured, you need to enable the modules you want to use for your right-click your project and select properties here you'll find a list of all the available tern modules you currently have to use alloyui features, you'll need the aui, browser, ecma5, liferay, and yui modules enabled. figure 2 by selecting these tern modules, you can use alloyui code assist features in your project check any additional modules you wish to use in your project and click ok your project is now set up to use ide's tern features using front-end development code assist features in ide developing applications with liferay ide using the alloyui form validator in a portlet";;
you can create layout templates to customize the display of portlets on your page and to embed commonly used portlets. tutorial described a nice scene where you're relaxing in a luxurious chair, computer in your lap, lenore ii your cat purring on the mantle above a dancing it would be, but the chair's too small, so your knees are up in the air when your feet are flat on the ground, and your laptop is balanced precariously on top of them. the fire is also surprisingly large for in fact, its flames are already licking at the bottom of the remember lenore ii, softly purring on the mantle? she's going to cook just like the original lenore if you don't do something! it's so hard to get out of this tiny chair. in the words of edgar allen poe adapted from the raven tell this soul with sorrow laden if, within the distant aidenn, it shall clasp a sainted kitten whom in memory of the late, now crispy lenore ii, it's time to create a layout to create a liferay layout template plugin project, follow the creating liferay maven plugins from liferay ide creating liferay maven plugins from the command line tutorial, making sure to select layout template as the plugin type archetype command line tool to generate your layout template project, you can filter on group id liferay, or even group id artifact id combination liferaylayout, to find the liferay layout template archetypes since it's helpful to familiarize yourself with the liferay layout template plugin project's anatomy, that topic is covered next a layout template project created from the there's a directory structure difference between plugin projects created using liferay maven archetypes and those created using the liferay plugins sdk. following table illustrates this difference you've passed your trial by fire your new cat, lenore iii, thanks you, developing yet another plugin type with maven. deploying liferay plugins with maven;;
if you're unfamiliar with the liferay faces project, it's important to know that liferay faces is an umbrella project that provides support for the javaserver faces jsf standard in liferay portal. thus, liferay faces portlets and jsf for further details on jsf portlets and the liferay faces project this tutorial explains the liferay faces portlets generation process using maven, and the anatomy of a jsf portlet you'll begin creating a liferay faces portlet plugin next to create your liferay faces portlet plugin project, follow the creating liferay maven plugins from liferay ide creating liferay maven plugins from the command line tutorial, making sure to select portlet as the plugin type and jsf 2.x as lastly, you'll be required to select a jsf component a liferay faces portlet can be built to use one of several different jsf jsf component suite has an archetype that is used in creating the portlet archetype command line tool to generate your portlet project, you can filter on the group id liferay, or even the group idartifact id combination liferayportlet, to find the liferay portlet archetypes more easily it's helpful to familiarize yourself with a liferay faces portlet plugin you can explore its anatomy next a portlet project created from the maven creates the srcmainjava directory automatically. portlet's java source code e.g., url , and portlet-pluginsrcmainwebapp holds its web source code. any portlet plugins using the plugins sdk, you might have noted it uses a the following table illustrates the differences in the locations of the java source code and web source code for a maven project and a plugins sdk project you now know how to create liferay faces portlets that can leverage one of several powerful jsf frameworks jsf portlets with liferay faces developing liferay plugins with additional maven archetypes deploying liferay plugins with maven;;
"liferay provides more archetypes than just the ones for portlets, hooks, themes, the liferay team has been busy expanding the list of check out these exciting archetypes that are available in addition, there are some maven goals liferay has provided you now have plenty of archetypes at your disposal! if you've been following our story that's dispersed throughout our maven tutorials, you might be concerned for the cat we introduced, lenore ii. i'll let edgar allen poe from the raven break the but the chair whose violet lining with the lamp-light gloating o'er, lenore ii shall press, ah, nevermore! lenore ii didn't make it through all of the liferay maven tutorials, but you you can develop all your liferay plugins using maven; there's a standard process for generating the archetypes and selecting your plugin options for each you can then customize the archetype to your liking. develop plugins offers an easy and effective way to customize your liferay are you wondering if we're going to make more terrible jokes that steal from you're ready to create all kinds of liferay plugins based on liferay's plugin just don't let lenore iii sleep near the fire this time";;
when working with maven projects in liferay ide, you may encounter situations where your project is missing required maven properties. maven properties go missing when a maven profile id isn't associated with the a project's creator may accidentally delete the profile id from the either way, liferay ide reports the missing properties as errors in your url file's editor. reports such errors in a section named maven configuration problem figure 1 liferay ide lets you know when your maven project is missing required properties liferay ide, fortunately, provides a way to fix these problems the quick fix the quick fix tool lets you select or create a profile for your maven project, so that your project can access the maven properties it needs. tutorial shows you how to address missing maven properties using the quick fix the first thing you need to do is launch the quick fix tool. the maven configuration problem section of the markers view in liferay ide. then, right-click the error and select quick fix from the context menu. following screenshot shows the quick fix option in the context menu figure 2 to open the quick fix tool, right-click the error and select quick fix from the context menu the quick fix tool opens, showing you information about the error. the error appears at the top of the window, followed by possible solutions. panel at the bottom of the tool shows the file in which the error occurs. screenshot shows the quick fix tool figure 3 the quick fix tool presents you with information about maven property errors and possible fixes in the case shown in the figure above, there are two fix options. fix the error by attaching a maven profile to the project. however, in how they enable you to provide profiles one solution lets you create a new profile, while the other lets you select from existing profiles the remainder of this tutorial explains how to the next section walks you through creating a new maven profile using the quick fix tool if you want to select an existing maven profile for your project, you can skip to create a new maven profile, select that option in the quick fix tool and click finish. you are presented with options for selecting your liferay runtime, profile id, liferay version, and profile location figure 4 you can create a new maven profile with the quick fix tool first, select your liferay runtime from the menu. runtime configured or you wish to use a new one, click the new runtime icon to the right of the liferay runtime combo box. a default liferay version is selected for you automatically based on make sure its liferay version matches your runtime. certainly not least, select the location for your new profile. now just click ok, and the missing properties to resolve missing maven properties, the quick fix tool also lets you select existing maven profiles to use with your project. in the quick fix tool and click finish. a new window pops up that shows your available profiles on the left and selected profiles on the right figure 5 the quick fix tool also lets you pick existing maven profiles to use with your project to select a profile to use, click it in the column on the left and then click the move right arrow between the two columns. this moves the profile into the column on the right, so your project can use it. column on the right by mistake, select it and then click the red x button on this removes that profile from the right hand column. once you've selected the profiles you want to use, just click ok and your missing properties error disappears! as you can see, the quick fix tool is aptly named. helps you create or find properties for your maven project developing plugins with liferay ide developing with the plugins sdk;;
"liferay maven plugin projects created with liferay ide 2.0 milestone 1 and newer have all the required liferay facets, including the new m2e-liferay the m2e-liferay plugin provides a project life cycle map for building and deploying your liferay project. if your liferay maven plugin project was created outside of liferay ide or created in a liferay ide earlier than version 2.0 milestone 1, you must update the project with the latest required facets, including the m2e-liferay plugin. projects with facets and shows you how to import your standalone maven projects you'll also learn how to determine whether your project is missing any required facets, in case you're unsure if you're interested in learning more about the liferay maven project facets, then you'll enjoy the next section. you can otherwise skip ahead to the section after it to learn how to set up your older liferay maven projects to use the beginning with version 2.0 milestone 1, liferay ide supports liferay maven projects that use the m2e-liferay eclipse plugin. contains a maven project configurator that enables liferay maven plugin projects to use liferay facets. liferay maven projects with liferay facets are recognized as full liferay ide projects while it's possible to use a variety of maven-related mojo plugins to build liferay plugin projects, you should use liferay-maven-plugin to build them. liferay plugin archetype available in maven central adds the liferay-maven-plugin to the build plugin configuration section of the note that most of the liferay maven plugins are just.war packages with the liferay-maven-plugin added to their configuration sections to support these projects in liferay ide, a mechanism is needed for the ide to recognize them as liferay ide projects. non-maven liferay ide projects are recognized in eclipse as faceted web projects with the appropriate liferay these projects are also eclipse web projects, which are simply faceted projects with the web facet installed. projects recognized by eclipse and working with the rest of its jee tooling, the projects must be faceted as flexible web projects. concert with the following eclipse plugins meet these requirements the m2e-core plugin contains the standard maven tooling support for eclipse. main benefits that m2e-core provides are dependency resolution classpath management and an abstract project configuration framework for adapters. m2e-wtp plugin enables projects to be recognized as flexible web projects. m2e-wtp plugin provides project configuration mapping between the.war package type the poms in the maven model and the flexible web project support in with these eclipse plugins in place, there's just one piece remaining to make liferay maven projects first-class citizens in eclipse. must be explicitly told how to integrate the liferay-maven-plugin, so it can add the liferay-maven-plugin goals prefixed with liferay to the standard normally without the m2e-liferay plugin, m2e-core users have to specify manually the liferay-metadata-execution mapping themselves. m2e-liferay plugin automatically provides this mapping. also provides m2e-core with additional build participation integration to make sure that liferay maven projects are handled properly in the eclipse build for example, m2e-liferay makes sure that the liferay maven goal liferaybuild-css is called when eclipse deploys a liferay theme plugin. liferay maven goals are similarly enabled by m2e-liferay now that you know the details of what the m2e-liferay plugin provides, you can in the next section, you'll learn how to set up your existing liferay maven plugin projects to use the m2e-liferay plugin for maven life cycle making sure that your project has the correct facets and liferay maven life cycle just right-click your project and select properties. window that appears, open the maven section on the left and then click figure 1 the life cycle mapping for this liferay maven project is correct if the life cycle mapping is correct, the liferaybuild-css item has a green the mapping and source fields for liferaybuild-css should also contain configurator and extension, respectively. isn't correct, then you can install the m2e-liferay plugin by following the instructions contained in the tutorial if you have an existing liferay maven plugin project that you'd like to import into liferay ide, the next section explains how to install the m2e-liferay plugin during the import process importing and installing the m2e-liferay plugin is straightforward when importing a liferay maven project that contains all of the required liferay the plugin installer launches immediately after you specify the project to import, effectively combining these two processes. the window that appears, select existing maven projects, and click next figure 2 the first step in importing an existing liferay maven project the next step is to specify the project to import. location in the root directory field. once you select a project, its url make sure that the checkbox next to the url note that this example imports the project maven-test. this project's liferay properties are contained in a profile in the url, the profile must be specified in the profiles field of the advanced you don't need to specify a profile here if the liferay properties are contained elsewhere in the project. for example, if the liferay properties are specified for the whole project in a tag in the url, then you don't need to put anything in the advanced section. figure 3 specify the liferay maven project that you want to import and click finish liferay ide detects that you don't have the correct life cycle mappings for the project you're importing and suggests an action; install maven integration for liferay ide the m2e-liferay plugin if at this point, the setup maven plugin connectors dialog displays a green check mark before each of the maven build goals listed in the table, you can proceed to setup the maven plugin connectors by clicking finish and continuing if a red check mark precedes any of the maven build goals however, then you can resolve them by continuing to the next section figure 4 click finish to launch the installer for maven integration in liferay ide the next set of steps takes you through the installation process for the first, make sure that the checkbox for the m2e-liferay plugin is checked and then click next. this takes you to the window that lets you review the items you've marked for installation. m2e-liferay plugin is listed and click next. select the radio button to accept the license the following sequence of screenshots shows these figure 5 the first step of the installer lets you select the m2e-liferay plugin for installation figure 6 review the item that you selected for installation in the previous step of the installer figure 7 agree to the licenses and click finish to complete the installation upon clicking finish, the m2e-liferay plugin downloads and installs. this may take a few minutes to complete. when the installation is complete, you're prompted to restart eclipse. restart eclipse and you're all set! as mentioned during the maven plugin connector installation discussion, if the wizard detected missing liferay properties, you can follow the instructions in the next section to resolve those missing properties on importing your liferay what if the project that you want to import doesn't contain liferay properties? liferay ide still has you covered. the initial import steps are the the process diverges, though, after you specify as before, liferay ide detects that you don't have the correct life cycle mappings for the project you're importing and suggests an however, since there are no liferay properties in the project, it shows when you click finish, you're presented with a warning that tells you you're about to import a project that contains errors. resolve this in the following steps. figure 8 the error occurs because liferay ide can't find the correct plugin connectors as indicated in the previous dialog box, the project imports, but it contains to resolve this, you need to download and install the m2e-liferay first, open the liferay ide preferences by selecting window then open the maven section on the left, select discovery, and click the open catalog button. this opens the catalog of plugins that can figure 9 in preferences, open the plugin catalog for maven now just scroll down in the catalog, check the checkbox for m2e connector for liferay-maven-plugin, and click finish. this launches the installer for the the steps in the installer are identical to those in the once the installation completes and liferay ide restarts, the error in your imported project is gone! figure 10 select the m2e-liferay plugin for installation and click finish to launch the installer now you know how to resolve life cycle mapping errors for liferay maven just remember that it's the m2e-liferay plugin that takes care of the maven life cycle mapping developing plugins with liferay ide developing with the plugins sdk";;
"you can download the liferay maven artifacts if you're just interested in using the artifacts for a specific release. however, if you'd like to use the very latest liferay ce maven artifacts, you can build them from source. latest liferay ce maven artifacts from source, follow these steps navigate to your local liferay portal ce source project. already have a local liferay portal ce source project on your machine, you can fork the liferay portal ce github repository, found at url, and clone it to your machine create an url.user name.properties file in your local liferay specify the following properties in for example, if you're using liferay with apache tomcat 7.0.42 bundled in your cbundles folder, you'd specify the following of course, you should specify the values appropriate to your application server and your bundleparent directory. url.type.dir directory doesn't need to exist yet; it is created by invoking an ant target in the next step run ant -f url unzip-app server name to unzip a copy of your preferred application server to the specified directory for example, to unzip apache tomcat to the directory specified by your create a releases.user name.properties in your local liferay portal ce source project root directory and specify your gpg credentials and maven repository information, similar to the properties in the following example of course, replace the values specified above with your own gpg credentials and maven repository information if you don't have gpg installed and don't have a publicprivate gpg key, you should visit url and install gpg once you've installed gpg, generate a gpg key by running gpg --gen-key and following the instructions. key, you can find your gpg keyname by running gpg --list-keys note if you only plan to install the liferay artifacts locally and not deploy them, the releases.user name.properties is not required open a command prompt, navigate to your liferay home directory, and build the liferay portal war file by running deploy the liferay artifacts to your maven repository by running if you want the liferay artifacts to be installed locally but don't have a remote maven repository or don't want the artifacts to be remotely deployed, you can run the installation target instead of the deploy target ant -f url install-release-artifacts or ant -f url install-snapshot-artifacts. the target installs the liferay artifacts you built to your local.m2 repository e.g., to your userhome.m2 packaging up the url files for your liferay artifacts, your machine may experience sluggish performance or an insufficient amount of java heap there are two solutions to this problem increase the memory available for the javadoc packaging process navigate to liferay home url and search for the javadoc target. find the maxmemory property and increase it as desired skip the javadoc packaging process navigate to liferay home url and find the prepare-maven target. this target, comment out the call to the jar-javadoc target, like below you now know how to build liferay ce artifacts from your local portal installing and managing liferay maven artifacts";;
you'll use entry list screenlet by following the same steps to use any screenlet insert the screenlet's xml in an activity or fragment layout, and then implement the screenlet's listener in the activity or fragment class. you'll follow these steps here to insert entry list screenlet in first, you'll insert entry list screenlet's xml in entriesfragment's layout, inserting entry list screenlet's xml is very simple. url to do is display the screenlet, it must only contain replace the contents of url with the as with guestbook list screenlet, you'll use the androidid value to get a next, you must implement the screenlet's listener recall that to use a screenlet, you must implement its listener. methods let the app developer respond to the screenlet's behavior in the activity or fragment class that contains the screenlet. guestbook list screenlet didn't need extra listener methods, you used it in guestbooksactivity by implementing the with guestbookmodel as a type argument. entry list screenlet also doesn't need like guestbook list screenlet, you can use it by implementing baselistlistener with its model class as a type argument follow these steps to implement entry list screenlet's listener in change entriesfragment's class declaration to implement the class declaration should now look like this requires that you add the following imports now you must implement the listener's methods. full explanation of the methods in both listeners, see note that in entriesfragment, you don't need to take any action in these there are no ui elements or other parts of the fragment that must be updated or processed in response to the screenlet's behavior. screenlet must do is display its content, which it does regardless of anything you do in the listener methods. the only thing you may want to add is a toast message in onlistpagefailed to notify the user if the server call fails, but this isn't required. this requires you to add the following imports now you're ready to register entriesfragment as the screenlet's listener. you'll do this the same way you registered guestbooksactivity as guestbook list screenlet's listener get a reference to the screenlet and call its after doing this, you'll use the entry list screenlet reference's setguestbookid method to set its guestbook id. guestbook where the screenlet gets its entries. replace the oncreateview method with this as you can see, oncreateview now registers entriesfragment as the screenlet's listener and sets the screenlet's guestbook id. now run the app in the emulator and log in with your credentials when prompted. the app then presents you with the first guestbook's entries. navigation drawer by pressing the hamburger button, then select a different the drawer then closes to show the selected guestbook's entries. your app now uses guestbook list screenlet and entry list screenlet to show the same guestbooks and entries as the guestbook portlet. screenshots show these screenlets in action figure 1 entry list screenlet displays guestbook entries in your app figure 2 guestbook list screenlet displays guestbooks in the navigation drawer although your screenlets work, you may have noticed something odd about the navigation drawer's headerit's hideous. the action bar is somewhere on the purple-blue spectrum, while the drawer header is green. more attractive finger paintings. fortunately, it's simple to change the drawer also, the drawer header contains the generic text you should change this to something more suitable for your follow these steps to apply these changes to the drawer header androidendcolor, and androidstartcolor with the following settings this sets the drawer header's colors to match the colors used in the rest of define the following string resource in url in url, find the textview element that contains androidtextandroid studio, and replace android studio with you can delete any other textview elements in run the app again, and open the drawer after signing in. drawer header now shows your greeting. figure 3 the drawer header looks a lot better after some light customization now you know how to use liferay screens and create your own this opens up a world of possibilities for developing apps that although you learned a great deal in this learning you can customize your screenlet's appearance, package it for redistribution, and even configure it to receive push notifications. these topics, and more, are covered in the tutorials on android apps with liferay screens.;;
hooks are the optimal plugin type for customizing liferay's core features. creating a hook plugin with maven is very similar to creating a portlet plugin this tutorial explains how to create a hook plugin and explains the liferay maven hook plugin project's anatomy to create a liferay hook plugin project, follow the steps outlined in the creating liferay maven plugins from liferay ide creating liferay maven plugins from the command line tutorial, making sure to select hook as the plugin type archetype command line tool to generate your hook you can filter on group id liferay, or even the group idartifact id combination liferayhook, to more easily find the liferay portlet archetypes since it's helpful to familiarize yourself with the liferay hook plugin project's anatomy, that topic is covered next a hook project created from the the hook-pluginsrcmainjava directory holds the hook's java source code e.g., url and hook-pluginsrcmainwebapp holds the hook's web source code. if you're familiar with creating hook plugins using the plugins sdk, you've probably noticed that maven uses a different the following table illustrates the differences in location of the java source and web source code for a maven project and a plugins sdk project you now know how to create liferay hook plugins to customize liferay deploying liferay plugins with maven;;
as a developer, you know that developing any kind of app without an overall design goal and plan to implement it is a recipe for disaster. you need to decide some things upfront. the liferay guestbook app needs a straightforward way to do three things to authenticate users, all you need to do is insert and configure login screenlet comes complete with its own ui. authentication, therefore, like with liferay portal itself, is done for you you must, however, create the ui for displaying guestbooks and entries. sort of ui would be best for this? although the best ui for any purpose is a matter of opinion, displaying guestbooks and entries in a list is a good choice. lists are common, compact design elements familiar to mobile users. mobile devices don't have room to display a list of guestbooks and a list of entries at the same time, you also need a user-friendly way to display and it makes sense to show the first guestbook's entries automatically after the user authenticates. this is similar to the guestbook portlet's design it shows a list of the first guestbook's entries by default. when the user selects a different guestbook, you can then use the same ui to show the selected guestbook's entries instead figure 1 by default, the first guestbook in the portlet is selected you must also decide how the users can select different guestbooks. list of guestbooks in a navigation drawer that slides out from the left side of a navigation drawer is easily hidden and is a to display these lists of guestbooks and entries, you'll create your own screenlets guestbook list screenlet and entry list screenlet. screenlet needs to retrieve guestbooks from the portlet and display them in a once written, using this screenlet is a simple matter of inserting entry list screenlet needs to retrieve and display a guestbook's entries in a similar list. you'll display the entries by inserting entry list screenlet in the ui element where you want it also note that these screenlets are list screenlets. screenlets by using the list screenlet framework, which sits on top of the core the list screenlet framework makes it easy for developers to write screenlets that display lists of entities from a liferay portal now you have a basic ui design and know the screenlets you'll create to but where in the app can you use these screenlets? contains one empty activity, mainactivity, which you'll use for authentication to use your custom list screenlets, you'll need to create an additional activity and a fragment guestbooksactivity and you'll create the activity in a moment figure 2 the liferay guestbook app's design uses two activities and a fragment. in this diagram, each activity and fragment is labeled, along with the screenlets and the navigation drawer in addition to showing the app's components, this diagram shows how the user after sign in, the user transitions to this activity uses entry list screenlet in entriesfragment to display the selected guestbook's entries the first guestbook is selected by default. pressing the hamburger button at the top-left of this screen opens the navigation drawer, where guestbook list screenlet displays the list of guestbooks. selecting a guestbook closes the drawer to reveal that guestbook's entries. note that you only need one activity, guestbooksactivity, to display guestbooks and entries. and entriesfragment are part of this activity now you're ready to create guestbooksactivity. fortunately, android studio has a template for creating an activity that contains a navigation drawer. these steps to create guestbooksactivity with the navigation drawer template right click the package url and select new activity navigation drawer activity to launch the new name the activity guestbooksactivity, accept the defaults for the remaining fields, and click finish after android studio creates the activity, the guestbooksactivity class and url layout open in the editor. don't need to edit these files yet now you understand the liferay guestbook app's design. next, you'll authenticate users by adding login;;
"now that you've generated your persistence framework, its time to integrate it into your jsf guestbook so you can use it. on the persistence side of things, service builder has generated all the basic functionality you'll need for the the next step is defining the service layer, which is the buffer between your controller and your persistence layer before you get started defining the service layer, there's one additional thing you'll need to add to your url file. slightly different implementation of its service layer compared to the mvc portlet, so we'll need to account for that slight change in the way your open your jsf guestbook's url file. expand the guestbook entity and click on finders click the button to the right of the list of finders and name the new finder name and give it the return type collection expand the name finder and click on finder columns. click the build services button from the top right of the screen. this, you'll rebuild the services you built previously the new finder you created will aid in finding a guestbook table by name, instead of solely relying on its groupid. you'll use this finder in the next the next thing you'll need to do is implement a service layer for your guestbook entity; after that, you'll implement a service layer for your builder has generated several stub classes for each entity. url class is your implementation for local services, whereas the url class is your implementation for remote you'll customize in the service layer of your application. methods from here not directly, but exposed via a -util class, and the methods here call your service layer. you'll learn about the controller and how you'll implement the simplest methods first. exposing methods from the persistence layer in your service layer. following two methods to guestbooklocalserviceimpl notice that the work of actually going to the database and finding your guestbook entities has already been done for you all you're doing is in a sense, you're creating your own api for the first method gets all the entities that match a given groupid, and the second method does the same thing, but includes start and end markers to paginate the data now you're ready to create a method that adds guestbook s to the database. add the following method to your class this method retrieves a guestbook name and assigns it to the guestbookid then, that guestbookid is used to add a guestbook to the you'll need a method that grabs and returns the first guestbook by name. ensures that the portlet is displaying a guestbook when a user views the the guestbook portlet will always have a generic main guestbook if no custom made guestbooks are found. add the following method to return a press ctrl-shift-o to add and organize the class' necessary imports you've successfully created a service api to retrieve and add to enable it, you must run service builder again. it'll generate the methods you just created in your service layer's interface next, you'll create similar methods to add guestbook entries now that you've written a service api for guestbooks, you'll need to do the same thing for your guestbook entries open the entrylocalserviceimpl class, which is located in the create two methods for finding guestbook entries. you created required two fields a groupid and a guestbookid create a method for adding guestbook entries. method you created earlier for adding guestbooks create a method for returning the number of guestbook entries that you've once again, you'll need to run service builder to generate the methods you just created in your entrylocalserviceimpl class, for your service layer's you now have a fully functional service api for the guestbook and the next step is creating managed beans which will make use of";;
first, you'll need to identify the theme elements you want to make configurable. in the case of the lunar resort, you want to make the breadcrumbs, portlet borders, and page title elements configurable now that you know the elements you want to give administrators control of, you making configurable theme settings involves a multi-step process. need to add the theme settings to url open your url located in your docrootweb-inf add the following code below ftl the code you just added identifies the theme settings for the theme. setting has a few attributes in common. the configurable attribute defines whether the setting is configurable by the user. key refers to the language key that identifies the theme setting. the options for the select menu. type refers to the type of ui to render finally, the value attribute sets the default value for the theme setting although you can create custom theme settings using your own key, you can also make existing theme settings user configurable. portlet-setup-show-borders-default is an existing theme setting that has been made user configurable for the lunar resort save the file and wait for the changes to publish sign in to the portal as an admin and navigate to admin select the settings drop-down panel. figure 1 the settings panel allows you to set theme settings for the entire site the steps you've completed so far have added the custom theme settings to the look and feel menu for the theme. in order to make them actually work, you'll have to assign their values in url.;;
so far you've added the theme settings to the look and feel menu in liferay. in this section you'll add the logic to the theme settings open url and insert the following code the code you just added assigns freemarker variables to the theme settings the theme settings are accessed by their key that was assigned in url, using the following portlet-setup-show-borders-default is not assigned a variable because it is a default theme setting that already exists. condition to display the theme elements in url now if showpagetitle is set to true, the page-title element is rendered, and if it is false, the element is not rendered, and instead the no-page-title class will be used for additional styling, when the theme is made responsive if showbreadcrumbs is set to true, the breadcrumbs are included on the page, and if it's set to false the breadcrumbs aren't included on save the file and wait for the changes to publish now if you go to the settings menu in site administration, you can configure the settings for the theme and see your changes. in the next section you'll learn how to set theme settings for an individual page.;;
"for most pages, you'll set the default theme settings so they work for the for some pages, however, you may want settings different this is where individual page settings come into play follow these steps to configure the theme settings for the welcome page navigate to the welcome page for the theme and sign in as an select the edit button and go to the look and feel section click the radio button to define a specific look and feel for this page verify that show breadcrumbs is already reload the page to see the changes you made you'll notice that show-page-title matches the key that was set up in url, while the other theme settings do not; this is because they are using language keys. as a best practice you should configure all your theme settings to use language keys. folder, you'll find the url file inside the this file holds all the english language keys that in order to include a language key for show-page-title you'll need to create a";;
to create custom language keys, you must create a hook plugin to modify follow the steps below to create the hook open idedeveloper studio and goto file new liferay set the project name as language-key-hook and display name as set the proper sdk and runtime, select hook for the plugin type, and the foundation for the hook is created. next you need to configure the hook. this case, you'll modify the english us language properties, but the same process can be used to hook into any existing language properties file right-click the language key hook you just created in the package explorer on the left and select new liferay hook configuration with language-key-hook set as the hook plugin project select language properties for the hook type and click next leave the default content folder and click add enter url for the property file, click ok and if it doesn't, open the docrootweb-infsrc folder of the language-key-hook and open the url file in add the following language key to the file and save it deploy the language-key-hook to the server and wait for the changes to once the changes have published, click the edit button and open the look the show-page-title theme setting is now using the the theme settings now all have language keys! the learning path you'll expand your css further by making the lunar resort theme responsive to mobile devices.;;
designing a theme is a challenging process, especially when you take responsiveness into consideration. how will your theme look on a desktop how will it look on a phone or a tablet? questions you need to keep in mind while designing your theme. you'll explore how to adapt your theme to respond to the aspect ratios on making your theme responsive can seem like an overwhelming task at first glance, but don't worry liferay provides you with the tools you need to get the job thanks to liferay's preview feature, adapting your theme for different devices takes only a few steps.;;
"to determine what changes need to be made, you can use liferay's preview window to see how the theme responds with the existing css styles. icons on the left side of the screen. underneath the plus icon, you'll see a screen icon this is the preview button figure 1 you can open the preview menu to preview your portal in other devices click the preview button to bring up the preview window. the page scrolled all the way to the top before clicking the preview button. failing to do so may result in the preview window being out of view inside the preview menu, you can see four pre-defined render options, as well as by default you see your site in the smartphone a good rule of thumb is to work organically, starting with the desktop view you're used to and previewing your theme on smaller and smaller devices. the end of this section you'll understand why this is true. each device displays the site in portrait view by default. the tablet preview a second time, you'll see that your site is now clicking the current preview a third time returns your view back to portrait scroll through the theme in the preview window and you'll see the elements first of all, the carousel is outside the borders of the page, so it should second, while the navigation is functional, it's not very tablet friendly, so you need to change it. looks okay, it could be scaled down some figure 2 you can identify the elements that need modified in tablet view using the preview window as a best practice, you should also see how the theme responds in landscape switch to landscape view to verify that the same elements need modification now that the theme has been tested on the tablet, you can see how it select the smartphone preview to view it scroll through the site in the preview window to see how it responds on a now in the smartphone preview, you can see that the same concerning areas on a tablet are more obvious in this preview the logo is too large and needs to be scaled down; the navigation is even more squeezed than before; the carousel is even further beyond the borders of the page and definitely needs to be removed everything else seems to be responding well. figure 3 viewing the theme in the phone's landscape and portrait views clearly shows the areas that need modifed now that you have identified the elements needing modification for responsiveness, you can move on to the next section.";;
"with the theme elements identified, you can now add the css to make them responsive for phones and tablets open url and add the following code to the bottom of the file, after now if you preview your theme on the tablet and phone you'll see that all the the logo has been scaled down and repositioned to better fit the tablet and phone; the main navigation bar now uses the following code to hide itself display none;.... handled with.open, and can be accessed by selecting the hamburger button next in the top right corner. finally, the carousel has been removed in both the tablet and phone views sass mixins were used to tell the css to respond to the correct devices. instance, the respond-tophone, tablet mixin is used to wrap the styles that are shared for both the phone and tablet devices. good to work organically for responsiveness. by starting off with the tablet device and moving down to the phone, you are able to figure out what elements have shared render issues and can then update them for both the phone and the respond-tophone mixin is then used to wrap the remaining styles that are unique to the phone only figure 1 with the updates to the css, the theme now responds well to the smartphone";;
you've learned how to build a theme from start to finish. now that you've created a theme, you can publish it to liferay's marketplace for others to download. can read about marketplace and the requirements for publishing in our before you publish your theme to marketplace make sure you update your url file for the resources importer so it can run properly in a production environment. follow these steps to configure your open the url file in the web-inf folder of the theme and set the developer mode property to false the theme resources will overwrite the existing portal resources only on now that developer mode is disabled, you'll need to uncomment the required-deployment-contexts remove the following code from the file this ensures that the resources will be imported into the site template by as you can see, theme development is a multi-headed beast, but with careful planning and a thought out process you can tame it and develop;;
"all of the guestbook admin portlet's back-end code is developed; the only thing left to do is create the portlet's user interface. a button for adding new guestbooks, and it should also display a list of the guestbooks that have been added to the site figure 1 the guestbook admin's ui will contain buttons to add, edit, delete, and control permissions of guestbook entities each guestbook should also be accompanied with the action buttons edit, delete, you'll begin by creating the buttons, then you'll check for the first thing you'll do is configure the existing url file to facilitate the ui's similar to the original url, this view will serve as the navigation view, checking boolean properties in the guestbookbacking bean, and displaying the appropriate view according to those property values open the url file and replace the contents within the... tags with the following this view checks the guestbookbacking bean for the editingguestbook if the property is true, the guestbook view is displayed. it's false, the guestbookactions view is displayed. editingguestbook property is set to true when the edit button is clicked, meaning the guestbookactions view is always displayed, unless the edit button has been clicked. also notice you didn't have to create a nice convenience when using jsf views now you'll need to create your guestbookactions view, which acts similarly to your original guestbook portlet's master view right-click the viewsguestbook-admin folder and select new give the file the name url and click finish the first thing you'll need to do is add the necessary xml version and element into the url file, similar to what you completed for your other views within the... tags, add the add guestbook button code into the guestbookactions view. make sure to surround the button with... tags this is the exact same code that was already present in your remove the element you added in step 4 from the master view, so the add guestbook button is only accessible from you guestbook admin directly below the tag under the command button for adding a guestbook, add the following code to create your guestbook's action buttons all three of your action buttons for guestbooks are now available in your they are formatted in a datatable. delete buttons call the guestbookbacking bean action methods you created the permissions button calls the permissionsurl property you created in your guestbook wrapper class now that your buttons are created and your guestbooks are displayed in a table, redeploy your guestbook-jsf-portlet project and visit your guestbook admin it should look similar to figure 1 in this section. guestbook button should no longer be present in your guestbook portlet your buttons are all available, but you have not configured the buttons' in the next section, you'll configure the permissions the last thing you'll need to do to have fully functional action buttons for your guestbook entities is to utilize your guestbook wrapper class' you'll need to check each button for its corresponding for instance, the delete button will need to call the deleteable property from the deleteable property is true if the user has the appropriate permissions to access the button. the property is set using the getdeleteable method from the guestbook wrapper class, which checks for the user's permissions. add permissioning to your action buttons, open the guestbookactions view and find the action buttons you created previously in the data table for each of your entry buttons, surround each individual... or... contain the rendered element specifying the appropriate permission to check below is how your entry buttons should look after you're your action buttons are now configured with permissions, which are controllable your guestbook admin portlet is fully functional and allows administrators to control your guestbook portlet's";;
previously, you built the framework for the theme and imported the content for the end result may have seemed a little underwhelming. your work left you with what appeared to be an un-styled theme. your hard work was not for nothing. in this section of the learning path you'll create the css that styles the theme elements you created in the previous;;
before you add the css for your theme, you'll need to complete some preliminary open url in your diffscss directory you'll add the css piece by piece, just as you saw in the html picture in the last section of the learning path. figure 1 the html is broken up into sections it's a good practice to add a roadmap to your css file before you start, to keep things organized as you go along replace the contents of url with the following code liferay supports sass syntactically awesome style sheets. nest similar styles together, keeping your code concise and well organized. also allows you to use variable declarations in your css, making it easier to you can read more about sass here in addition to the map, some initial styling has been added for the background of the site, edit controls, dockbar, as well as some imports. compass and mixins imports, url has been imported so that you can use the variables in url later on the styling that has been added to the body of the site adds a gradient to the background and preserves the default styling for pop-up windows with the ground work laid, you can start with the wrapper's styling next.;;
"the wrapper is the container that holds the theme's elements. positioning and styling the theme as a whole. you'll use the wrapper to create the dimensions and background for the theme add the following code below the wrapper placeholder since the banner, content, and footer sections all go inside the wrapper, add the closing brace for the just above the closing at the the css above makes use of the sass bkcolor variable to color the background of the wrapper, separating it from the background gradient. important, it sets the width and margins for the theme as a design choice, the wrapper has been given a set width, max-width 1000px;, and centered, margin 0 auto;, relative to the browser. allows the gradient background to show when the browser is wider than the if users view the theme in a larger display than the max-width, they won't be greeted with dead pixels on either side of the you always want to keep the user experience in mind when using the max-width property sets the width, while also allowing it to be in a later section of the learning path, this will let the theme scale down for smaller devices. had the width property been used instead, the width would be carved in stone save the file and navigate to the welcome page and refresh it to see the your theme should look like the following figure figure 1 the theme is starting to take shape now that the wrapper for the content is styled, you can move on to the";;
the banner holds all the elements in the theme's header. is the first thing users see when they visit your site add the following code to url below the banner placeholder the navigation has been formatted in a list and spaced further down from the it has also been placed in a red bar to match the color of the logo. further relate the navigation's color to the rest of the theme, the navigation items have been given a blue background when active and on hover. the links in the activities drop-down are hidden by the carousel. your theme should now look like the following figure figure 1 the updated navigation bar brings the banner together and completes the header you can move on to the content styling next.;;
the content is used to position and set the dimensions for the theme's currently the content is pressed right up against the edge of the wrapper, giving the theme a claustrophobic feel. content a little breathing room add the following code to url below the content placeholder this adds some padding between the edge of the wrapper and the content it also creates styles for some web content articles on the welcome page and removes the portlet icons from the bordered portlets the carousel has been given some styling as well. some spacing has been added between the breadcrumbs and the carousel. carousel has also been given a z-index of 0, so the navigation shows save the file and navigate to the welcome page save the file and refresh the browser. sometimes, you may need to redeploy your theme should look similar to the figure below figure 1 the content is clearer to read now that the there is some padding you can move on to the footer's styling next.;;
"as you create a theme, you want to keep the whole picture in view. can be seen as the bow that nicely wraps the finished package. mind, it's good to find a way to unify the theme with the footer's design; in this case, its look is matched to the navigation bar's add the following code to url below the footer placeholder the footer is now styled to match the navigation bar and padded to give its the'powered-by' link has also been given a text color to the footer's content is sparse at the moment, but this will change later in the learning path up to this point you're styling has been focused on the macro picture, dealing with the larger elements of the page. next you'll explore the micro picture a bit and focus your styling on an individual portlet.";;
"if you click the make your reservation link, the site presents you with a reservation form, along with the guestbook portlet from the the guestbook portlet is looking pretty plain at the moment. it can be styled just like any other element on the page; you just need to know the existing classes to override sign in as an admin and click the make your reservation! link at the bottom click the gear icon on the guestbook portlet and select look and feel select the advanced styling tab at the top of the dialog window at the top of the section you'll see a box highlighted in blue that reads your current portlet information is as follows figure 1 you can view a custom portlet's class in the look and feel configuration menu now you can see that the class for the guestbook portlet is.guestbook-portlet. it follows an easy pattern.project-name. write all your css for the guestbook portlet here in the advanced styling section, but to keep things organized, you should place the styling in url with the rest of the styles open url and add the following code above the closing for the this gets you most of the way there, but the styling could use some more the background matches the color of the theme's navigation and footer, but the text is unreadable in the table's first entry. added any entries to the guestbook, you won't see the table elements. ahead and add a couple entries to the main guestbook if you haven't you should now see the table for the entries. can see the red background is a bit jarring with the second entry link. order to make the needed changes to the rest of the guestbook styles, you'll need to know the elements or classes most browsers allow you to inspect the elements of the page to view the using the built-in browser tools, you can retrieve the rest of the right click on the table and select inspect element a new area appears, showing the html for the page. is a table element with a th element for the column names and td elements for each of the columns in the rows. add the following code for the guestbook below the padding 30px; style and some additional styling has been added for the guestbook portlet's title and search bar using the classes found in the browser's inspector. to the styling, the guestbook portlet should look similar to the figure below figure 2 the guestbook portlet's styles now complement the theme in the next section you'll learn how you can use bootstrap markup and styles to give your theme's ui a consistent look.";;
since liferay portal 6.2, themes are based on bootstrap 2.3.2. common markup such as buttons, forms, and layouts, it is recommended that you let bootstrap handle the styling for you you can view bootstrap's base css here you may have not been aware, but some of the web content articles you imported with the theme are using bootstrap markup styles. the reservation form, you'll see bootstrap's classes this form follows bootstrap's horizontal form the form inputs are extended even further, using bootstrap's invalid for example, by setting the type for the e-mail input to email you are able to get validation for the field! bootstrap makes it easy for you to get a consistent look to your theme's ui in a a step-by-step approach to css allows you to handle it with ease and keep track in the next portion of the learning path you'll create the social media links for the lunar resort.;;
the puzzle pieces are falling into place. you've built the theme, imported resources, and customized the look and feel of it with css. to use the icons that come bundled with liferay to create the social media links bootstrap and font awesome icons come bundled with liferay, making them a prime each library of icons offers a unique sampling to in either case, you access the icons by setting your element's class to the corresponding icon name all the available bootstrap icons, along with their names, can be found in likewise, you will find the list of available font awesome icons, along with their names, in their github repository in this portion of the learning path, you'll leverage some of font awesome's icons to create the social media links for the lunar resort. choice you could use bootstrap's icons using the same methods.;;
follow the steps below to add the social media links to the footer add the following code inside the tag, above each social media link uses a font awesome brand icon. one set of icons where the brand logo is in a fixed position, made up of this lets you move the logo and border around as a whole, but does not give you control over the position or styling of the figure 1 font awesome brand icons can have the logo made up of empty pixels one set of icons where the brand logo does not have a border. to position and style the logo and create the border yourself figure 2 font awesome brand icons also offer logos without borders for the purposes of the social media links, you need control over the background icon's trademark f logo you can see that it is made up of empty pixels. because the icon's logo is made up of empty pixels, the footer's background color shows through the logo, which in this case red, doesn't fit the design using the second option, the borderless brand icon, the brand logos are given they're then placed within tags, which are given styling to color the background. this allows you to position the logo with its own color, while also letting you control the size and color of now that the social media links are in place, you can add the css for them open url and place the following code below the.powered-by save the file and wait for the theme to republish load the welcome page and you'll see your new social media icons have been placed in the footer just below the follow us heading congrats! the footer is finished in the next portion of the learning path you'll learn how to make configurable theme settings for the lunar resort.;;
theme settings allow you to give administrators control over the elements of the page without having to touch any of the code directly theme settings can then be modified on a site-wide or a page by page basis. a few simple clicks of the mouse, an admin can remove and add theme elements now that you know what theme settings can provide, you can learn how to;;
in this section, you'll configure the url file open the url file in the web-inf by default, developer mode is enabled with the following line of code theme resources overwrite the existing portal resources on every you should leave this property enabled during development of the theme, but it should never be on in production. theme will be imported directly into the site, and not a site template, you need to add two additional properties add the following code to the bottom of the file the first property sets the type of portal entity to write the resources to, which is the site in this case. the second property sets the name of the portal entity to write the resources to, which is set to the guest group in this case, so the resources will be visible on the public pages. important to note that you should never set the property in a production environment. property, which will import the resources to the site template uncomment the following code and save the file this requires the resources-importer-web plugin to be installed in order for if the resources-importer-web is not installed, the theme will be placed on hold until the plugin is installed. all of the resources are ready to be deployed with the theme redeploy the lunar resort theme and refresh the browser to see the changes your theme should look like the image below figure 1 the resources importer adds pages and content to your site now that your theme has these initial pages and content, you can disable the if you don't do this, the pages, web content, and documents will be reimported unnecessarily and asset reference issues can occur when you to disable the resources importer follow these steps comment out the following properties from the your theme project is ready for more development as you can see the resources importer is not too complicated once you break down the individual pieces, and it serves as an effective way to stage your theme in the next portion of the learning path you'll learn how to style your theme using css.;;
you've created the theme for the lunar resort, but it's looking pretty empty at you need some default content to go with it, so it looks nice when there are a couple methods you can use to import resources you can create an url file, which imports the lar with the theme, or you can create a url file to hold your layout and populate your content from a directory structure both methods are good options, but there are some disadvantages to using the lar lars are version dependent, so upgrading to a new version of liferay also any changes made to the content require the lar the url on the other hand works in any version of liferay. you can thus implement changes with a simple redeploy in this section, you'll learn how to use the resources importer with the lunar in order to import content with the resources importer, you'll need to create the proper directory structure first.;;
recall that when using a screenlet, the app developer primarily interacts with the screenlet class contains attributes for configuring the screenlet's behavior, a reference to the screenlet's view, methods for invoking interactor operations, and more. this article shows you how to create entry list as with most of entry list screenlet, its screenlet class is almost identical to that of guestbook list screenlet. besides working with entries instead of guestbooks, the only difference is that it must know its entries' guestbook id. even the screenlets' attributes are the same therefore, this article doesn't explain all the code in detail. placed on the few parts that differ from guestbook list screenlet. to see the article on creating guestbook list screenlet's screenlet class you'll create entry list screenlet's class with the same steps you used to create guestbook list screenlet's class define the screenlet's attributes. these are the xml attributes the app developer can set when inserting the screenlet's xml. control aspects of the screenlet's behavior this class implements the screenlet's functionality defined in the view and interactor. values and configures the screenlet accordingly first, you'll define entry list screenlet's attributes recall that before creating the screenlet class, you must define the attributes the app developer needs to control the screenlet's behavior. screenlet, like guestbook list screenlet, only needs a groupid attribute. your app's resvalues directory, create url and replace its next, you'll create the screenlet class entry list screenlet's class must contain an instance variable for the id of the guestbook the screenlet retrieves entries from. this is the only significant difference between the screenlet classes of entry list screenlet and guestbook list screenlet. differences exist only because they handle different entities create the entrylistscreenlet class in the entrylistscreenlet package. replace the class's content with this code the instance variable for the guestbook id is guestbookid. setter methods getguestbookid and setguestbookid let the app developer get and set this variable, respectively. the loadrows method starts the interactor by calling the start method with guestbookid as an argument. scenes, the list screenlet framework passes guestbookid to the interactor's getpagerowsrequest and getpagerowcountrequest methods via the args this is why you were able to extract guestbookid from the args for an explanation of how the rest of this screenlet now you're ready to use entry list screenlet alongside guestbook list the following section of this learning path concludes with both screenlets working together in harmony.;;
"now that you have the guestbook list and entry list screenlets, you're ready to as you'll see, using these screenlets isn't much more difficult than using login screenlet. this is an advantage of screenlets; it typically takes only a few minutes to get them up and running. integrate with the rest of your app's ui to add your screenlets to the app, you'll follow these steps understand how guestbooksactivity's ui works. this ui instead of replacing it, you should first understand how it works prepare guestbooksactivity for guestbook list screenlet use guestbook list screenlet by inserting it in guestbooksactivity create entriesfragment for entry list screenlet. guestbooksactivity to display this fragment when a guestbook is selected in use entry list screenlet by inserting it in entriesfragment if you get confused or stuck at any point in this section of the learning path, refer to the finished app's code first, you'll see how guestbooksactivity's ui works.";;
recall that you used android studio's navigation drawer activity template to any activity this template creates contains a navigation drawer and all the components the activity needs. layout files that display content. currently, these files contain simple you'll replace this content shortly with content from your before doing so, however, you should know where the placeholder content exists in the project's structure and how the app displays the app's ui is defined by three layout files that combine to display the app's url the activity's main layout file. defines the navigation drawer and includes the appbarguestbooks layout. the latter appears when the navigation drawer is closed url defines the action bar app bar and includes the url defines the activity's main content, which appears first, you'll learn how url works first, open guestbooksactivity's main layout file, url. this file should look similar to this one this isn't much code considering everything that's in guestbooksactivity. navigationview and its parent drawerlayout define the navigation drawer. attributes in navigationview define the drawer's contents appheaderlayout the appheaderlayout value navheaderguestbooks specifies that the layout url renders the activityguestbooksdrawer specifies that the menu in url creates the drawer's items. navigationview, the include statement adds the layout url as the content shown when the navigation drawer is the following diagram illustrates how url maps to figure 1 the url layout defines the app's main ui components the activity's main content also contains a toolbar the action bar, some text, next, you'll see how these are defined it should look similar to this the appbarlayout and toolbar elements define the toolbar at the top of the following the toolbar definition, the include statement adds the contentguestbooks layout to appbarguestbooks. layout defines the content displayed in the activity's body below the toolbar. right now, this layout only contains an empty constraintlayout element. its contents should look similar to this anything you define in this layout becomes the activity's main body content. later, you'll return to url to display the guestbook entries retrieved from the guestbook portlet floatingactionbutton to define the floating action button. containing placeholder content up from the bottom of the screen. won't do anything with the floating action button in this learning path, you'll when you finish this learning path, you may want to test your liferay mobile development chops by adding functionality to this button the following figure illustrates how the appbarguestbooks layout maps to the on the left, this figure lists each ui component in each arrow points to the component's rendering on the figure 2 the layout url defines the activity's main content now you know which layout files in the project define the app's ui. also know the exact ui components these files define. guestbooksactivity for guestbook list screenlet.;;
"recall that you want guestbooksactivity to display guestbook list screenlet before using these screenlets, however, you must prepare guestbooksactivity as follows refactor the action bar so you can later set its title to the selected refactor the navigation drawer so you can later close it when a guestbook is selected in guestbook list screenlet delete the navigationview.onnavigationitemselectedlistener implementation. since guestbook list screenlet handles guestbook selections, you don't need when you finish, you'll be ready to use guestbook list screenlet. won't always have to take steps like these before using screenlets. so here to fit this particular app's design first, you'll refactor the action bar by default, the action bar displays the activity's name. list screenlet, you want the action bar to display the selected guestbook's name you'll enable this by modifying the code that creates the action bar. android studio created this code for you in the guestbooksactivity class's although you could edit it, you'll instead create a separate method that creates the action bar. worry about the now missing toolbar variable in oncreate; you'll fix it create actionbar and toolbar instance variables. this requires that you import url.actionbar add the following initactionbar method to guestbooksactivity like the code you removed from oncreate, this method also creates a toolbar and sets it as the action bar. it also sets the action bar's title this prevents the activity's title from showing in the action bar before the app can retrieve guestbooks from the portlet call initactionbar in oncreate. place the call immediately below the the first few lines of oncreate should now look next, you'll modify the code that controls the navigation drawer before you can use guestbook list screenlet in the navigation drawer, you must refactor the drawer's existing code. do so now by following these steps currently, the navigation drawer initialization code is in the oncreate android studio created this code for you when you used the navigation drawer activity template to create guestbooksactivity. instead, you'll initialize the navigation drawer in a separate method that you'll create this method shortly you'll also change the drawer variable to be an instance variable that you can refer to throughout the class. this lets you use this variable to close the drawer when a guestbook is selected in guestbook list screenlet. this variable to guestbooksactivity add the following initdrawer method. this method's contents match the drawer initialization code you deleted in oncreate, except that drawer in the oncreate method, place the call to initdrawer immediately below also, because you want to use the same drawerlayout instance throughout the class, delete the line of code that creates a new drawerlayout in the your onbackpressed method should now look like now you're ready to delete the navigationview.onnavigationitemselectedlistener the next section walks you through this since guestbook list screenlet handles navigation drawer item selections, you don't need to implement navigationview.onnavigationitemselectedlistener in follow these steps to remove this implementation delete the implementation from the class declaration. remove the code in guestbooksactivity that implements the following code at the end of the oncreate method your oncreate method should now look like this delete the onnavigationitemselected method, along with its and statementwithemptybody statements finally, remove the url.navigationview import now you're ready to insert guestbook list screenlet in";;
the steps for using guestbook list screenlet are the same as those for using any insert the screenlet's xml in the activity or fragment layout you want the implement the screenlet's listener in the activity or fragment class recall that you used these steps to insert login screenlet in mainactivity. first, you'll insert guestbook list screenlet's xml in guestbooksactivity's recall that url defines guestbooksactivity's ui. recall that the navigationview in url defines the to put guestbook list screenlet in the drawer, you must insert the screenlet's xml in the navigationview. placeholder content from the navigationview. the navigationview in url with this code compared to the navigationview it replaced, this navigationview contains guestbook list screenlet's xml and lacks the appmenu attribute. this attribute pointed to the menu resource file that creates the drawer's since the screenlet now handles the drawer's items the guestbooks, you don't need appmenu or the menu resource file. you also don't need the drawable resources that android studio created for the navigation drawer's placeholder delete url, and each of the icmenu.xml returning your attention to url, note that guestbook list screenlet's xml strongly resembles login screenlet's xml. androidid value that you can use in the activity to get a reference to the both also use a layoutid attribute to specify the screenlet's view. guestbook list screenlet's xml, however, differs by using the navheaderheight, pads the top of the screenlet by the height of the navigation drawer's header section. this prevents the screenlet and drawer next, you'll implement the screenlet's listener interface in to use a screenlet, you must implement its listener methods in the class of the activity or fragment where you want the screenlet to appear. these methods depends on how you want the screenlet to function in your app. example, when you used login screenlet you implemented loginlistener in you implemented this listener's onloginsuccess and onloginfailure methods to display a message to the user. onloginsuccess implementation to navigate from mainactivity to since these methods are void, however, you could have obviously this wouldn't have made for a very useful app, but it highlights an important point screenlet listener methods let the app developer choose how to respond to the screenlet's events. app developers can therefore control how the screenlet functions with their app before implementing guestbook list screenlet's listener, however, you should add a method that the listener methods can use to help display a guestbook and its you might now be thinking, i thought you said screenlets contain their why does the activity need special methods for displaying the although a list screenlet's ui displays the list of entities, the rest of the app's ui must still account for that list. list screenlets don't include an action bar, but you should still change the action bar's contents to reflect what's on the when a guestbook is selected in guestbook list screenlet, the action bar should display that guestbook's name. you can accomplish this by calling a method that takes a guestbookmodel and sets that guestbook's name as the follow these steps to add this method and implement the listener add this showentries method to guestbooksactivity this requires you to import url.guestbookmodel. method is called showentries because you'll also use it to display the guestbook's entries via entry list screenlet you'll add this code later. you'll call this method in the listener methods you'll implement to process recall that guestbook list screenlet doesn't need any custom listener it can use the listener methods defined in the list screenlet change guestbooksactivity's class declaration to implement the class declaration should now look to implement baselistlistener, you must implement the following methods onlistpagefailedint startrow, exception e called when the server call to retrieve a page of items fails. this method's arguments include the exception generated when the server call failed. this requires you to import url.toast called when the server call to retrieve a page of items succeeds. that this method's arguments include the list of objects retrieved from the server entries , and the page's start row startrow , and end row recall that by default, you want the activity to display the you'll use this method to do so because it receives the guestbooks from the server. endrow change for each page, a startrow of 0 corresponds to the first guestbook on the first page. use an if statement to select this guestbook, and then call showentries this requires you to import url.list onlistitemselectede element, view view called when the user selects this method's arguments include the selected list to process the guestbook's selection, call showentries also, close the navigation drawer following the because baselistlistener extends the the activity must also implement basecachelistener's error method. method lets you respond to an error alongside the user action that caused in this app, you don't need to do anything in this method, so you can now that you've implemented the listener methods, you must set guestbooksactivity as the listener. guestbooklistscreenlet id that you set in the screenlet's xml comes in add the following code to the end of the activity's oncreate this code first uses the id guestbooklistscreenlet to get a reference to it then sets this guestbooksactivity instance as your app's guestbooksactivity now contains guestbook list you're almost ready to use entry list screenlet. however, you must create a fragment to put it in.;;
using a fragment for entry list screenlet lets you swap out part of guestbookactivity's contents without recreating the entire activity from scratch each time a guestbook is selected. your app doesn't currently have any in this step, you'll create a fragment and then add it to when you finish, you'll be ready to use entry list follow these steps to create the fragment to create the fragment, right click the url wizard, check only the box to create the layout xml, name the fragment entriesfragment, and then click finish. figure 1 create a new blank fragment for the entries this creates the entriesfragment class and its layout file replace the class's contents with this code if you have experience with android fragments, then you're likely familiar with the static newinstance method. in short, using such a method instead of an empty constructor lets you create the fragment and initialize its data this makes it easier to create and restore the fragment. since this fragment will contain entry list screenlet, its data must include the guestbook id the screenlet retrieves entries from guestbookid . the oncreateview method uses the bundle arguments set in newinstance to for now, you don't have to do anything with the you'll use this variable when you add the next, you'll add this fragment to guestbooksactivity now that entriesfragment exists, you can add it to guestbooksactivity. this, you must put an android fragment container in the layout where you want android's documentation on adding fragments at runtime. since you want entry list screenlet to appear in guestbooksactivity, your first thought might be to put the fragment container directly in navigation drawer activity template created the layout url to hold the activity's main body content. you'll add the fragment container to this layout, then write the code in guestbooksactivity that displays the follow these steps to add the fragment to guestbooksactivity open url and place the following fragment container this fragment container should be the only other element inside the constraintlayout next, you must write the guestbooksactivity code that displays the fragment when a guestbook is selected in guestbook list screenlet. recall that you created guestbooksactivity's showentries method to process a list item selection in guestbook list screenlet. does right now is set the action bar's title to the selected guestbook's you'll add the fragment transaction to showentries, so a guestbook selection also shows that guestbook's entries. method in guestbooksactivity with this code this requires that you import url.fragmenttransaction this method's url call is the same as before. in it, you first use newinstance to create a new entriesfragment instance with the selected guestbook's id. transaction then adds this fragment to the fragment container now you have a fragment to put entry list screenlet in, and the code that displays this fragment in guestbooksactivity.;;
a blank resources-importer directory was created with your theme. add each file individually and create all the remaining folders, go ahead and delete the existing resources-importer directory the updated resources importer directory uses the following structure to organize the files for the lunar resort the theme's resources are organized into documents and media files and web structures and templates are given their own folders inside web content articles can be written in either html or xml and placed in the images included in the web content are referenced using the name of the file in the documentlibrarydocuments folder. content references the image using the following code that's all the prep work that needs to be completed for most web content. more advanced web content that requires structures and templates, there are a few additional steps you'll need to take for the carousel, the web content is added to its own folder, carousel inside the structure is then added to the finally, the matching template is added to the templates folder and placed in its own carousel folder. directory for the carousel matches the following structure it's important that you create the file structure this way so the web content now you can create the url file.;;
the url file defines the layout for the web content, pages, and as the file extension suggests, url uses json syntax, so if you are familiar with json you should be able to navigate your way through the sitemap fairly easy. if you are not familiar with json syntax, don't worry, the sitemap will be explained in further detail since the url file was already created when you copied the contents of the resources-importer folder, you don't need to do anything to implement. the code below adds a welcome and about us page using the default layout template and populates the pages with web content articles the sitemap starts out by defining a default layout template id for the pages. you can find layout template ids in the layouttpl folder in your liferay next, the pages, referred to as layouts in the sitemap, are organized. the page is then given a name, a title, and a friendly url next, the web content is organized under the columns section. to the columns in the layout template. since the welcome page uses the default 1column layout, the layouttemplateid doesn't need to be specified. the page uses a one column layout, the web content articles are all placed within the same set of brackets . as with an image in a web content article, you reference the web content by the name of the file in the resources the layout below adds an activities page with a rover racing child page and populates them with web content as you can see, to create a child page, you use the same layouts syntax that you would use to create a parent page. the layouts configuration for the child page is placed within the parent page's configuration the following code adds two portlets to the page and defines its own layout portlets are defined within the layout template columns like the web content articles, with just a slight variation in syntax. portlet id, which you can find in the url inside your liferay a layouttemplateid is set for the page because it does not use the default template id that was defined at the top of the sitemap the following code creates a page hidden from the navigation menu and adds a web content article and a custom portlet to the page portlet plugins are defined the same way core portlets, such as the web content display portlet, are defined, and their ids are defined in their own they follow an easy to remember pattern in order for the portlet to be assigned an id it you took care of this in the last section of the you should now have a better understanding of the url file. one last file to configure, url, which you'll;;
recall that in liferay screens for android, screenlet uis are called views, and every screenlet must have at least one view. in this article, you'll use the following steps to create a view for guestbook list screenlet this layout defines the ui for each row instance in that fills a row layout instance with the data for one list item. repeats for each list item until the list is full this class renders the ui, handles user interactions, and communicates with the screenlet class this layout defines the screenlet's ui as a whole. for a list screenlet, this is a scrollable list note that these are the same steps for creating a view as those in you'll create guestbook list screenlet's view in its own package inside the create a new package named view inside the now you're ready to create the row layout first, you must create the layout that defines the ui for each row instance in since each row in guestbook list screenlet displays only a single guestbook's name, the row layout only needs a single textview. layout file url and paste in this content note that the textsize and padding values result in clean, readable text for when you develop your own list screenlets, you can style your row in guestbook list screenlet, the layout is url the row layout and the content is a guestbook's name. make list scrolling smooth, the adapter class should use an to make this easier, you can extend the list screenlet framework's with your model class and view holder as type arguments. baselistadapter, your adapter needs only two methods your view holder should also contain variables for any data each row needs to the view holder must assign these variables to the corresponding row layout elements, and set the appropriate data to them inside the screenlet's view package, create the following guestbookadapter this adapter class extends baselistadapter with guestbookmodel and guestbookadapter.guestbookviewholder as type arguments. inner class that extends baselistadapter's view holder. screenlet only needs to display a guestbook's name in each row, the view holder the view holder's constructor assigns the textview from url to this variable. sets the guestbook's name as the textview's text. guestbookadapter leverage the view holder. the fillholder method calls the view holder's bind method to set the guestbook's name as the name variable's next, you'll create the view class recall that the view class controls a screenlet's ui. handles user interactions, and communicates with the screenlet class. screenlet framework provides most of this functionality for you via the baselistscreenletview class. your view class must extend this class to provide your row layout id and an you'll do this by overriding baselistscreenletview's getitemlayoutid and createlistadapter methods. baselistscreenletview you must do so with your model class, view holder, and this is required for your view class to represent your model objects in a view holder, inside an adapter create the guestbooklistview class inside the view package, and replace its this view class represents guestbookmodel instances in a guestbookviewholder baselistscreenletview parameterized with guestbookmodel, guestbookadapter.guestbookviewholder, and guestbookadapter. overriding createlistadapter to return a guestbookadapter instance, the only other functionality that this view class needs to support is to get the layout the overridden getitemlayoutid method does this by returning the row layout guestbookrow now you're ready to create your view's main layout although you already created a layout for your list rows, you must still create a layout to define the list as a whole. apart from the view class and styling, this layout's code is the same for all create the layout file url and replace its contents note that the androidid values in this layout xml are hardcoded into the screens framework and changing them will cause your app to crash you're done with guestbook list screenlet's view.;;
interactors are screenlet components that make server calls and process the interactors themselves are made up of several components the event class creates event objects that contain the server call's liferay screens uses these event objects via the library to communicate the results between the screenlet's components the listener interface defines the methods the app developer needs to respond to the screenlet's behavior. defines the onloginsuccess and onloginfailure methods. these methods when login succeeds or fails, respectively. these methods in the activity or fragment class that contains the screenlet, the app developer can respond to login success and failure the interactor class makes the server calls, processes the results in the event objects, and notifies the listener of those results since the list screenlet framework already contains two listener interfaces, you only need to create the event and interactor classes. follow these steps to create guestbook list screenlet's event class first, create a new package called interactor in the interactor's components in this new package a list screenlet's event class must extend with the screenlet's model class as a type argument. class contain the server call's results as model objects. screenlet's event class, guestbookevent, must therefore extend listevent with guestbookmodel as a type argument. the class declaration should look like this this requires you to import url.guestbookmodel and the event class should also contain a private instance variable for the model class, a constructor that sets this variable, and a no-argument constructor that calls the superclass constructor. you must also implement listevent's abstract methods in your event class. note that these methods support even though guestbook list screenlet doesn't support offline mode, you must add these methods to guestbookevent now for example, the getlistkey method in guestbookevent returns the guestbook's name getmodel unwraps the model entity to the cache by returning the model for example, the getmodel method in guestbookevent note that this code is almost identical to the example event class in the only difference is that guestbookevent handles guestbookmodel objects you're almost ready to write the first, however, you should understand the basics of how server calls work in interactors recall that interactor classes use the liferay mobile sdk to make server calls an interactor class does this with the following get the mobile sdk session and use it to create the mobile sdk service you invoke the mobile sdk service method that makes the server call create an event object from the json that the server call returns. screenlet has a model class, create a model object from this json, then use the model object to create the event object figure 1 this diagram shows a typical server call made by a screenlet's interactor. the dashed line around the model class indicates that it's optional. although list screenlets require model classes, non-list screenlets don't to call the guestbook portlet's remote services, you'll use the guestbook mobile sdk you built and installed earlier. this mobile sdk contains the services required to call the guestbook portlet's remote services. guestbook list screenlet's interactor class a screenlet's interactor class is the central component of the interactor. makes the server calls, processes the results in the event objects, and notifies provides most of the functionality that interactor classes in list screenlets you must, however, extend baselistinteractor to make your service calls and handle their results via your model and event classes follow these steps to create guestbook list screenlet's interactor class, create the guestbooklistinteractor class in the package interactor class must extend baselistinteractor with baselistinteractorlistener and your event class as type you must therefore change guestbooklistinteractor to extend baselistinteractor with baselistinteractorlistener and guestbookevent as type arguments this requires that you add the following imports override the getpagerowsrequest method to retrieve a page of entities. this method, you can use the getsession method to retrieve the session created by authentication with login screenlet. creating a service instance from the session and calling the service method guestbook list screenlet must retrieve a page of guestbooks, so you must create a guestbookservice instance from the then call the service's getguestbooks method with the groupid, the groupid specifies the site to retrieve guestbooks from, while the start row and end row define the list rows that mark the start and end of the page of guestbooks, respectively. getpagerowsrequest method to guestbooklistinteractor note that the groupid variable isn't set anywhere. baselistinteractor, like guestbooklistinteractor, inherit this variable you'll set it when you create the screenlet this getpagerowsrequest method requires that you add the following override the getpagerowcountrequest method to retrieve the total number of in guestbooklistinteractor, you retrieve the total number of guestbooks from a site by creating a guestbookservice instance from the session and then calling the service's getguestbookscount method with the groupid. getpagerowcountrequest method to guestbooklistinteractor override the createentity method to create and return a new event object containing the server call's results. converts the json that results from a successful server call into a the createentity method's only argument is this map, which you use to create a guestbookmodel object. object to create and return a new guestbookevent object. createentity method to guestbooklistinteractor this requires you to import url.map override the getidfromargs method to return the value of the first object add this method to guestbooklistinteractor this is a boilerplate method that returns a cache key for even though you won't add offline mode support to guestbook list screenlet, this method makes it easier if you decide to do so later your interactor class is finished. similar to the interactor class in the list screenlet creation tutorial your interactor is finished too. next, you'll create the screenlet class.;;
when using a screenlet, app developers primarily interact with its screenlet the screenlet class contains attributes for configuring the screenlet's behavior, a reference to the screenlet's view, methods for invoking interactor you'll use these steps to create the screenlet class define the screenlet's attributes. these are the xml attributes the app developer can set when inserting the screenlet's xml. control aspects of the screenlet's behavior this class implements the screenlet's functionality defined in the view and interactor. attribute values and configures the screenlet accordingly first, you'll define guestbook list screenlet's attributes before creating the screenlet class, you should define its attributes. the attributes the app developer can set when inserting the screenlet's xml in an activity or fragment layout. the app developer could insert the following login screenlet xml in an activity the app developer can set the app attributes basicauthmethod and layoutid to set login screenlet's authentication method and view, respectively. screenlet class reads these settings to enable the appropriate functionality when creating a screenlet, you can define the attributes you want to make you do this in an xml file inside your android guestbook list screenlet only needs one replace the file's contents with the following this defines the groupid attribute, which the app developer can use to set the portal site to communicate with if they don't want to use the default groupid you'll account for this attribute's functionality in the screenlet class now that you've defined this attribute and know what it needs to do, you're ready to write the screenlet class provides the basic functionality for all screenlet classes in list screenlets, including methods for pagination and other default behavior, your screenlet class must extend baselistscreenlet with your model class and interactor as use the following steps to create the screenlet class for guestbook list create the guestbooklistscreenlet class in the package baselistscreenlet with the model and interactor as type arguments this requires you to add the following imports for constructors, leverage the superclass constructors this is a boilerplate method that uses a listener in the screenlet framework to propagate any exception, and the user action that produced it, that occurs during the service call. method does this by checking for a listener and then calling its error method with the exception and useraction override the createscreenletview method. this method reads the screenlet's in guestbook list screenlet, you only need to read the value of the groupid attribute and set it to the groupid recall that the screens framework propagates this variable to your finish the createscreenletview method by calling the superclass's createscreenletview method. note that if the app developer doesn't set the groupid attribute, url is called to retrieve the app's default liferaygroupid setting from url this createscreenletview method requires you to add the following imports override the loadrows method to start your interactor and thereby retrieve this method takes an instance of your interactor as an argument, which you use to call the interactor's start the loadrows method in guestbooklistscreenlet therefore starts a note that the interactor inherits also, because you don't need to pass any data to guestbooklistinteractor, you can call the start method with 0 override the createinteractor method to instantiate your interactor. that's all this method needs to do, call your interactor's constructor and your screenlet class is finished. note that this screenlet class is the list screenlet creation tutorial your screenlet is finished, too! before using guestbook list screenlet, however, you'll create entry list screenlet to show a list of each guestbook's entries. after all, viewing guestbooks without their entries doesn't make much sense. what's really exciting is that you can create entry list screenlet with the same set of steps you used to create guestbook list the next series of articles in this learning path walks you through;;