Categories
Community Notes In 9 Podcast XPages

NotesIn9 143: Component vs Value binding in XPages

In this show Tim Tripcony explains that while we’ve typically been binding to a value all this time, it’s possible to bind to a component inside your XPages Development.

This show was originally published elsewhere and I basically grabbed this to try and improve the visibility and get Tim’s information as much exposure as possible.

I have 2 new unpublished videos from Tim coming next.

#codefortim

Categories
Community Learning XPages XPages

Tim explains JSON-RPC #codefortim

First I want to highlight OpenNTF’s recent post regarding Tim’s projects.  Let me simply say that I think the #codefortim idea is brilliant. Pure genius and so appropriate.  Tim shared.  Period. I just read that post like 5 minutes ago so I’m going to let it sink in before I talk any more about it.

Which brings us to the topic of today.  This email exchange I’m going to post was forwarded to me by my friend Dan.  He asked Tim a question and as usual got a great response back.  I’m so very thankful he sent this to me.  What make this really special is just how recent it is.  It was only a couple of days before Tim passed.  This is the last email I have to publish.  If anyone has any similar emails that they’d be willing to share I’d be very happy to publish them as well. Next up is some videos.

Dan asks:

On May 7, 2014 at 4:30:20 PM, Daniel wrote:

Hi Tim,

I was looking at an answer you gave Naveen on Stack Overflow on the use of the JSON-RPC control.

http://stackoverflow.com/questions/11356227/how-to-use-xejsonrpcservice

From how you describe the control, it sounds like an AJAX operation. Is my understanding correct?

I’m thinking of an application for it and I wonder if you could tell me if it’s the right tool.

I have an Xpage I’m building that accepts input from a proximity scanner. When an ID is scanned (badgeNo), I’d like to be able to query and SQL db to get the person’s EmpID number and use that to display his image on the screen. Would the JSON-RPC control be appropriate for that kind of operation?

Thanks,

Dan

Tim responds:

From:        Tim Tripcony

To:        Daniel

Date:        05/08/2014 02:15 AM

Subject:        Re: JSON-RPC control


In my opinion, that use case is almost definitely a good fit for JSON-RPC.

RPC stands for “remote procedure call”. Simply put, you’re telling the server to run a method — and how to run that method (in other words, passing method arguments) — and send back a result. So yes, this is AJAX, but it’s slightly different from partial refresh events in XPages.

Partial refresh events execute server-side code, of course, but upon completion they send back a specific visual representation of a portion of the page (namely, HTML) because that portion of the page might need to look different afterward as a result of the execution of that code. The archetypal example of this is an onChange event in a combo box that alters which select values are now valid for an additional combo box further down the page. As you’ve no doubt already seen in action, the platform automatically generates the JavaScript for you that causes the AJAX call to tell the server what code to run, but also handles taking the HTML that is returned and updating the affected portion of the page.

Similarly, submission of any data the user has entered is also automatic. While there are ways to override exactly how much data is sent for each specific event, the default is to just post the entire form to the server. This facilitates the “statefulness” of XPages — with each event, the server state of the page is essentially synchronized with what the client state now is, so both the browser and the server have some level of awareness of the user’s behavior, and both can account for that current state.

JSON-RPC, by comparison, might appear rather manual at first glance. Adding one of these components to your page and defining one or more methods is essentially defining an API that you can then call… but you still need to then add client-side code to actually call it, and also to respond to whatever data the server sends back to the browser. There are a few bits of good news in this regard, however:

– The platform still auto-generates some client-side JavaScript for you. To be precise, a global JavaScript object is created client-side and populated with methods that map to whatever server-side methods you defined for the RPC. These methods are even aware of what arguments you defined for each.

– The performance of this type of service is incredibly lean for two reasons. One reason is that it sends the absolute minimum amount of data in both directions. To be precise, it sends only identifiers for which service is being called and which method it should run, as well as the value of any arguments; in return, it sends back only whatever value you explicitly return from whichever method is called. So instead of posting the values of potentially dozens or even hundreds of fields and getting back a big blob of HTML, it might send only a single number (e.g. badge ID) to the server and get back a single string (e.g. employee ID)… although the response object can be as simple or complex as you want.

