Thu 7 May 2020
Can we get a huzzah for updated Domino Limits?
Wed 29 Apr 2020
A bigger boat: when in Rome
Mon 27 Apr 2020
HCL Notes 11 - Quick Intro to features and enhancements
Rich text manipulation in Java? From R5? Using @Midas?
Thu 18 Sep 2003, 10:02 AMTweet
by Ben Langhinrichs
As a follow up to yesterday's post on @DbColumn/@DbLookup on rich text tables, one of the questions I get about our beta @Midas Formulas is "Where would you use it?" While there are lots of answers, one that might not be obvious is "From Java".
Because Java offers the ability to evaluate formulas, it can call an @Midas formula and either get the results or simply make the change. No configuration or special linking or translation layers of JNI. If the @Midas software and license are on your server or client, Java can use them. This works in ND6, R5, and might even in R4.6, although I can't recall whether the evaluate method was available from Java then.
So why would this matter? What might you want to do from Java with rich text. [NB: Lotus clearly doesn't think you want to do much, as their rich text manipulation from Java is seriously lagging even the small amount of rich text manipulation they offer from LotusScript. But I digress...]
Three simple examples come to mind. The first is based on yesterday's post. If you have a rich text table and want to look up a column of data, you could use code such as the following:
Vector v=session.evaluate("@DbColumn(\"Midas\":\"NoCache\"; \"\"; @DocumentUniqueID; \"Body\"; 2; \"Format='Currency' SkipTitle='Yes' \");", doc);
This would give you a vector array of numeric values you could then use as you needed. Pretty simple, and no other configuration or setup required. Escaping the quotes is a bit annoying, but other than that, it is a lot easier even than getting the same information using the Midas Rich Text LSX, where you would have to connect, define the table chunk, loop through the rows, etc.
The second sample uses a different feature of @Midas, which is the ability to convert rich text to HTML. With the following simple code snippet, you could retrieve the HTML for the content inside a particular table cell in a rich text field. This HTML fragment and others like it could then be used to build a webpage dynamically based on choices made in the Java code.
Vector v=session.evaluate("@DbCommand(\"Midas\":\"NoCache\"; \"Connect\"; \"\"; @NoteID; \"Body\"; \"GenerateHTML\"; \"Table 2; Row 2; Column 3\"; \"HTML\"; \"Generation=Fragment MoveStylesInLine=yes ImageRelativeToPage=yes \")", doc);
The third example uses search and replace to modify the form stored in a document, thus allowing the form to be dynamic:
Vector v=session.evaluate("@DbCommand(\"Midas\":\"NoCache\"; \"Connect\"; \"\"; @NoteID; \"$Body\"; \"ReplaceText\"; \"Dollars\"; \"Euros\"; "Text"; ; \"Save\")", doc);
So, whether Java is your cup of tea or not, you can see how relatively easy it would be to add rich text functionality to a Java agent by add a little simple @Midas code. If you would like to sign up for the beta test, we are planning on sending out a new beta release shortly. If you are already signed up, even if you haven't received a beta yet, you will be contacted automatically.
Copyright © 2003 Genii Software Ltd.
What has been said: