Oracle Apex Rich Text Editor - Unable to configure Read Only Mode - oracle-apex

Oracle Apex 22.2.1
Rich Text Editor
initialization code
function(options){
// disable the Autoformat feature
options.editorOptions.removePlugins.push('Autoformat');
options.editorOptions.enableReadOnlyMode( 'my-feature-id' ); //Also replaced my_feature_id with true
// apply a custom toolbar
options.editorOptions.toolbar = [
'heading', 'bulletedList', 'numberedList', 'fontSize', 'undo', 'redo'
];
return options;
}
I get the following error when the code is run with either an id or the boolean true:
TypeError: options.editorOptions.enableReadOnlyMode is not a function
What am I missing?
Thanks

Koen Lostrie gave me the correct answer of using the native apex page item read only attribute. Do not use the rich text editor method to set it to read only.

Related

Attachments moved away from Item after validation and before submit process in Apex

I have multiple File Browser Item fields on one page of Application in Oracle Apex.
What happens: When I miss any Item for which validation error fires, I want to hold that file to the browser but I usually loose it if I get that validation error. Is there a solution for the same like other Items fields hold previous value except File Browser Item field. Please see below ss:
Anshul,
APEX 4.2 is very old and no longer supported. A later (or preferably latest) version of APEX will behave differently as Dan explained above.
Can you import your application into apex.oracle.com (which is running APEX 20.1) and you will probably see better results. Based on this you can hopefully use it as justification to upgrade your environment.
Regards,
David
Go to your page-level attributes and a function like the following in the Function and Global Variable Declaration:
function validateItems(request) {
var $file1 = $('#P68_FILE_1');
var $file2 = $('#P68_FILE_2');
var errorsFound = false;
if ($file1.val() === '') {
errorsFound = true;
// Show item in error state
}
if ($file2.val() === '') {
errorsFound = true;
// Show item in error state
}
if (!errorsFound) {
// I think doSubmit was the name of the function back then. If not, try apex.submit
doSubmit(request);
} else {
// Show error message at top of page, I'll use a generic alert for now
alert('You must select a file for each file selector.');
}
}
Then, right-click the Create button and select Create a Dynamic Action. Set the name of the Dynamic Action to Create button clicked.
For the Action, set Type to Execute JavaScript Code. Enter the following JS in code:
validateItems('CREATE');
Finally, ensure that Fire on Initialization is disabled.
Repeat the process for the Save button, but change the request value passed to validateItems to SAVE.

How to create sitecore dialog with XML and ShowModalDialog

I created a CopyToMarkets.XML dialog file based off of the \Dialogs\CopyTo.XML file:
And attempting to open the dialog with:
Context.ClientPage.ClientResponse.ShowModalDialog("/sitecore/shell/Applications/Dialogs/Copy To Markets.aspx", "1200px", "700px", string.Empty, true);
It just turns grey and nothing happens.
However when I use ShowModalDialog with Copy To.aspx it shows up fine.
I'm new to sitecore so maybe I'm misunderstanding something but basing my understand of creating content editor ui form this tutorial: https://sitecorejunkie.com/2012/12/12/put-things-into-context-augmenting-the-item-context-menu-part-2/
Let me know if this isn't the correct/modern method of creating new editor dialogs!
I ended up building my url like this:
string url = Sitecore.UIUtil.GetUri("control:CopyToMarkets");
Context.ClientPage.ClientResponse.ShowModalDialog(url, "400px", "700px", string.Empty, true);

Oracle APEX - how i can change translate action menu language (interactive grid and report)

I'm trying to change the language of default UI elements language in my APEX application to Arabic language :
i change the button (excepted interactive button) and column header language using XLIFF file , but i can't change action menu language , how i can do that if it possible.
You have to create new "messages":
Try to find message id:
select *
from APEX_APPLICATION_TRANSLATIONS
where WORKSPACE = 'INTERNAL'
and message_text = 'Subscription';
Copy TRANSLATABLE_MESSAGE field value (e.g. APEX.IG.SUBSCRIPTION or APEXIR_SUBSCRIPTION) and remember IS_JS_MESSAGE value
Go to Shared Components -> Globalization -> Text Messages -> Create Text message
Put id id name field (APEX.IG.SUBSCRIPTION)
Select your language
Fill "Text"
Select the same value as already exists in field IS_JS_MESSAGE
Your application language must me the same with this new message.

Unchecking checkbox in oracle apex

Created an report with checkbox using apex_item and when checked more than one check box i will display alert message "not to check more than one checkbox with ok button " after clicking ok it should be unchecked . please find my JavaScript code that displays alert message
if($("input[type=checkbox]:checked").length > 1)
{
var msg = alert('You are not allowed to select more than one employee');
}
It's best to use the APEX JavaScript APIs for this type of thing. You can find them here: https://apex.oracle.com/jsapi
If you're getting started with JavaScript and APEX, you may find these slides useful: https://www.slideshare.net/DanielMcGhan/getting-started-with-javascript-for-apex-developers
Here's a solution that should work for you (just change the name of the item to match yours):
var cbItem = apex.item('P1_CHECKBOX');
if (cbItem.getValue().length > 1) {
alert('You are not allowed to select more than one employee');
cbItem.setValue(); // Passing nothing to clear the value
}

Sitecore 8 MVC : How to make the field editable in Page Editor

I'm trying to make my Sitecore site compatible with page editor i.e. all the fields text, rich text editor, etc, should be able to be updated in Page Editor.
So far I've modified the TDS T4 template which returns a HTMLString for each field like below:
public HtmlString HeroImageField(bool isEditable = true, string parameters = "")
{
string renderParameter = GenerateRenderParameter(isEditable, parameters);
return new HtmlString(Sitecore.Web.UI.WebControls.FieldRenderer.Render(
Sitecore.Context.Database.GetItem(this.EntityId.ToString()), "Hero Image", renderParameter ));
}
So, in view I just call Model.HeroImage()
Is there a better way to achieve above? Maybe Glass Mapper comes with out of box support for this (which I don't know).
Sitecore comes with MVC helpers that you can use to make fields editable:
#Html.Sitecore().Field("My Field Name") //Context item by default
#Html.Sitecore().Field("My Field Name", Model.PageItem) //Explicit page item
#Html.Sitecore().Field("My Field Name", Model.Item) //Datasource item (may be context item)
My recommendation is also to use a controller to load a different view for editing. There is often a different visual needed for authoring fields. Carousels/tabs should be flattened out, validation messages need to be exposed, etc.
See more at:
http://sitecore-community.github.io/docs/sitecore-mvc/rendering-content/
Glass mapper has something OOTB for that. You can use the extended WebViewPage GlassView and use the Editable methods as described here:
http://glass.lu/Mapper/Sc/Tutorials/Tutorial14