What good is the internet of things to people who don’t have internet?

While preparing for a panel discussion this morning, Tami suggested that I check out the blogs by our technology team at DAI. Rob Ryan-Silva wrote an excellent think piece on using the Internet of Things to help people who have no access to the internet. In Cambodia, they relied on human intervention to get out flood warnings. That’s not always reliable, but Rob was able to use IoT to come up with an automated solution….

Categories: General Interest | Tags: , , , | Leave a comment

An apparent theme: application agnosticism

As always, I’m enjoying learning new things and seeing old friends (and some new ones!) at MWLUG. There have been sessions that talked about accessing and displaying data from within Notes without using Notes or XPages and sessions about accessing non-Notes data using XPages. Much of the excitement is about having data exposed via a REST service and using a good front end tool to display it. So, in some senses, we are talking about not needing Notes at all.

Earlier this summer, our company’s Vice President of the Office of Information Management and Technology announced that we’re actually moving away from the Notes client for mail. While I knew that this was a possibility, I’d thought we were still just looking at allowing folks to choose other mail applications to access their mail. Of course, allowing multiple mail applications either tosses some of your users to the wolves of ‘no support’ or complicates things immeasurably for support. So, it does make sense and was not particularly unexpected. Nonetheless, it still surprised me.

The core of our Notes use has always applications anyway. Our business relies on a lot of people working disconnected and, as such, the Notes replication model has been key to our need for Notes. So, we’ll be keeping the Notes client on machines for all those people who work disconnected, but much of our access had already moved to the browser. So, in a sense the work I do was moving in this direction as well.

So, the agnosticism is where we’re all going, it seems. I guess the mantra remains — use the best tool for the job.

Categories: Conferences, General Interest, Xpages | Tags: | Leave a comment

Sessions for #MWLUG2016

Looking over the announced sessions for MWLUG 2016 down in Austin, I’m excited. There’s a good mix of things you can use today and road maps you can apply in the future. I’m a developer, so all the Development and Best Practices sessions look interesting. The tough part will be picking which ones to attend (and record!)

Five sessions that jumped off the page at me are, in no particular order:

Debugging Java In Your Domino Applications with Julian Robichaux — Java just kills me sometimes. Heck, all of XPages does, but learning more about how to debug and troubleshoot is always useful.

Extreme Development: Pair Programming with Devin Olson and Mike McGarel — Now that Elvis Lezcano is aboard at DAI, we might have a chance to do some of this. He’s the smartest developer I’ve worked with, which I why this is the third job we’ve had together.

Think Outside The Box with Karl-Henry Martinsson — We’ve just been breaking into using REST services with jQuery and Bootstrap to present data, so getting someone else’s take on it will expand my ability to combine data from multiple databases to dazzle our users. (see Kathy’s session on dashboards for ideas she’s using for us)

Getting Your Hands on Graphs with Nathan Freeman — I have loved all the conceptual sessions and want to learn more. If Nathan can get me to understand, there’s no telling how far we can go!

A Modernized Developer’s Workflow with Domino/XPages with Eric McCormick — Workflow has always been a great strength of Notes, so getting modernized by someone who’s not spouting theory, but displaying methods in practice is exciting.

Now, before anyone complains about me not mentioning their sessions…. I’d like to sit in on about… 27 sessions. Since Marky has made no progress on the time machine and IBM doesn’t have anyone working replication of people instead of just data and design, I think I only get about a dozen sessions.

Categories: Conferences, Java, Xpages | Tags: , , , , , , , , , , , , , , | Leave a comment

Can you hear me now? Life without #HearingLoss

I turned 50 in December, but my ears were already retired. I’d go to corporate events or to happy hours and smile a lot when people talked. I had long ago stopped asking more than once if I couldn’t hear someone in those environments. If I was lying on my right side in bed and my wife said something, I could only tell that she was speaking, not even guess what she’d said. In our kitchen, with little or no background noise, I’d often ask her to repeat herself. When we’d go on walks, it was important that she walk on my right, since I wouldn’t be able to carry on a conversation if she was on my left. Playing baseball (in an over 48 league!) I’d smile and nod when one of the other outfielders would shout some advice that was simply from too far away.

