TextBox not saving data
Oxygen general issues.
-
- Posts: 1
- Joined: Tue May 27, 2014 5:56 pm
TextBox not saving data
Hi,
I'm using the Author Component, and have set up some text boxes to edit attributes. The textbox data is only getting saved if you click outside the textbox before trying to save. If the textbox still has focus then it doesn't save.
Does anyone have any suggestions on how to fix this issue?
Thanks!
Ian
I'm using the Author Component, and have set up some text boxes to edit attributes. The textbox data is only getting saved if you click outside the textbox before trying to save. If the textbox still has focus then it doesn't save.
Does anyone have any suggestions on how to fix this issue?
Thanks!
Ian
-
- Posts: 1016
- Joined: Wed Nov 16, 2005 11:11 am
Re: TextBox not saving data
Post by alex_jitianu »
Hi Ian,
This is actually the intended behavior for a text field form control. It only commits the value when it loses focus or the user request the commit by pressing ENTER. There are some form controls that commit the value immediately, like for example a check box but like I've said, the text field is not one of them. You can enhance the built-in form control to auto commit by extending it, like so:
The next step is to pack this class inside a JAR and add it in the document type Classpath. To bind this custom form control you'll need a rule like this one:
Best regards,
Alex
This is actually the intended behavior for a text field form control. It only commits the value when it loses focus or the user request the commit by pressing ENTER. There are some form controls that commit the value immediately, like for example a check box but like I've said, the text field is not one of them. You can enhance the built-in form control to auto commit by extending it, like so:
Code: Select all
package simple.documentation.framework;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.JTextComponent;
import ro.sync.ecss.component.editor.TextFieldEditor;
import ro.sync.ecss.extensions.api.editor.AuthorInplaceContext;
import ro.sync.ecss.extensions.api.editor.EditingEvent;
import ro.sync.exml.view.graphics.Point;
import ro.sync.exml.view.graphics.Rectangle;
public class CustomTextFiledEditor extends TextFieldEditor {
private DocumentListener documentListener = new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
scheduleCommit();
}
@Override
public void insertUpdate(DocumentEvent e) {
scheduleCommit();
}
@Override
public void changedUpdate(DocumentEvent e) {
scheduleCommit();
}
};
protected void scheduleCommit() {
timer.stop();
timer.start();
};
private Timer timer = new Timer(400, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
fireCommitValue(new EditingEvent((String) getValue()));
}
});
public Object getEditorComponent(
AuthorInplaceContext context,
Rectangle allocation,
Point mouseLocation) {
JTextComponent editorComponent = (JTextComponent) super.getEditorComponent(context, allocation, mouseLocation);
// The editor is used only one time so there is no point to remove the listener.
editorComponent.getDocument().addDocumentListener(documentListener);
return editorComponent;
}
}
Code: Select all
para {
content: oxy_editor(
rendererClassName, 'simple.documentation.framework.CustomTextFiledEditor',
swingEditorClassName, 'simple.documentation.framework.CustomTextFiledEditor',
edit, '#text',
columns, 15)
}
Alex
-
- Posts: 1016
- Joined: Wed Nov 16, 2005 11:11 am
Re: TextBox not saving data
Post by alex_jitianu »
Hi Ian,
There are other two aspects that slipped my mind and might help you (sort of alternatives to the previous solution):
1. When the editor saves it's content, it automatically stops any form control editing session and commits its value. If you were to use WSEditorBase.save() then the form control would have committed its value. Next, if you had a Custom Protocol Plugin, this plugin would have received an update stream. I guess you are using WSEditorBase.createContentReader() instead (that call doesn't end the form control editing session)...
2. before calling WSEditorBase.createContentReader (basically before saving) you can make sure the form control editing session is ended by explicitly requesting the focus inside the author component:.
Best regards,
Alex
There are other two aspects that slipped my mind and might help you (sort of alternatives to the previous solution):
1. When the editor saves it's content, it automatically stops any form control editing session and commits its value. If you were to use WSEditorBase.save() then the form control would have committed its value. Next, if you had a Custom Protocol Plugin, this plugin would have received an update stream. I guess you are using WSEditorBase.createContentReader() instead (that call doesn't end the form control editing session)...
2. before calling WSEditorBase.createContentReader (basically before saving) you can make sure the form control editing session is ended by explicitly requesting the focus inside the author component:
Code: Select all
AuthorComponentProvider.getEditorComponent().requestFocus()
Best regards,
Alex
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ 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