Presentation is loading. Please wait.

Presentation is loading. Please wait.

LiNC Developer Meetup Welcome!. Our job is to make your life easier APIs Tools and workflow Documentation Stay in touch: developers.lithium.com Join the.

Similar presentations


Presentation on theme: "LiNC Developer Meetup Welcome!. Our job is to make your life easier APIs Tools and workflow Documentation Stay in touch: developers.lithium.com Join the."— Presentation transcript:

1 LiNC Developer Meetup Welcome!

2 Our job is to make your life easier APIs Tools and workflow Documentation Stay in touch: developers.lithium.com Join the Developer Track at LiNC May 20-22, San Francisco Lithium Developer Network

3 Freemarker: Rest and Other Context Object A look at the powerful tools you can access through freemarker Doug Schroeder and Yuri Kapulkin

4 REST How to make and use REST calls in freemarker components and endpoints

5 The rest directive can be used to call the Lithium REST API Rest calls return a W3C.Node context object with the response from call If you compare the XML response in a browser to the W3C.Node object, the only difference is it doesnt contain a response wrapper So you dont have to do.response To get an attribute use @ sign To check if an attribute exists use node.attribute[0]?? To get nodes, use. Notation Examples: ${rest(/messages/id/5).message} ${rest(/messages/id/5).message.@href[0]??} ${rest(rest(/messages/id/5).message.board.@href)} REST

6 Imperative http://freemarker.org/docs/xgui_imperative.html Declarative http://freemarker.org/docs/xgui_declarative.html Builtins http://freemarker.org/docs/ref_builtins_node.html How to parse the DOM

7 Querying the Community How to get community data into your components

8 Use when dealing with pages that represent lower level nodes in the community structure Category page Forum page etc. Note: Most pages in the application are community level Examples : ${coreNode.id} Lithosphere: CoreNode Context ObjectCoreNode Context Object

9 Use on a page that represents either a message, a user, or a thread If a page represents a user, you can get details about the user My Profile Page User Profile Page If a page represents a message, you can get details about the message Message Page If a page represents a thread, you can get details about the thread Thread Page Examples: Verify the context object exists using if: ${page.context.thread.topicMessage.uniqueId} ${page.context.message.uniqueId} ${page.context.user.id} Lithosphere: Page Context ObjectPage Context Object

10 When you are on a page with a list of messages (such as the topic page), the env object can help to get the id of each message in the list Forum Message Idea Message Etc. Examples: ${env.context.message.uniqueId} ${env.context.message.parent.u niqueId} Lithosphere: Env Context ObjectEnv Context Object

11 Used to render localized text strings Examples: ${text.format(general.Kudos)} ${text.format(text.key.with.arguments, arg1,arg2)} Lithosphere: Localizable TextLocalizable Text

12 Lithium Freemarker Directives A look at special directives that can be used in components and endpoints

13 The @component directive allows you to insert components into other components You can pass parameters to a component using named parameters Most components dont have any parameters but some do You can add parameters to your custom components Examples: Retrieve parameters in a component using the following: Lithosphere: Passing Parameters to a ComponentPassing Parameters to a Component @component

14 Modal directive is used to render a component inside of a modal window You will need to specify the following parameters: Id: the id of the component you want to render inside the modal Label: The text to display on the link or button used to open the component These are the only two parameters required but there are others you can use to further customize the modal Example: Lithosphere: Creating Modal DialogsCreating Modal Dialogs @modal

15 Lets you specify a block of javascript code in a component The javascript will be added to any page containing the component The javascript will be added after all core javascript has run For jQuery, use Lithium.jQuery instead of $ to use Lithiums jQuery You can assign $ to Lithium.jQuery as in the example Example: @liaAddScript ;(function($){ /*your code here*/ })(Lithium.jQuery);

16 Calling External Services How to call external services and use them in freemarker

17 Http Client allows you to call third party APIs You can configure what domains are allowed via the Lithium Admin You can add headers, fragments, cookies, and parameters to the request Currently HTML is not allowed in the responses and will be rejected! Examples: ${http.client.request(https://some.api.url/some/path). json().get()} $eval{(http.client.request(https://some.api.url/some/pa th).get()} ${http.client.request(https,some.api.url,/some/path ).xml().parameter(paramName,paramValue).post()} Lithosphere: Http ClientHttp Client

18 You can use response.hasError to check if call was successful response.error.message will contain the error message Response.content will contain the content of the response Examples http://lithosphere.lithium.com/t5/developers-knowledge-base/http-client- response-FreeMarker-context-object/ta-p/80622 http://lithosphere.lithium.com/t5/developers-knowledge-base/http-client- response-FreeMarker-context-object/ta-p/80622 Http Client – Parsing the response

19 Thanks!


Download ppt "LiNC Developer Meetup Welcome!. Our job is to make your life easier APIs Tools and workflow Documentation Stay in touch: developers.lithium.com Join the."

Similar presentations


Ads by Google