using rest and freemarker to build components
Download
Skip this Video
Download Presentation
Using REST and Freemarker to Build Components

Loading in 2 Seconds...

play fullscreen
1 / 13

Using REST and Freemarker to Build Components - PowerPoint PPT Presentation


  • 126 Views
  • Uploaded on

Using REST and Freemarker to Build Components. “let’s make something”. “I want to show the most recent blog article and when it was posted”. Ok, no problem. First get the message from REST. /topics/style/blog/ recent?page\_size =1 And assign that to a freemarker variable

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Using REST and Freemarker to Build Components' - oya


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
i want to show the most recent blog article and when it was posted
“I want to show the most recent blog article and when it was posted”

Ok, no problem. First get the message from REST.

/topics/style/blog/recent?page_size=1

And assign that to a freemarker variable

<#assign recent= rest(“/topics/style/blog/recent?page_size=1”).messages />

no wait i only want it to come from my blog it s called bloggy and it s the best
“No,wait! I only want it to come from my blog. It’s called “Bloggy” and it’s the best

Still no problem. We’ll just change our REST call to be specific to one board.

<#assign recent = rest(“/boards/id/bloggy/topics/recent?page_size=1”).messages />

http://lithosphere.lithium.com/restapi/vc/boards/id/lithiumblog/topics/recent?page_size=1

what s that restapi vc thing
“What’s that ‘/restapi/vc’ thing?

If you want to see your pure xml response in the browser you need to have “restapi/vc” in the url. If you are making the call in Freemarker, we take care of that part for you.

This:

http://lithosphere.lithium.com/restapi/vc/boards/id/lithiumblog/topics/recent?page_size=1

Is the same as this:

<#assign myCall = rest(“/boards/id/lithiumblog/topics/recent?page_size=1”) />

what kind of date is that i can t read that
“What kind of date is that?? I can’t read that!”

Welcome to Bloggy2013-11-18T17:34:08+00:00

Good point, you can get more user friendly info by adding a parameter to your rest call

?restapi.response_style=view

slide7
<#assign recent = rest(“/boards/id/bloggy/topics/recent?page_size=1&restapi.response_style=view”).messages />

This changes the response for post time from this:

2013-11-18T17:34:08+00:00

To this:

2013-12-02T19:13:12+00:00

slide8
Now we have:

${recent.message.subject}

${[email protected]_friendly_date}

Welcome to BloggyYesterday

Yay, I love it.

Let’s test it!

what happened
What Happened?

We used @view_friendly_date without ever checking that it existed.

fix it
“FIX IT!!”

${recent.message.subject}

<#if [email protected]_friendly_date[0]??>

${[email protected]_friendly_date}

<#else>

${[email protected]_date}

Gives you:

tips for development
Tips for Development
  • Always check the XML first
  • Test for variables before you use them. De-FENCE, De-FENCE!
  • Test as both an admin user and a regular user- permissions will kill you –
  • “unit test”
  • Versions tab is your friend
  • Think about performance
ad