Last year, my mother-in-law asked me to go to a luncheon offered by an audiologist to talk about hearing aids. I assumed it was because she remembered that we shared the problem of hearing loss. She didn’t, so she was surprised when I was excited about it. I’d been asking my doctor each year when they did the hearing test if it was time to get hearing aids. Those problems noted above really bothered me. This year, he said, “Maybe.” The luncheon was marvelously informative and I set up an appointment to have my hearing checked. Due to the price tag, I held off to reconsider getting them. Thousands of dollars requires more than a few minutes of thought. I had in mind about half of the number they cited.

A few months later, they had another luncheon and this time, I took Melissa. They gave me a pair to try. It was a world of difference. You know, I thought the turn signal on my truck didn’t make noise anymore. It does. I just wasn’t hearing it.

While I had the trial hearing aids, a friend of my mother-in-law came into town. We were all sitting the kitchen table discussing hearing aids and especially that someone in particular didn’t want people to think she is “old”. So, her friend who is a several years younger than her says, “I’m wearing mine.” No one had ever noticed. The behind-the-ear hearing aids were about the same color as her hair and you couldn’t notice unless you leaned in close and pushed her hair aside. She also solved my concern over the price. Costco sells hearing aids and for a fraction of the price. However, not every Costco has audiologists on staff – some only have hearing aid technicians. If your local Costco doesn’t have audiologists, you probably are better off going to an independent audiologist, just as you wouldn’t go to someone who wasn’t a surgeon for heart surgery.

Many people worry that people will think they’re old if they see the hearing aids. The truth is, they probably can’t see them and…. people already know you can’t hear them. When you just nod and smile at conversation or bring up topics that have been discussed five minutes ago, people notice. Then, you look old AND stubborn. I’m only 50 and I could care less if people notice. I tell people about them all the time. A couple of the guys in my office who are in their 30s spent too much time in rock-and-roll, so are considering getting them.

If you’re not hearing people, it causes a lot of problems. You don’t hear important things — like what your doctor tells you about your health or medication. Imagine hearing that a “1 in 2” surgeries results in death, instead of “1 or 2%” of surgeries result in death. You may not hear when a loved one says, “I love you”. You answer different questions than people asked. You laugh when everyone else does, even if you didn’t hear the punchline. You miss out on lots of interaction and life gets dull. You may develop a tendency to avoid places where hearing may be difficult, like restaurants, and end up avoiding other social situations. These compound each other and you feel isolated. Isolation can lead to emotional issues, like depression, or even lead to dementia (if you’re the only one you can hear in your world, it gets real hard to connect to reality).

So, if you’re missing conversational bits or find that “people talk too fast”, get yourself checked. People are not talking faster – your ears don’t hear every letter anymore, so it takes you longer to figure out what they actually meant to say. There are some sounds, like the f or ph or s, that I simply can’t hear without my hearing aids because those pitches are simply bad for me. If you miss two or three letters in every word, your brain can’t figure out what the words were. One joke I often told was that “as I got older, people said more interesting things” because I couldn’t hear what they actually said and my brain guessed wrong!

If you don’t think you need them and that nobody has noticed, ask someone.

* While I don’t use Duracell batteries, that’s a great commercial AND they have a portion of their website dedicated to it.

Categories: General Interest | Tags: , , , , , | Leave a comment

Austin, Texas hosts #MWLUG2016 in August

While the definition of “Midwest” may be getting broader, there is no denying the huge value of the largest Notes user conference in the US, MWLUG. This year, we venture to Texas, holding our conference in one of the premier hotels in Austin, while keeping lodging affordable.

We are please to officially announce that MWLUG 2016 will be held on August 17-19, 2016 at the Four Seasons in Austin, Texas. We have secured a special rate for this premier ICS conference. With all the new innovations that IBM and IBM Business Partners are creating with our favorite technologies, we are “Defining the Art of Collaboration” which is our theme for MWLUG 2016.