The other reason it’s faster is because the default behavior is to not save the component tree after an RPC method runs. It’s assuming that you’re doing something very similar to the use case you described, so there’s no need to re-serialize the entire page state, because you’re not sending a bunch of form data that should update a backing model bean, etc.; rather, you’re just sending it a badge ID and asking it to send back a corresponding employee ID, so there shouldn’t be a need for it to “remember” that it did once it has.

For both of these reasons, JSON-RPC tends to be lightning fast when compared to most partial refresh events, even under low-bandwidth / high latency conditions.

Here’s some pseudo-code to give you a feel for what this might look like if you decide to take the JSON-RPC approach. Somewhere in your XPage you’d have component markup that looks similar to the following:

<xe:jsonRpcService id=”scannerRpc” pathInfo=”scanner”>

<xe:this.methods>

<xe:remoteMethod name=”getEmployeeId” script=”return getEmployeeIDFromSQL(badgeId);”>

<xe:this.arguments>

<xe:remoteMethodArg type=”number” name=”badgeId” />

</xe:this.arguments>

</xe:remoteMethod>

</xe:this.methods>

</xe:jsonRpcService>

The assumption, of course, is that the getEmployeeIDFromSQL() function is already defined somewhere — presumably, in a SSJS library. So for what you’re describing, all that might really need to change in the above example is to alter the type of the badgeId argument (if, for instance, that should be a string, not a number) or to change the getEmployeeIDFromSQL reference to whatever code will be responsible for actually performing the SQL query, whether that be SSJS or perhaps a method of some Java bean.

The other half of this, then, is defining client-side code to call the remote method defined above. If that’s triggered by a “Search” button, for instance, you might end up with something like this:

<xp:button value=”Search” id=”button1″>

<xp:eventHandler event=”onclick” submit=”false”>

