Sunday, May 18, 2014

Angular JS - Another Tool in your XPages Toolbox - Part 1

Around this time last year Twitter Bootstrap was becoming the big thing in the XPage Community, and a year later it is widely adopted and has become another tool in your XPages toolbox.  Not that they are that similar but it seems that Angular.JS is now becoming the next big thing for 2014.

For the last several months I have observed with high interest as Mark Roden, Mark Barton, Jeff Byrd and perhaps others from the community have discussed Angular and other noun.js frameworks (backbone, ember, etc).  One common theme that I have noticed is the enthusiasm of eliminating everything front end that XPages provides and only using Domino for the security model and to serve up pages and JSON data.

I must admit that I am a little bothered inside when I try to understand what they are advocating. What bothers me is that I like XPages and what it brings to the table.  I like my XPages toolbox, and while I am always interested in a shiny new tool, I am not interested in trading it for another toolbox.

I totally respect those guys reasons for advocating their approach to front end javascript frameworks, and I am glad they are pushing the envelope in that area, and grateful they are sharing their knowledge.  When I say I am bothered it has more to do with my opinion that you can have both.  I would be lying if I didn't say the investment in time I have made to learning the whole XPages platform didn't have something to do with it.

To be clear, Marky is not saying everyone should follow his path, but as one of the leading bloggers in our community there is a certain pressure to follow the leader.  Speaking of leaders in our community, there is tangible vacancy as we all mourn the loss of Tim Tripcony.  It saddens me that I won't see Tim comment on this post as he sometimes did with others I wrote.

Given this background, I have set out to learn Angular.JS by creating a proof of concept for using it within an XPage.  I have decided to duplicate the functionality of a Dojo Data Grid using Angular.  In this two part blog series, I will show you how I used an Angular.JS within an existing Xpage.

Disclaimer:  

There is always a chance that after time passes, and I become more comfortable with the Angular framework and what all it can do, that I will agree and even advocate with what Marky and others have proposed.  I reserve the right to change my mind.

Learning Angular:

I really can't say that I know Angular that well, as I write it is only 7 days since I first dug into it.

Here is what I did to get up to speed:
  • First I read Marky Roden's blog series, which inspired me to dig deeper.  
  • I next turned to one of favorite resources, lynda.com and watched the course "Up and Running with Angular.JS" by Ray Villalobos.  Ray is one of the my favorite instructors on lynda.com and has a great website with the most awesome URL for a web developer - iviewsource.com
  • After I finished the course, I read Marky's blog post again, as well as those from Mark Barton and Jeff Byrd
With this background, and the assurance from Marky that is was possible, I dove right in my goal of making Angular work within a <div> of an existing XPage.  In part 2, I will share how and what I did.  I will even show how what I added was better than what I used before.

5 comments:

  1. You're running Angular stuff from INSIDE XPages? I thought the whole point was to use Domino as a REST backend and do your front end with Angular on something like an Apache server...

    ReplyDelete
    Replies
    1. Yes, I am running it inside part of my page. I am not sure who gets to make the rules as to what the "whole point" gets to be :). I don't know if this has realistic use cases or not, but I wanted to try it. Maybe I am off base here, maybe I am not. My next post will go over how I use JSON data from a REST service. I have yet to try the dynamic "wow" stuff that angular is known for.

      Delete
  2. Merging the Angular stuff within the XPage is a good way to learn as it introduces you gently to the concepts and there are lots of use cases where you could have computed information (by the Xpages runtime) available to the Angular App.

    Having said that if your XPage results in a page refresh then you have lost one of the main advantages of Angular.

    Good luck with it.

    ReplyDelete
    Replies
    1. Mark, Thanks for the encouraging words. I hadn't considered the results of a page refresh. This is just a fun project for me and I am enjoying the thrill of learning something new.

      Delete
  3. I see no point why not to run Angular in XPages if you are already on the Notes benchmark allthough I am not sure how much the development environment in DDE and XPages comply with working with Angular :-?

    ReplyDelete