We are expecting an even greater turnout this year at MWLUG 2016. We are planning many activities and new formats to make this a special event. For attendees that are interesting in coming earlier, we are also working on a special event on Tuesday, August 16, 2016. We will need to determine if there is enough interest before we book this event. More information will be coming soon.

The Four Seasons location in downtown Austin is rated as one of the best hotels in the United States. We have made special arrangements with the Four Seasons for a special discount of $189.00/night for attendees of MWLUG 2016.

If you are interested in being a sponsor of MWLUG 2016, sponsorship will start next week. Stay tuned for announcements.

Ready to share your knowledge and skills, abstract submission for MWLUG 2016 will start on April 15, 2016 so get your ideas ready. As always, we reserve 25% of the speaking slots to new speakers. So don’t be shy.

Registration for MWLUG 2016 will start on May 1, 2016.

MWLUG 2016 session tracks include:

  • Application Development
  • Best Practices in Social Collaboration
  • Customer Business Cases
  • Innovation
  • System Administration

MWLUG 2016 is made possible by the generous MWLUG 2016 sponsors whom not only pay for the majority of the cost for MWLUG 2016, but also donate their time in organizing and providing technical sessions on critical topics that are important to our ICS community.

  • Close to 50 business and technical sessions
  • Breakfast and Lunch for Thursday and Friday
  • Wednesday Evening Showcase Reception that include drinks and hors d’oeuvres
  • Thursday Evening Social Event
  • Networking with your colleagues in the ICS community
  • And a whole lot more

While I will again be videotaping the session I attend (like my videos from MWLUG 2014 and MWLUG 2015) but it’s nothing like seeing it in person. Your session choices might be different from mine and there’s really no substitute for seeing it in person. Additionally, all of us also end up learning from each other in between sessions, over meals and in the evenings. You get to make connections that will be useful when you hit a roadblock or…. when you’re looking for a new job or trying to find a new employee. Since the cost of the conference itself is nominal and lodging is reasonable, I can’t see a reason you wouldn’t attend.

Note that session proposals can be pitched starting April 15th!

Categories: Conferences | Tags: | Leave a comment

Orphan #Java class files in the Local folder in #XPages

Every once in a while, when I do a design refresh for one of my XPages databases, I notice it adding .class files for XPages that I’ve already deleted.

So, I do another clean & build on the template, but they’re still there. Annoyed, I console myself that the files are never referenced, so I don’t need to worry about it. Of course, I worry anyway.

Vestigal Java FilesSo, in my quest to figure out what was going on, I continued poking around. I checked in the Local folder while looking at the Navigator Eclipse view and saw that the .java files were still sitting there as orphans, with no XPage in the design any more. So, I did just a ‘Clean’ and it eliminated all the files except for those. According to “Mastering XPages”, this doesn’t happen. In warning you not to create Java files in the Local folder, it states that

the incremental builder in Domino Designer would then flush the contents of the Local folder before recompiling all the XPages again. Your custom Java source files would be permanently deleted in this case.

Yet, those files stubbornly remain. Fortunately, when I create a new copy of the template, none of those Local files copy into the new database. So, my habit of creating new files for new versions of the template has helped me by dodging this little, harmless bug.

 

Categories: Java, Xpages | Tags: , , | Leave a comment

An agent to change field values to help in #XPages

With our transition to XPages, I’ve been finding more and more often that I don’t have a form interface in the Notes client to just change one field value on the back end. Too often, on the front end, in XPages, there’s a value I simply haven’t exposed for editing or don’t even display. I often don’t add the fields to the back end Notes form because it really doesn’t add much value. So, when I want to change one field, or change one field on multiple documents, I do it with an agent. Heck, over the years, we all have. We just usually did it in a very static manner – writing a quick @formula to change the value of a specific field. That requires changing the design to create the agent and then delete the agent – or leaving a mess behind that slowly grows your agent list with more and more single-use agents.

So, I wrote an agent that allowed me to replace a text field by naming the field and the value. Then, I found I wanted one for numbers as well. So, for a few weeks, I had two agents. Then, I realized the folly and wrote an agent that detects the field being updated (or asking you if the field doesn’t exist). I only did it for text, numbers and dates, so I imagine it could be extended. It’s enough for me. Since I had occasion to share it this week with another developer, I thought I’d also post it here to share via the blogosphere.

While there’s nothing brilliant about it, it sure is useful.

%REM
	Agent Change Field Value
	Created Jun 19, 2015 by David Navarre/DAI
	Description: This Agent allows the user to name a field and change the value
		It checks the field type on the first document selected and
		handles strings, numbers and dates differently
%END REM
Option Public
Option Declare
Use "Utilities"
Dim ws As NotesUIWorkspace
Dim newDate As NotesDateTime
Dim newvalue As Variant
Dim fieldname As Variant
Dim change As String
Sub Initialize
	Dim session As New NotesSession
	' thisdb declared in Utilities '
	Dim ndc As NotesDocumentCollection
	Dim itemdoc As NotesDocument
	Dim itemToChange As NotesItem
	Dim numericValue As Double
	Dim itemType As Long
	Dim selectedType (2) As String
	Dim choice As Variant
	Dim reason As String

	On Error GoTo errorhandler

	Set ws = New NotesUIWorkspace
	Set thisdb = session.CurrentDatabase

	selectedType (0) = "Date"
	selectedType (1) = "Text"
	selectedType (2) = "Numbers"

	Call StartAgentLogging (session )

	fieldname = ws.Prompt ( PROMPT_OKCANCELEDIT, "Field Name", "Enter the name of the field to change" )
	If IsEmpty ( fieldname ) Then
		Exit Sub
	End If

	newvalue = ws.Prompt ( PROMPT_OKCANCELEDIT, fieldname, "Enter the new value for " & fieldname )
	If IsEmpty ( newvalue ) Then
		Exit Sub
	End If

	' get the collection before issuing the confirmation, so we can determine field type '
	' from the first document selected, assuming it is the same on the rest '
	Set ndc = thisdb.UnprocessedDocuments
	Set itemdoc = ndc.GetFirstDocument
	Call agentLog.LogAction ( "Items: " & ndc.Count )

	If ( itemdoc.Hasitem(fieldname) ) Then
		Set itemToChange = itemdoc.Getfirstitem(fieldname)
		itemType = itemToChange.Type
	Else
		choice = ws.Prompt(PROMPT_OKCANCELLIST, "Select field type", "Field " & fieldname & " does not exist on the first document. Select field type to create", "Text", selectedType )
		If IsEmpty ( choice ) Then
			MessageBox "Action cancelled"
			Exit Sub
		End If
		Select Case choice
		Case "Date"
			itemType = 1024
		Case "Text"
			itemType = 1280
		Case "Number"
			itemType = 768
		End Select
	End If	

	If Confirm ( itemType ) Then
		While Not itemdoc Is Nothing
			Select Case itemType
			Case 1024  ' DATETIMES '
				Call itemdoc.ReplaceItemValue ( fieldname, newDate )
			Case 1280  ' TEXT '
				Call itemdoc.ReplaceItemValue ( fieldname, newValue )
			Case 768  ' NUMBERS '
				' if the value supplied is an integer, save it that way '
				If ( CInt ( CDbl ( newValue ) ) = CInt ( newValue ) ) Then
					Call itemdoc.ReplaceItemValue ( fieldname, CInt ( newValue ) )
				else
					Call itemdoc.ReplaceItemValue ( fieldname, CDbl ( newValue ) )
				End If
			End Select

			Call agentLog.LogAction ( change )
			Call itemdoc.Save ( True, False )

			Set itemdoc = ndc.GetNextDocument ( itemdoc )
		Wend
		MessageBox change & Chr$(10) & "Successful on " & ndc.Count & " documents"
	End If

exiting:
	Call agentLog.LogAction ( "-------" )
	Call agentLog.LogAction ( "-------" )
	Exit Sub
