read-only attributes
Post here questions and problems related to oXygen frameworks/document types.
-
cristi_talau
- Posts: 517
- Joined: Thu Sep 04, 2014 4:22 pm
Re: read-only attributes
Post by cristi_talau »
Hello,
In Web Author an attribute can be edited either inline using a form-control or by using the "Attributes" side-view.
If you want an attribute to be read-only, you can remove from CSS any form-control that edits that attribute. Regarding the "Attributes" view, we have Java API [1] that allows one to completely hide the attribute from the UI. To use this Java API, you should create a plugin [2].
Best,
Cristian
[1] https://www.oxygenxml.com/InstData/Edit ... playFilter
[2] https://www.oxygenxml.com/doc/versions/ ... ugins.html
In Web Author an attribute can be edited either inline using a form-control or by using the "Attributes" side-view.
If you want an attribute to be read-only, you can remove from CSS any form-control that edits that attribute. Regarding the "Attributes" view, we have Java API [1] that allows one to completely hide the attribute from the UI. To use this Java API, you should create a plugin [2].
Best,
Cristian
[1] https://www.oxygenxml.com/InstData/Edit ... playFilter
[2] https://www.oxygenxml.com/doc/versions/ ... ugins.html
-
odovao
- Posts: 12
- Joined: Tue Oct 04, 2016 12:18 pm
Re: read-only attributes
Hi,
I have implemented a CustomProtocolPlugin (this is working fine) and also an AuthorAttributesDisplayFilter, however how do I activate the filter?
Looking at other threads in the forum, it seems that I need to do this via WSAuthorEditorPageBase. Where/how do I get an instance of WSAuthorEditorPageBase so that I can add the filter to it?
Thanks,
Oscar
I have implemented a CustomProtocolPlugin (this is working fine) and also an AuthorAttributesDisplayFilter, however how do I activate the filter?
Looking at other threads in the forum, it seems that I need to do this via WSAuthorEditorPageBase. Where/how do I get an instance of WSAuthorEditorPageBase so that I can add the filter to it?
Thanks,
Oscar
-
Gabriel Titerlea
- Site Admin
- Posts: 95
- Joined: Thu Jun 09, 2016 2:01 pm
Re: read-only attributes
Post by Gabriel Titerlea »
Hello,
To add your filter you can implement a ro.sync.exml.plugin.workspace.WorkspaceAccessPluginExtension and override the applicationStarted method:
To register the WorkspaceAccessPluginExtension you need to add it in the plugin.xml file of your plugin as follows:
Best,
Gabriel
To add your filter you can implement a ro.sync.exml.plugin.workspace.WorkspaceAccessPluginExtension and override the applicationStarted method:
Code: Select all
@Override
public void applicationStarted(StandalonePluginWorkspace pluginWorkspaceAccess) {
WebappPluginWorkspace workspaceAccess = (WebappPluginWorkspace) pluginWorkspaceAccess;
workspaceAccess.addEditingSessionLifecycleListener(new WebappEditingSessionLifecycleListener() {
@Override
public void editingSessionStarted(String sessionId, AuthorDocumentModel documentModel) {
documentModel.getAuthorAccess().getEditorAccess().addAuthorAttributesDisplayFilter(YOUR_FILTER_HERE);
}
});
}Code: Select all
<extension type="WorkspaceAccess" class="com.example.YourWorkspaceAccessPluginExtension"/>Gabriel
-
Stevee
- Posts: 16
- Joined: Wed Jan 12, 2022 6:17 pm
Re: read-only attributes
Hi
I seem to have the same/ similar Use-Case.
I want to make some Attributes of XML-Tags to be not editable via the Attributes-Side View and the In-place Attributes Editor in Author Mode.
Instead of Web Author, i am using OxygenXMLAuthor Eclipse Plugin v24.0
Greetings,
Steffen
I seem to have the same/ similar Use-Case.
I want to make some Attributes of XML-Tags to be not editable via the Attributes-Side View and the In-place Attributes Editor in Author Mode.
Instead of Web Author, i am using OxygenXMLAuthor Eclipse Plugin v24.0
Greetings,
Steffen
-
Radu
- Posts: 9556
- Joined: Fri Jul 09, 2004 5:18 pm
Re: read-only attributes
Hi Steffen,
Here are some possibilities:
1) Remove the attribute completely from being displayed in the Attributes view, using the API Gabriel mentioned above which works also in the Eclipse plugin:
https://www.oxygenxml.com/InstData/Edit ... layFilter-
2) Use the API to set a document filter:
ro.sync.ecss.extensions.api.AuthorDocumentController.setDocumentFilter(AuthorDocumentFilter)
and avoid changing the value for that specific attribute, but the end user might still get confused as the value will remain editable in the Attributes view but when it gets committed it will not be inserted in the document.
3) If you edit your DITA framework customization in the Oxygen Preferences->"Document Type Associations" page, in the "Extensions" tab there is an extension named "Author Custom Attribute Value Editor" which can be set by you to your own Java class:
https://www.oxygenxml.com/doc/versions/ ... ditor.html
Regards,
Radu
Here are some possibilities:
1) Remove the attribute completely from being displayed in the Attributes view, using the API Gabriel mentioned above which works also in the Eclipse plugin:
https://www.oxygenxml.com/InstData/Edit ... layFilter-
2) Use the API to set a document filter:
ro.sync.ecss.extensions.api.AuthorDocumentController.setDocumentFilter(AuthorDocumentFilter)
and avoid changing the value for that specific attribute, but the end user might still get confused as the value will remain editable in the Attributes view but when it gets committed it will not be inserted in the document.
3) If you edit your DITA framework customization in the Oxygen Preferences->"Document Type Associations" page, in the "Extensions" tab there is an extension named "Author Custom Attribute Value Editor" which can be set by you to your own Java class:
https://www.oxygenxml.com/doc/versions/ ... ditor.html
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
Dinesh
- Posts: 15
- Joined: Mon Feb 24, 2025 12:19 pm
Re: read-only attributes
Hi Radu,Radu wrote: ↑Fri Mar 11, 2022 7:55 am
3) If you edit your DITA framework customization in the Oxygen Preferences->"Document Type Associations" page, in the "Extensions" tab there is an extension named "Author Custom Attribute Value Editor" which can be set by you to your own Java class:
https://www.oxygenxml.com/doc/versions/ ... ditor.html
I have a similar use case in Oxygen XML Author. We have our own framework for DocBook, and I created a CustomAttributeEditor. However, I would like to know if there is a way to enable Oxygen's default attribute editing feature for all attributes except for a specific read-only attribute.
For example,
Code: Select all
@Override
public String getAttributeValue(EditedAttribute attribute, Object parentComponent)
throws CancelledByUserException {
// Show an error message if the attribute is read-only
if(attribute.getAttributeQName().equals("myattr")) {
PluginWorkspaceProvider.getPluginWorkspace().showErrorMessage("Editing the 'myattr' attribute is not allowed.");
throw new CancelledByUserException("Editing the 'myattr' attribute is not allowed.");
}
// Use Oxygen's default editor for other attributes, currently the example mentioned in the docs opens the JEditorPane, which results in loss of some features like combobox, etc, which we get for free in attribute view.
return super.getAttributeValue(attribute, parentComponent);
}Thanks,
Dinesh
-
Radu
- Posts: 9556
- Joined: Fri Jul 09, 2004 5:18 pm
Re: read-only attributes
Hi Dinesh,
So you have your own Java extensions bundle class which probably extends the base "ro.sync.ecss.extensions.docbook.DocBook5ExtensionsBundle" extension bundle or something similar, right?
Then you would overwrite this API which has a "shouldHandleAttribute" method:
As another possible approach we have an API "ro.sync.exml.workspace.api.editor.page.author.WSAuthorEditorPageBase.addAuthorAttributesDisplayFilter(AuthorAttributesDisplayFilter)" which would allow you to hide certain attributes from appearing at all in the Attributes view and other places.
https://www.oxygenxml.com/InstData/Edit ... ilter.html
Regards,
Radu
So you have your own Java extensions bundle class which probably extends the base "ro.sync.ecss.extensions.docbook.DocBook5ExtensionsBundle" extension bundle or something similar, right?
Then you would overwrite this API which has a "shouldHandleAttribute" method:
Code: Select all
/**
* @see ro.sync.ecss.extensions.api.ExtensionsBundle#createCustomAttributeValueEditor(boolean)
*/
@Override
public CustomAttributeValueEditor createCustomAttributeValueEditor(boolean forEclipsePlugin) {
return new CustomAttributeValueEditor() {
@Override
public String getDescription() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean shouldHandleAttribute(EditedAttribute attribute) {
// TODO Auto-generated method stub
return false;
}
@Override
public String getAttributeValue(EditedAttribute attribute, Object parentComponent)
throws CancelledByUserException {
// TODO Auto-generated method stub
return null;
}
};
}https://www.oxygenxml.com/InstData/Edit ... ilter.html
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
Dinesh
- Posts: 15
- Joined: Mon Feb 24, 2025 12:19 pm
Re: read-only attributes
Hi Radu,Radu wrote: ↑Tue Nov 04, 2025 12:54 pm
So you have your own Java extensions bundle class which probably extends the base "ro.sync.ecss.extensions.docbook.DocBook5ExtensionsBundle" extension bundle or something similar, right?
Then you would overwrite this API which has a "shouldHandleAttribute" method:
Thank you for the prompt response. Yes, you are correct—we have our own class that extends DocBook5ExtensionsBundle. I can override the shouldHandleAttribute method and display an error dialog, returning false if the attribute is read-only. This approach fits my needs exactly.
Regarding the use of AuthorAttributesDisplayFilter, this would require us to create a plugin, correct? We are a little concerned about using plugins because, if we want to update the functionality in the future, I don't think it is possible to automatically update the plugin on the technical writers' Author installations. That’s why we are leaning toward using a framework, as we can deliver updates more swiftly and reliably compared to a plugin, but I could be wrong.
Thanks again for your quick response. I will reach out if I encounter any issues.
Best regards,
Dinesh
-
Dinesh
- Posts: 15
- Joined: Mon Feb 24, 2025 12:19 pm
Re: read-only attributes
Hi,Radu wrote: ↑Tue Nov 04, 2025 12:54 pm So you have your own Java extensions bundle class which probably extends the base "ro.sync.ecss.extensions.docbook.DocBook5ExtensionsBundle" extension bundle or something similar, right?
Then you would overwrite this API which has a "shouldHandleAttribute" method:
Code: Select all
/** * @see ro.sync.ecss.extensions.api.ExtensionsBundle#createCustomAttributeValueEditor(boolean) */ @Override public CustomAttributeValueEditor createCustomAttributeValueEditor(boolean forEclipsePlugin) { return new CustomAttributeValueEditor() { @Override public String getDescription() { // TODO Auto-generated method stub return null; } @Override public boolean shouldHandleAttribute(EditedAttribute attribute) { // TODO Auto-generated method stub return false; } @Override public String getAttributeValue(EditedAttribute attribute, Object parentComponent) throws CancelledByUserException { // TODO Auto-generated method stub return null; } }; }
I just noticed that the getAttributeValue() method should return something, and I have to override this method since it’s abstract. I still need to get input from the user for all other editable attributes. If I return null, it won’t work, because as soon as I click on an attribute to edit in the Attributes view, it adds an empty string and stops.
Therefore, in this getAttributeValue() method, I want to get the string value using Oxygen’s input mechanism—such as input from the default text field in the Attributes view itself, etc. Is that possible?
-
Radu
- Posts: 9556
- Joined: Fri Jul 09, 2004 5:18 pm
Re: read-only attributes
Hello Dinesh,
So:
(1)
(2)
Regards,
Radu
So:
(1)
Not necessarily, in your DocBook5ExtensionsBundle you could do something like this:Regarding the use of AuthorAttributesDisplayFilter, this would require us to create a plugin, correct?
Code: Select all
/**
* @see ro.sync.ecss.extensions.docbook.DocBook5ExtensionsBundle#createAuthorExtensionStateListener()
*/
@Override
public AuthorExtensionStateListener createAuthorExtensionStateListener() {
AuthorAttributesDisplayFilter filter = new AuthorAttributesDisplayFilter() {
/**
* @see ro.sync.ecss.extensions.api.attributes.AuthorAttributesDisplayFilter#shouldFilterAttribute(ro.sync.ecss.extensions.api.node.AuthorElement, java.lang.String, int)
*/
@Override
public boolean shouldFilterAttribute(AuthorElement parentElement, String attributeQName,
int source) {
return "id".equals(attributeQName);
}
};
AuthorExtensionStateListener superListener = super.createAuthorExtensionStateListener();
return new AuthorExtensionStateListener() {
@Override
public String getDescription() {
return null;
}
@Override
public void deactivated(AuthorAccess authorAccess) {
superListener.deactivated(authorAccess);
authorAccess.getEditorAccess().removeAuthorAttributesDisplayFilter(filter);
}
@Override
public void activated(AuthorAccess authorAccess) {
superListener.activated(authorAccess);
authorAccess.getEditorAccess().addAuthorAttributesDisplayFilter(filter);
}
};
}If you return false on the "shouldHandleAttribute" callback for all other attributes which should remain editable, then they should be handled as usual in the Attributes view.I just noticed that the getAttributeValue() method should return something, and I have to override this method since it’s abstract. I still need to get input from the user for all other editable attributes. If I return null, it won’t work, because as soon as I click on an attribute to edit in the Attributes view, it adds an empty string and stops.
Therefore, in this getAttributeValue() method, I want to get the string value using Oxygen’s input mechanism—such as input from the default text field in the Attributes view itself, etc. Is that possible?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
Dinesh
- Posts: 15
- Joined: Mon Feb 24, 2025 12:19 pm
Re: read-only attributes
Hi Radu,
Thank you for the clear explanation. I was able to resolve this using the CustomAttributeValueEditor. After going through the documentation, I now understand what you meant.
For anyone in the future who wants to make an attribute read-only:
By asking the custom editor if it wants to handle editing, you determine whether the getAttributeValue function you override will be called. If shouldHandleAttr function returns true, then your custom getAttributeValue will be invoked. Therefore, if you want an attribute to be read-only, you just need to throw an exception or display an error message in the getAttributeValue function.public boolean shouldHandleAttribute(EditedAttribute attribute,
CustomAttributeValueEditingContext editContext)
Ask the custom editor if it wants to handle editing for a certain attribute in a certain context.
For all other attributes that should remain editable, return false; this will tell Oxygen to use its own editor to get the input.
An example would look something like this:
Code: Select all
return new CustomAttributeValueEditor() {
@Override
public String getAttributeValue(EditedAttribute editedAttribute, Object o) throws CancelledByUserException {
// This function is only called when the shouldHandleAttribute returns true.
String attributeName = editedAttribute.getAttributeQName();
String message;
message = "The '" + attributeName + "' attribute is read-only.";
PluginWorkspaceProvider.getPluginWorkspace().showErrorMessage(message);
throw new CancelledByUserException(message);
}
@Override
public boolean shouldHandleAttribute(EditedAttribute editedAttribute) {
return editedAttribute.getAttributeQName().equals("id");
}- Dinesh
Return to “SDK-API, Frameworks - Document Types”
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