How to put limitations on size & no. of characters in JTextArea? - jtextarea

I'm developing an application that requires a textarea to be used in which no. of characters are restricted to 165. I made an object of JTextArea with row & column no. 3,3 respectively but it didn't work as when I went on typing, the size of 'Textarea' went on increasing.How to restrict that? As I've used 'DocumentListener' for noting no. of characters typed,deleted,cut and pasted, I'm getting problem when suddenly the size of textarea is increased.
Thank you!

What you want is a javax.swing.text.DocumentFilter. This enables you to filter changes to the Document which holds the underlying text of JTextArea. There are tutorials linked to from the class description for that and related classes.
The example here shows how to limit the number of characters in the document.

Use a key Listener instead of Document filter
.

Related

XPages typeAhead does not work If you have so many documents

TypeAhead works fine If you don't have so many documents. If i delete lots of them typeAhead works. I think there is a limitation #DbColumn() in typeahead option.
How to solve this problem? It's like a 64k size problem but any suggestion is important
Thanks in advance
C.A.
Are you using #DBColumn() or #DBLookup() to populate your typeahead? They do have 64K limits. (I'm not sure as I read your question, so I ask for clarification).
If so, you might want to consider looking at links like this Can typeahead results be returned from a java function,
I've recently done one with a massive number of documents (millions). I used this, but since it was taking a lot of time to return, I changed it to get the first selected entry in the view (based on the value from the AJAX typeahead), created a ViewNavigator from that entry, and used the setBufferMaxEntires property to restrict the size of the returned ViewNavigator. This lets the process go quite fast.
Brian
UPDATE:
As requested. I started with using results like I linked above, then I added
ViewEntry startEntry = canQLView.getEntryByKey(searchValue, false);
allObjects.addElement(startEntry);
if (startEntry != null) {
ViewNavigator matchingEntries = canQLView.createViewNavFrom(startEntry);
matchingEntries.setBufferMaxEntries(10);
ViewEntry entry = matchingEntries.getFirst();
You can see I get a single entry rather than a ViewEntryCollection, start my ViewNavigator from that entry, and the setBufferMaxEntries property restricts how much is fetched - you can change it, but a low number is sensible since it's a typeahead.
Cheers,
Brian
Correct, there is the 64Kb limit on #DbColumn(), it's not an XPages-specific limitation and various blog posts confirm it. Ensure typeahead is only provided once the user has entered an appropriate number of characters that can restrict. After all, the typeahead should return a small number of entries for the user to select from, otherwise it's not much use. Then use #DbLookup with "[PARTIALMATCH]" or getAllEntriesbyKey. There are a number of blog posts available that give code samples.

viewJsonService returning too many entries to dataGrid

I've set up an ExtLib REST service as "xe:viewJsonService" and connected it to a domino view. Currently the view contains 63 entries. The documents behind those entries have read access restrictions.
The Json returned by the service is consumed by a Dojo Data Grid (taken from the ExtLib libraries).
The page is accessed by a test user having read access to only one of the 64 entries. This user however sees a data grid containing a single data element, followed by 63 empty entries, like this:
Looking at the raw Json data I see that the service indeed is only returning a single entry, but it knows that there are 63 siblings:
[
{
"#entryid":"1-6C5763E4A122F1D3C1257EC700355386",
"#unid":"6C5763E4A122F1D3C1257EC700355386",
"#noteid":"3FD2E",
"#position":"1",
"#read":true,
"#siblings":63,
"#form":"fInvoice",
"colIconStatus":"imgInvExported.gif",
"colIconLock":"blank.gif",
"invInvoiceDate":"2015-09-21T09:44:27Z",
"invJobInvNumbers":"111\/5152\/52567\/ 001",
"invSupplierNameShort":"My Test Company GmbH",
"invAmount":121.5
}
]
Technically speaking this is correct as the service has access to all 64 entries. Problem is that the data grid is making space for 64 entries instead of only one.
Question is: how can I tell the data grid the correct amount of data to be displayed? Or do I need to manipulate the REST service instead?
EDIT: continuing my search for a possible solution in meanwhile found a few other related questions this one by Eric McCormick (including a very good approach by Stephan Wissel), or this one by Steve Zavocki. So my question would be a duplicate, really... (sorry for that)
Caveat: please read down to the bottom of this answer as you might run into unexpected ussues!
Finally after some playing around I just stumbled upon an obscure property that seems to help, for whatever reason (I'll be making this a new question):
the property globalValues appears to be available for service types xe:documentJsonService, xe:viewItemFileService, xe:viewJsonLegacyService, xe:viewJsonService and xe:viewXmlLegacyService. this property has three fixed options called Entries (= 0x0001), Top Level (= 0x0002) and Timestamp (= 0x0004). Just by playing the goold old "trial-and-error" game I found that setting this property to 1 (= Entries) modifies / filters the resulting data:
by default the raw JSON returned by xe:viewItemFileService looks like this:
{
"#timestamp":"2015-10-14T12:57:59Z",
"#toplevelentries":63,
"items":
[
{
...
}
]
}
Setting globalValues to "1" removes the #timestamp and #toplevelentries fields from the output:
{
"items":
[
{
...
}
]
}
And, more importantly, this also removes the empty rows from my data grid!
There's only one thing that's making me nervous and that is that I can't find any explanation at all in regards to that property. So I really don't have a clue whether there are any unwanted side effects...
Update: thanks to Knut Herrmann I did some more testing on this (see comments below this answer). In my test case there are over 13,000 documents in my view; as long as my test user can only read a small amount of those everything seems to be fine. Then I added 200 more documents to the read-enabled list. Result is a data-grid that constantly has to recalculate its scroll bar: the further down I'm scrolling the smaller the scroll handle gets. As soon as I reach the bottom line however the grid goes berzerk and decides to only display the first 13 (?!?) rows, and also the scroll bar is removed alltogether. Performance isn't as bad as I expected, though.
So I have to agree with Knut that this isn't such a good solution for the combination of large views with a large subset of accessible entries!
Lothar,
I have experienced this before as you pointed out. I believe the answer is to use the 'keys' property to filter out the invalid entries.
I am not sure about how your application is structured, but if the user can only see certain entries in the view, I would consider categorizing by user, and then use the keys to show them only the rows in which they have access.
You asked if you can change the dojo grid to exclude the entries. I think the answer there is no. Your options are to filter via the REST service or via the Notes view.
Here is a related blog post that I wrote on the issues I was having. http://notesspeak.blogspot.com/2013/07/creating-updatable-rest-service-for-use.html
EDIT 2 Additional Things to Try
1) Did you see the comment on my blog post? I haven't tried it myself. Credit goes to blog comment-er "Goo Goo".
"I use this code in onstyleRow event of the grid to solve the blank rows issue "
which using viewJsonService:
var row = arguments[0];
var rowItem = djxDataGrid1.getItem(row.index);
var rowCount = Object.keys(restService1._index).length - 1; //-1 for omit the onUpdate event
if(row.index >= rowCount){
row.customStyles += 'display:none;';
}
2) What I personally did to fix the issue is in this SO answer: How to configure an xe:viewFileItemService on an XPage to filter the data in a categorized view?
Given what you said about your view structure, I am not sure that this will apply to you.