errorhandler:' report all errors in a messagebox '
	reason = "Error #" & CStr (Err) & " (" & Error & ") on line " & CStr (Erl)
	MessageBox reason, 16, "Error"
	Call agentLog.LogAction ( reason )
	Resume exiting

End Sub
%REM
	Function ConfirmValue
	Description: This function displays a confirmation dialog based on the field type
%END REM
Function Confirm ( itemType As Long ) As Boolean

	Select Case itemType
		Case 1024  ' DATETIMES '
			Set newDate = New NotesDateTime ( newValue )
			change = "Change date in " & fieldname & " to " & newDate.Dateonly
		Case 1280  ' TEXT '
			change = "Change text in " & fieldname & " to " & newValue
		Case 768  ' NUMBERS '
			change = "Change number in " & fieldname & " to " & newValue
		Case 1  ' RICHTEXT '
			Confirm = False
			MessageBox "Cannot change rich text using this agent"
			Exit Function
		Case Else
			Confirm = False
			MessageBox "Cannot change " & fieldname & " using this agent" & Chr$(10) & "Field type: " & itemType
			Exit Function
	End Select 

	Confirm = ws.Prompt ( PROMPT_YESNO, "Confirmation", change & "?" )

End Function

Oh, and the relevant snippet of the Utilities script library….

%REM
    Library Utilities
    Created Mar 29, 2012 by David Navarre/DAI
    Description: Some database utilities
%END REM
Option Public
Option Declare

Dim thisdb As NotesDatabase
Dim agentLog As NotesLog
Sub Initialize

End Sub

Sub StartAgentLogging ( session As NotesSession )
    ' this module starts agent logging '
    ' 29 Mar 12, David Navarre '
    Dim title As String
    Dim agent As NotesAgent

    Set agentLog = session.CreateLog ("Agent log")
    Set agent = session.Currentagent
    Call agentLog.OpenAgentLog
    Call agentLog.LogAction ( "Log Open" )

End Sub
Categories: Old Notes, Utilities | Tags: , , , , , | 2 Comments

Copying property definitions for custom controls in #XPages

PropertyDefinitionSometimes, when I’m working on my applications, I’ll decide that I want to copy a property definition from one custom control to another. When using the standard properties interface, it’s a lot of work. You have to put the right information into the right fields and switch between tabs. It’s a real bother.

Interestingly, it never occurred to me to look at the .xsp-config documents until we started using SourceTree for source control.* I was looking at some changes and suddenly noticed that … the property definitions are right there! So, instead of slogging through manual editing of the definitions in the UI in Designer, I could just go to either the Navigator or the Package Explorer Eclipse view to open and edit the properties as simple XML.

    <property>
      <property-name>deletionAllowed</property-name>
      <property-class>boolean</property-class>
      <display-name>Allow deletions of attachments</display-name>
      <property-extension>
        <designer-extension>
          <category>Control information</category>
          <editor>com.ibm.std.Boolean</editor>
          <default-value>false</default-value>
        </designer-extension>
        <required>false</required>
      </property-extension>
      <description>Determines if attachments may be deleted,
Deletions are soft and may be recovered within recovery period.
(default: false)</description>
    </property>

So, if I realized that I needed that property on a different custom control, or I wanted to create a second property on the same control with a different name, I could simply copy-paste the code and edit it as necessary.

There is one pretty cool PropertyCategoriespiece of the property definition that seems only to be available when you edit the code directly. That’s the category definition. If you provide a category definition as shown in my code snippet above, then when you’re setting the properties of the custom control that you’ve inserted, it displays categorized properties as part of that category in the UI for ‘All Properties’. I urge you to make sure that if you do fiddle with the properties on the back-end this way, that you first give yourself examples by doing most of it using the UI for adding properties. As with anything else I do in XPages, I find myself wanting to get right to the code, not to use the UI provided by Designer.

It’s interesting that it actually does give you an option that you don’t seem to be able to get otherwise.

* I want to thank PSC for getting us to use SourceTree and bitbucket (while Kathy and Brad do some work for us) and to Paul Withers for his excellent Notes in 9 video on how to do it (for our internal ones).