<xp:this.script><![CDATA[var badgeId = someCodeToGetIdFromScanner();

scanner.getEmployeeId(badgeId).addCallback(function(employeeId){

dojo.byId(“#{id:employeeId}”).attr(“value”, employeeId);

});]]></xp:this.script>

</xp:eventHandler>

</xp:button>

You might, of course, be setting the innerHTML of a div instead of the value of an input, but hopefully the above example illustrates the basic premise:

– Because the JSON-RPC service lists “scanner” as the value of its “pathInfo” attribute, the browser will automatically be aware of a global JavaScript object called “scanner”.

– Because the RPC service defines a remote method named “getEmployeeId” that accepts a single argument named “badgeId”, the global client-side object has a function called “getEmployeeId” that is also expecting a single argument.

– Calling that client-side function does not immediately send the AJAX request; rather, it returns an object that has a .addCallback method. Calling this method does immediately trigger the AJAX call… and passing a function to addCallback() defines what code will run when the AJAX call returns. Since we’re just expecting to get back a single string value, we specify that the function that we pass to addCallback() accepts a single argument, which we can then use inside the function to somehow update the page or otherwise inform the user that we now know what the scanned employee’s ID is.

No doubt there’s a myriad of valid approaches for your specific use case, but I’ve become rather fond of JSON-RPC for this type of functionality, both because of the relative ease of implementation and because of the comparative performance. Hopefully this overly verbose explanation gives you an indication of whether or not the JSON-RPC approach would, in fact, be a good fit for what you’re trying to do. 🙂


For anyone reading this information that’s interested in the JSON-RPC stuff.  I believe it’s come up on NotesIn9 a couple times as well. So there should be some examples available.

#codefortim

Categories
Community XPages

Tim Explains: SSJS Object Persistence

Below is an email thread between Serdar Basegmez, Tim Tripcony and myself. Serdar reminded me of it and re-sent it to me so I could share.  It’s a little dated but I’m reposting this because the quality of the information should be shared.

This is pretty much the marks the beginning of when I came to grips and realized that if I wanted to use XPages in a similar manner to how I developed for the Notes Client I needed to look past ServerSide JavaScript and focus on Java.  I liked building my applications around Custom Classes in LotusScript.  This email explains how that is no longer possible to do in XPages and that if I wanted to continue my client development “comfort zone” I needed to use Java for that.

Now this realization did not happen over night for me.  I believe this email came in right after my famous battle with Phil Riand. Where I said I’ll never use Java and SSJS should be made better and the “bug” should be fixed.  And he said it’s not really a “bug” and to use Java. we went back and forth a bit and I ended up losing royally and now I write with Java.  haha

 

So anyway here’s Serdar’s original question:

Categories
Community

NotesIn9 and Blog publishing plans for Tim’s material

I guess I just wanted to give everyone a heads up on my current thoughts on publishing material that I have from Tim.

I have 2 emails filled with “Tim Info” that I want to publish and just get it out there.  1 is pretty old but the other was forwarded to me last week and I think was from that past Thursday.  Both have some really good information that deserves to be more widely available I think.

I also have 2 videos from Tim.  One from a couple weeks ago on using OAuth.  Another small one from a couple months ago that I just totally missed and forgot about.

There’s also a video from a while ago that was intended for NotesIn9 but I think I was on vacation that week and he just got impatient and put it up on his YouTube Channel.  I pretty much intend to republish that inside NotesIn9 so try and get it more visibility.

Anyway – that’s my thoughts.  My current intention is to get all this out as soon as possible.

 

 

 

Categories
Community

This one time at the Eastern PA Meetup and XMage Memorial…

Last night a memorial get together was held in honor of our friend, Tim “XMage” Tripcony.  We met at the Allentown Brewhouse which did seem like a pretty nice place.  It kinda reminded me of the Big River Grill at Disney where we always meet for BALD the day before Lotusphere starts.  So very fitting.

Jesse Gallagher, Chris Toohey and I wanted to have some kind of get together to raise a glass to Tim and share some stories and I think it worked out very well.

It was great to see old friends, Rob and Jim, and make new ones in Dave and Dennis. Everyone seemed to have a good time. Good enough that we might try to do another meetup in the area sometime in the future.

Here’s a couple pics from the event.

photo 1 photo 3 photo 4

 

Categories
Community

Tim Tripcony – Rest in Peace my friend

I really don’t remember all the details of how I met Tim “XMage” Tripcony, but from early on he was always kind to me and a friend of my NotesIn9 screencast.

I remember talking to him probably via email and/or Sametime about a blog post he made on “Fancy Typeahead”. I thought it was brilliant and as like many things Tim was involved with, no one had ever done that before in XPages. I eventually pretty much stole that entire post (with his blessing) and turned it into Episode 24. http://notesin9.com/index.php/2011/02/11/notesin9-24-fancy-type-ahead-in-xpages/

I’m not sure but I THINK I first met Tim in person at the Lotusphere 2010 Opening Party. This was now my second Lotusphere. I was doing NotesIn9 by then so I started to talk to people in the community but I really didn’t know many people “in person”. Just from online chats and stuff really. The original “XPages Blog” brought a lot of people together I think.

I did meet some people in person for the first time at BALD. Declan Lynch was one of them as I was presenting with him that year. I remember bumping into someone from BALD at the Sunday night party as I wandered around aimlessly and they told me not to move as “Tim was looking for me”. Sure Tim and I had communicated by then a little bit for him to actively try and look for me was something else. Made me feel very special and included. I’ll always remember the blogger photo from Lotusphere that year where this popular genius of the community ,who was also the nicest guy you could ever hope to find, chose to stand with me.

I remember Tim pinging me on Skype one day.  He said Nathan, who I never spoke to before, wanted to talk to me.  I said to Tim:  “Oh Crap! Nathan wants to cancel NotesIn9 because I’m doing it all wrong!”.  Tim assured me that wasn’t the case.

I remember on a business trip to Atlanta arranging to meet Tim for dinner.  We went to this really good BBQ place called Foxboro I think and just sat and talked for hours.  It was great.

I remember thinking of him as the “Mr. Spock” of our community.  Tim was completely brilliant.  And where Spock would say “fascinating” Tim would say “Indeed”.

Tim was the SWAT team of the XPages world.  You get stuck on something then you ask someone.  If no one else knows THEN you called Tim.  Tim always happily answered.  Which didn’t mean you understood the solution all the time. but he tried explaining it.  I remember him coming over to my room in Lotusphere one time.  I was really stuck on something…  I don’t remember what.  Tim sat and looked at my stuff and I think gave me a couple ways to proceed.  One of them I understood.

When I would describe Tim to someone I would always bring up a reference to Star Trek IV.  I’d say talking to Tim is like talking Scotty.  It’s like talking to someone from the future and he has the formula to Transparent Aluminum. I think Tim got a kick out of that one.

Tim was actually my best contributor to NotesIn9.  He love to share.  He came on for 8 shows that totaled over 3 and a half hours.  I’ll put links to those shows at the end of this post.  I have 2 more unpublished shows from Tim.  One I knew about and another one that I just completely missed. I’d forgotten all about it. That one seems extra special to me now for some reason.  I’m going to try and publish both next week.  I swear on the bigger show from just a couple weeks ago he seemed “giddy” when going through the code.

I’m a better person for knowing Tim Tripcony. He was an inspiration, a personal hero, and a friend.

 

Tim contributed to these NotesIn9 shows: (2 more coming)

http://notesin9.com/index.php/2012/02/28/notesin9-048-applying-themes-to-form-tables/
http://notesin9.com/index.php/2012/03/29/notesin9-063-creating-an-in-view-edit-custom-control/
http://notesin9.com/index.php/2012/04/04/notesin9-064-global-custom-controls-fixed/
http://notesin9.com/index.php/2013/11/01/notesin9-130-using-xpages-type-ahead-for-navigation/
http://notesin9.com/index.php/2014/01/13/notesin9-133-using-java-in-xpages-part-2/
http://notesin9.com/index.php/2014/01/14/notesin9-134-using-java-with-xpages-part-3/
http://notesin9.com/index.php/2014/01/16/notesin9-135-using-java-in-xpages-part4/

 

 

 

 

Categories
Community

VENUE CHANGE: Eastern PA Meetup and Tim Tripcony Memorial

I’ve gotten a great response to this!  I believe we’re up to 11 people that are likely.  Amazing!

But the initial plan needs to change. Apparently some of the local colleges graduate that day and the Bethlehem location was booked.  So we’re going to try and move it to their Allentown location.

http://www.thebrewworks.com/allentown-brewworks/

This isn’t really a “room” or anything.  It’s basically reservations for 5:00pm.  I’ve never been there so I don’t know what to expect. I assume there’s a bar if you get there early.  I’m sure I’ll be there a little earlier.

This is low key! The same as Tim or any other LUG type event.  No real “agenda”. We’ll hang… chat… morn, commiserate…  explore the future maybe.  Just basically a meet and be social as in “real world social”.

 

Please let me know if you have any questions.  And if you’re planning on coming and haven’t let me know yet please do!

 

Thanks!

 

Dave

Categories
Community

Announcing the Eastern PA Meetup and XMage Memorial

As much as I would like to, I’m unable to get to Tim Tripcony’s actual memorial with his family and friends in the Atlanta area. But here’s the thing, Tim has friends all over the world. So here’s what I’m going to do:

This Sunday evening, May 18th, starting at 5:30ish in the Bethlehem Pa area,  I’ll be getting together with Chris Toohey and Jesse Gallagher. We’re going to toast our friend*, maybe tell a story or 2 and then probably talk some XPages and whatever.

We’d like to invite anyone to join us for a very informal low-key event.  If we get enough interest one of the topics will be if we want to try and meet again for a more formal-ish “XPages and Beer” type learning event.

I feel that the best way to honor our friend is to continue to practice what he did every single day:

Learn. Code. Share

Again this is open to all whether you knew Tim personally, read his blog, or are just interested in talking XPages with like minded people.

If you are wanting to attend, please let me know ASAP – (dleedy @ notesin9)  so I can try and get a count for the possible venue – most likely at:  http://www.thebrewworks.com/bethlehem-brew-works/.  If you can’t make it on Sunday but are interested in a possible future event please let me know that as well.

UPDATE: Venue Changed to: http://www.thebrewworks.com/allentown-brewworks/

Thanks

* I personally will not be toasting with a White Russian simply because I don’t know how to drink “big boy” drinks and also don’t like coffee.  🙂

Categories
Community

Tim Tripcony

This weekend I was working on a NotesIn9 from Tim Tripcony that I’ve been sitting on for a couple of weeks. I pinged him on Skype this morning to ask a question. I was literally just about to start rendering the video when I got word that he has passed away.

Here’s the linked in post from Scott Hooks

https://www.linkedin.com/today/post/article/20140512170336-24024491-tim-tripcony-you-will-live-on-in-our-hearts

Tim was my friend.  My heart breaks over this news.

My thoughts and prayers go out to his family and friends.

I want to be more eloquent but simply can’t.  I can barely breath.

I would like to put this idea out…  if anyone wants to send me any audio stories or memories of Tim, I’d like to put them together and publish them. just email me: dleedy @ notesin9

Here is one of my few pictures of the two of us.  It’s also my favorite.  Taken from the 2010 blogger photo.  Tim standing next to my putting his chin on my shoulder.

Tim1

 

Categories
XPages

The Great XPages Mystery Solved.

Disclaimer: Everything in this post comes from Declan Lynch.  He doesn’t really blog anymore but I felt this important enough to share so I’m just trying to put out what info I know.

So we had a big problem at the day job this week.  Our main server was getting hammered with what looked like a memory leak.  This server houses our main business application that Declan wrote as well as the iPad BarCode Scanner stuff that I wrote.  So naturally the question was asked of me:

“What code updates have you pushed to production in the last week?”

A perfectly fair question.  Apparently he’s actually read some of my code.. who knew?

Anyway as luck would have it I’ve promoted nothing for a little while. I’ve been working on some new stuff that’s not ready. I could even use SourceTree to go back and find the date of my last promotion and it was far enough away that I was pretty much in the clear!  Talk about having a good alibi!  haha

Anyway – as best as I can tell Declan soon figured that is was not a memory leak but an unexplained CPU spike.  Something was happening that was killing the server.  And let me tell you, this is a BEEFY server. But still the CPU and HTTP Task was getting HAMMERED.

So what caused this almost Catastrophic problem?

The Safari Web Browser.  Specifically the “Top Sites” feature. From two users.

Here’s how Declan described it with the needed fix:

 

what I thought was a memory leak wasn;t a memory leak, it was Safari’s Top Sites feature on two different users machines. Safari has a feature called Top Sites, as you visit different web sites it adds the site to the Top Sites list.

So for these users it added our internal site because they use it a lot..  Safari is also trying to be helpful, by pre loading the site to show a preview. Except in our case the sites are locked down so there is a redirect to a login page so Safari tries loading it again.

and again, and again, and again

about 6 times a second safari was hitting our server. Driving the CPU usage up till the site became unresponsive for users. Once we removed the site from the two users top sites listing the server settled back down and is behaving normally again.

and now for a fancy workaround…

you can tell the browser what content to serve if it is being loaded by a ‘preview’ function using the following code.

if(window.navigator&&window.navigator.loadPurpose===”preview”){window.location.href=”http://some.other.content/in/a/folder.ext”};

so you could redirect the preview to a totally different site or you could redirect to an image

 

How did he diagnose this and fine the issue?

He had to put the XPages Toolbox on the production server. With the backend monitor he noticed all the hits to the same login page over and over. So he went to the users machine and used netstat to confirm that it had a connection opened to Safari.  Then he closed safari and saw the connection drop, But the connection came back on just opening Safari without going to out website.  So he saw the Top Sites listing and removed it.  No more connections.

He got the users IP address by running ‘tell http show thread state’ on the domino server.  That shows all the treads and IP Addresses.

WOW

He does other tricks as well.  I can struggle with something for a whole day and when I do break down and ask for help he often has the solution before I’m even done explaining the problem.

Yep.  I have the best boss in the world! It’s like working with Sherlock Holmes.