Download presentation
Presentation is loading. Please wait.
Published bySalvatore Hincks Modified over 10 years ago
1
Using REST and Freemarker to Build Components “let’s make something”
2
“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
3
“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. http://lithosphere.lithium.com/restapi/vc/boards/id/lithiumblog/topic s/recent?page_size=1
4
“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?p age_size=1 Is the same as this:
5
Now let’s write out our article title and date ${recent.message.subject} ${recent.message.post_time}
6
“What kind of date is that?? I can’t read that!” Welcome to Bloggy 2013-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
7
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
8
Now we have: ${recent.message.subject} ${recent.message.post_time.@view_friendly_date} Welcome to Bloggy Yesterday Yay, I love it. Let’s test it!
9
Aaahhhhhh!
10
What Happened? We used @view_friendly_date without ever checking that it existed.
11
“FIX IT!!” ${recent.message.subject} ${recent.message.post_time.@view_friendly_date} ${recent.message.post_time.@view_date} Gives you:
12
“Yay, it’s perfect” Happy Dance
13
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.