Categories: Xpages | Tags: , , , , | Leave a comment

Pause to breathe: a note from Lotusphere ’16

I have to be honest. I never knew that I was an introvert. I was always puzzled by the times in my life when I was afraid of people or just wanted to go somewhere quiet. I love reading and my ‘alone time’ reading has always given me that … space. On the other hand, I was in the drama club and on the debate team in high school. I even ran, very unsuccessfully, for student government. So, it was not until I was giving Kathy Brown a ride back to the airport from our offices (PSC is doing some work for us), that I learned about ‘outgoing introverts’. From what I understand, being an extrovert or an introvert is all about whether you gain or lose energy by interacting with others. So, while those of us who are outgoing introverts enjoy interacting with others, it can be draining. Someone who is an extrovert would be gaining energy through the interaction, but not me. I enjoy it, but it does wear me out.

Because we had lunch with James Weru, Clive Lightfoot and Roman Weber, I’ll have a post about their case story that they shared during the Opening General Session. It hits so close to what our company does, working toward the same purposes that I simply had to meet them and learn more.

So, having just spent a few hours being very social at lunch and between sessions, I just needed a quiet break. Just as I need to recharge my laptop and my phone right now, I need to recharge my personal energy banks. It’s easy to forget when attending conferences, that in order to ensure you get the most out of it – knowledge, contacts, tools and relaxation – you have to take care of yourself.

It’s been an incredible conference so far. Having stopped to write this, I feel ready to go back to shaking hands and telling stories.

Categories: Conferences, General Interest | Tags: , , , , , | Leave a comment

A venture into DateTimes in #XPages

Recently, I was trying to change the display of some dates in our application. We’ve found that the simplest way for our international company to display dates is to stick to the dd-MMM-yyyy format since that seems the clearest. No one wonders whether 1/4/16 represent the 4th of January or the 1st of April, because they all see 04-Jan-2016.

This was simplest to fix for all the date fields that use simple inputText controls – just change the convertDateTime pattern.

						<xp:inputText value="#{modDoc.RevPerf1Date}" id="revisedPerformanceDateStart">
							<xp:dateTimeHelper></xp:dateTimeHelper>
							<xp:this.converter>
								<xp:convertDateTime pattern="dd-MMM-yyyy"></xp:convertDateTime>
							</xp:this.converter>
						</xp:inputText>

Then, I noticed that in place I wasn’t letting them edit the dates, it wasn’t using that format. We’re not displaying the inputText, but using a label computed from that control to determine what to display. This code may actually hurt your eyes, but it did convert the date into a US-format date, like 01/04/2016.

<xp:label id="label14" style="color:black;">
	<xp:this.value><![CDATA[#{javascript:if(modDoc.isNewNote()){ 
		if(modDoc.getItemValueDate("PerfDate1") != null) {
			var termBegin = @Text(modDoc.getItemValue("PerfDate1")); 
			if(termBegin != ""){ 
				var dt2:NotesDateTime = session.createDateTime(termBegin); 
				var d = new Date(dt2.toJavaDate()); 
				var mon = ("0" + (d.getMonth() + 1)).slice(-2) 
				var td = ("0" + d.getDate()).slice(-2); 
				var yr = d.getFullYear(); 

				mon + "/" + td + "/" + yr 
			}
		} else { 
			if(sessionScope.POPerformBeginDate != null && sessionScope.POPerformBeginDate != "null" && sessionScope.POPerformBeginDate != ""){ 
				var dt:NotesDateTime = session.createDateTime(sessionScope.POPerformBeginDate); 
				dt.toJavaDate() modDoc.setValue("PerfDate1",dt); 
				var d = new Date(dt.toJavaDate()); 
				var mon = ("0" + (d.getMonth() + 1)).slice(-2) 
				var td = ("0" + d.getDate()).slice(-2); 
				var yr = d.getFullYear(); 

				mon + "/" + td + "/" + yr 
			} 
		} 
	} else { 
		var termBegin = @Text(modDoc.getItemValue("PerfDate1")); 
		if(termBegin != ""){ 
			var dt2:NotesDateTime = session.createDateTime(termBegin); 
			var d = new Date(dt2.toJavaDate()); 
			var mon = ("0" + (d.getMonth() + 1)).slice(-2) 
			var td = ("0" + d.getDate()).slice(-2); 
			var yr = d.getFullYear(); 

			mon + "/" + td + "/" + yr; 
		}
	}}]]></xp:this.value>
