Preventing content insertion
Oxygen general issues.
-
- Posts: 45
- Joined: Wed May 23, 2012 11:20 am
Preventing content insertion
I'm trying to restrict a user from entering more than 2000 characters for a given element. Whereby the content the user is trying to insert is ignored. I'm currently looking at the AuthoringListenerAdapter beforeContentInsert method and I can count the text content but I'm struggling to prevent the component from adding the text.
The other way I've thought of is to change and use the contentInserted method and then manually code for the removing of the inserted text. Which could get quite messy if there are nested nodes.
Can you please advise what the best approach will be?
The other way I've thought of is to change and use the contentInserted method and then manually code for the removing of the inserted text. Which could get quite messy if there are nested nodes.
Can you please advise what the best approach will be?
-
- Posts: 9446
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Preventing content insertion
Hi Neil,
We have an API method like:
AuthorDocumentController.setDocumentFilter(AuthorDocumentFilter)
and in the filter you can overwrite the method:
AuthorDocumentFilter.insertText(AuthorDocumentFilterBypass, int, String)
You can check which AuthorNode contains the offset:
AuthorDocumentController.getNodeAtOffset(int)
and then if that node is a certain node you can look at its start and end offsets to see how much content it has inside.
If it has too much content you can stop delegating to the "AuthorDocumentFilterBypass" the event.
Regards,
Radu
We have an API method like:
AuthorDocumentController.setDocumentFilter(AuthorDocumentFilter)
and in the filter you can overwrite the method:
AuthorDocumentFilter.insertText(AuthorDocumentFilterBypass, int, String)
You can check which AuthorNode contains the offset:
AuthorDocumentController.getNodeAtOffset(int)
and then if that node is a certain node you can look at its start and end offsets to see how much content it has inside.
If it has too much content you can stop delegating to the "AuthorDocumentFilterBypass" the event.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service