Show more than 30 attachments in document?

I am using a "document library" (template: StdXLWebXDocLib).
I can record more than 30 files(attachment) in the same document, but I can only see 30.
Even if I change the Row value.
Is this a XPAGES bug ?
Anyone know the solution?
(with the Notes client, I see them all)
Thank you for your help.
Search in database for string "xp:fileDownload" in Designer. It will show you as result:
Replace in all three design elements rows="30" with rows="0". Then it will show always all attachments.
Afaik the default entries per page of the xpages repeat element (which might be used in this case) is 30. They might just not have added a pager to it.
I don't know that template but if you mean the File Download control you can set the value of the lines to display to 0 to not restrict them so that you can see all attachments available.
You can find that property in "All properties, data, rows".

iText page number references

I am generating a large document that will have many references to other pages in the document. For instance, the text might say:
"This topic is covered in Chapter 46 (see page XX)."
or
"See the chart on page XX"
Since I don't know the page number ahead of time, my initial thought was to create the PDF in multiple passes, as outlined in "iText in Action", chapter 6. However, as I understand it, this would not work because the PDFStamper cannot edit existing chunks of text once they are created. My second thought is to create the document twice. The first time, I would create the document and simply make a hashmap of referenced places in the text and page numbers. The second time, I would use those to generate references.
Is there a better way to do this?
Create a PdfTemplate as placeholder for all the unknown data, store these in an array.
Mark the referred text with onGenericTag() and fill out the templates stored in the array with the page number.
Main problem: how to define the size of the PdfTemplate? That problem can't be solved.

design email body

here it goes, i have this code
#MailSend(sample1;sample2:sample3; "";"sample, #"+number;
"Good Day! " +#NewLine+ "
Please click the link to see details of the sample for your Reference.. " +#NewLine+ "
sample Details: ----->"+Category_1++#NewLine+"
Material 1----> "+Mat_1+#NewLine+"
Material 2----> "+Mat1_1+#NewLine+"
Material 3----> "+Mat2_1+#NewLine+"
Material 4----> "+Mat3_1+#NewLine+"
Material 5----> "+Mat4_1+#NewLine+"
Material 6----> "+Mat5_1+#NewLine+"
Material 7----> "+Mat6_1+#NewLine+"
Thanks "+#NewLine+" ";"";[IncludeDoclink])|
#Command([FileSave])|
#Command([CloseWindow]))
i wondering if i in this format how can i put table? like table view in php or table form.
Unfortunately in this format you can only add an ASCII grid, meaning you can add pipe and dash characters to present what appears to be a grid, and use a fixed width font with spaces to line up each column of data. Though, you can't set the font with this method either, sadly.
You can build the entire email using LotusScript, though, using the rich text classes, including constructing the table programmatically.
In #MailSend, Your body content parameter is a text. So you can not insert any objects using #MailSend function.
If you want to insert any objects into the body content, You have two different ways.
One is Lotus script. You can use the NotesrichTextItem class for manipulating the body field.
Another way is #Formula, But it is not the straight way, You can use #Command(EditInsertTable) and #DialogBox("Memo")
No, you would have to write LotusScript or Java code to do that. The Notes forumula language can only deal with simple text messages.

Resources