</xp:label>

Before we decided to convert to the new format, the ugliness of the code didn’t matter. It was used in one place (printing purchase order modifications) and it worked. Since I didn’t want to invent my own library function for computing the text value of the date in the new format, I searched for a better way to format the dates. I ran across Declan Lynch’s blog entry on using SimpleDateFormat. Unfortunately, that just points in the right direction, rather than providing working code. So, when I tried to implement that for displaying the labels correctly, I just couldn’t get it to work. This frustration led me to the simple solution: use convertDateTime on the labels. Duh!

						<xp:label id="performanceDateStartDisplay" style="color:black;">
							<xp:this.value><![CDATA[#{javascript:getComponent("performanceDateStart").getValue();}]]></xp:this.value>
							<xp:this.converter>
								<xp:convertDateTime pattern="dd-MMM-yyyy"></xp:convertDateTime>
							</xp:this.converter>
						</xp:label>

Now, on the printed purchase order modification, I also had changes in dates detailed in the text as a sentence. So, you’d see To Change the Period of performance from 01/04/2016 to 01/08/2106 to 01/11/2016 to 01/15/2016, which was not using our newly minted date format. I couldn’t figure out a way to use the converters within the text without creating several computed labels (each with a rendered formula) to display the text. Then, I remembered my dalliance with SimpleDateFormatter.

So, within that control, I brought in the package and created a function that gets the field value as a Vector using getItemValueDateTimeArray and formats it using my chosen SimpleDateFormat. The text string gets built with four calls to that function and returns our text To Change the Period of performance from 04-Jan-2016 to 08-Jan-2016 to 11-Jan-2016 to 15-Jan-2016

<xp:text id="revisedPerformanceRange">
	<xp:this.value><![CDATA[#{javascript:function getFormattedDate ( doc:NotesDocument, fieldName:String ) {
	importPackage(java.text);

	var dateFormatter:java.text.SimpleDateFormat = new SimpleDateFormat("dd-MMM-yyyy");
	var d:Date = new Date(@Today());

	if ( doc.hasItem (fieldName) ) {
		var valueVector:java.util.Vector = doc.getItemValueDateTimeArray(fieldName);
		var iterator = valueVector.iterator();

		while (iterator.hasNext()) {
			var itemvalue = iterator.next();
			if ((typeof(itemvalue)).endsWith("DateTime")) {
				d = new Date(itemvalue.toJavaDate());
				return dateFormatter.format(d);
			}
		}
	} else {
		return fieldName + " is not on the document"
	}

}

var modNotesDoc:NotesDocument = modDoc.getDocument();

var revisedPerformanceRangeText = "To Change the Period of performance from ";
	
revisedPerformanceRangeText = revisedPerformanceRangeText + getFormattedDate(modNotesDoc,"PerfDate1") + " to ";
revisedPerformanceRangeText = revisedPerformanceRangeText + getFormattedDate(modNotesDoc,"PerfDate2") + " to ";
revisedPerformanceRangeText = revisedPerformanceRangeText + getFormattedDate(modNotesDoc,"RevPerf1Date") + " to ";
revisedPerformanceRangeText = revisedPerformanceRangeText + getFormattedDate(modNotesDoc,"RevPerf2Date");

return revisedPerformanceRangeText;}]]></xp:this.value>
</xp:text>

Took some fiddling to figure it out, but gave me exactly what I wanted, two different ways.

Categories: Java, Server-Side Javascript, Xpages | Tags: , , , , , | 2 Comments

Blog at WordPress.com.

%d bloggers like this: