Add textfield for Classes in cq dialog - maven

If we want to add an Id to an AEM Core component such as image, there is this field:
.content.xml
<id
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldDescription="HTML ID attribute to apply to the component."
fieldLabel="ID"
name="./id"/>
which gives this textfield in the dialog.
But what if we want to create the same textfield, but for CLASSES instead? The core components only seems to use the "./id" name, and nothing for classes.
As you can see I am an absolute beginner, so any pointer or help is much appreciated.
--- Edit (June 17, 2022):
Following Vlad's answer, I needed to narrow down where I am having issue:
I don't know how to "add a textfield for classes". For example, the id field has name="./id" in the xml, which can be accessed as "${image.id}" in the html. But the same doesn't exist for Classes.
How would the Textfield look like if I am adding it for Classes? Like this one obviously wouldn't work as "./class" is not connected to anywhere.
<class
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldDescription="HTML CLASS attribute to apply to the component."
fieldLabel="CLASS"
name="./class"/>
I guess that the name="./id" of the Textfield is tied to some Java logic so we can retrieve it via "${image.id}". I have looked at image's java code, but don't see how they tied together.
I would need to understand the Java code in order to override it. Or am I missing anything and there is an easier way? Again, absolute beginner here.

You can override the dialog and add a textfield for classes, then overlay the HTL script and inject the classes in the markup. However, I recommend you look first into the OOTB Style System. It allows you to define classes in the component’s policy and then use them in the editor (they will be added on the component wrapper element).

Related

how to remove image from image field?

I created check box with ON and OFF option. When click on "ON" option then image show. I want to when click on "OFF" option then image remove or image filed empty
How to achieve this target in oracle forms 10g?
I don't think you can do this.
As someone suggested it, you could have thought using SET_ITEM_INSTANCE_PROPERTY (this one only applies to the current record). However, you cannot modify all the properties, only few of them : BORDER_BEVEL, INSERT_ALLOWED, NAVIGABLE, REQUIRED, UPDATE_ALLOWED and VISUAL_ATTRIBUTE.
Check the documentation of this method here (Oracle Forms v6i) : https://docs.oracle.com/cd/A97335_02/apps.102/a73074.pdf
One of the best solution you may find should be to make a custom Java Bean item which would handle this behavior. However be careful, Java Beans don't work correctly when used in a multi-records blocks. If your checkbox is used within a single-record block, it should be OK.
Here are some of my references to create your own Java Beans :
http://devtalks.blogspot.com/2008/07/creating-and-using-java-beans-in-oracle.html
http://forms.pjc.bean.over-blog.com/
https://www.baigzeeshan.com/2010/02/how-to-add-java-bean-by-writing-your.html

How to make admin-on-rest render a custom list component?

I am using this to build a admin UX https://github.com/marmelab/admin-on-rest and it seems to fit perfectly into what I want to build except one feature:
My work project needs to display a tree grid to display groups or subgroups of items in a tree form and also to show a drop-down to display and select a grouping field.
I think this is what is needed to achieve this:
a) Write a custom "Datagrid" which I am able to write
b) Custom "List" component to show grouping combo
c) Add custom List actions to add '_grouping' parameter to the REST request
I am unable to pass my list component to 'Resource' since it breaks the whole app rending / events logic. In OO programming lingo this will be called a classic sub classing but React framework does not support it.
What would be a proper way to achieve this functionality ?
PS: I am new to react, redux, saga so please excuse me if this is already supported in admin-on-rest. I would appreciate if such feature is possible or can be added without forking the whole repo ( modifying the existing )
I don't think you need to implement a custom <List> component for that need. A replacement for <Datagrid> should to the trick. You just need to add a custom action button, and you've already localized the place to add it to (<List actions>).
Try like this first, and then if it doesn't work (but you'll have to illustrate why), I can maybe look into replacing the <List> component.

Organizing i18n source file for data binding

I have a SAPUI5 SplitApp application written in English. There is a need to add translation into another language.
I have already made changes to all my detail views using this documentation and I have used the first approach (jQuery.sap.resources). All translations are in WebContent>i18n>i18n.properties file and in another .properties file for another language. And it works.
The problematic part is my main menu that is situated on the master page. To build my main menu I use data binding approach. Here are the elements of the menu and how I bind them: JSBIN.
I still want to use data binding for the master page.
What is the best way to create/organize file with menu elements and file with translation of those elements?
I don't quite get your question.
You want to use Databinding for your controls and for your i18n - that's not a problem, just use two models and give one of them a name.
var oModel = [The model with the data]
var oModeli18n = [The i18n model]
sap.ui.getCore().setModel(oModel);
sap.ui.getCore().setModel(oModeli18n, "i18n");
Now you can bind your normal data using just the paths, e.g. in an XML-View:
<Text text="{title}" />
You can bind to the i18n model by just prefixing the path with the model name you set before:
<Text text="{i18n>SOME_TEXT}" />
You can use this approach with any type of model and choose any name you want to.
If I did not answer your question, please explain your problem in more detail.
Update:
I used your code to make a working simple example of the basic binding:
http://jsbin.com/wafecaqezu/1/edit?html,js,output
You just have to add the bundle...

Orchard CMS widget Display Type

I have a widget which is using a query to display details. Is it possible to specify the display type of the widget (the query is using Summary and all is displayed as i want) because the header of the widget has a display type of Detail and i want it to use summary so i can override the shape when i place it in different sections (mainly the header text), but when in the content zone i would want it to be details. I am using the bootstrap theme. So basically if i stick my widget any where other than content i want it to use summary
Hope this makes sense.
Thanks
Ah, we meet again.
Widgets are built and injected into the layout in a class called Orchard.Widgets.Filters.WidgetFilter. There doesn't appear to be any way to modify the display type used for a widget (the default WidgetFilter uses the default value of "Detail").
To get around this, you can use your own implementation of WidgetFilter. Copy the existing code into your own class, and add an [OrchardSuppressDependency("Orchard.Widgets.Filters.WidgetFilter")] attribute to your class. This will make sure that the existing WidgetFilter isn't used, and yours is.
If you read through the OnResultExecuting method, you'll see that right near the end there is a call to BuildDisplay. The second argument to this method can be a display type. You can check widgetPart.Record.Zone to see where the widget has been placed, and pass in different values for the displayType parameter accordingly.
I'm not sure if this is the most elegant way, but it's where I'd start. Perhaps someone else might have a neater solution.

How to make derived textbox and toolstriptextbox use same code in Vs2010

I've created a derived WinForm textbox control that knows how to provide a hint (those grayed out words that say things like "Password" or "Enter search here") as well as allowing for the beep on enter to be disabled.
I have two public properties BeepOnEnter, and HintText, a single method - ResetHint and then overrides for the Text property, the OnGotFocus event and the OnKeyPress event.
This code works fine until I have a need for a textbox on a tool strip also known as a ToolStripTextBox.
I'd like to use the same code for both the TextBox AND the ToolStripTextBox. Is there a way minimize/reduce redundancy? I definitely need code that has classes that are derived from TextBox and ToolStripTextBox so the ui designer allows me to drop these new controls on a form or tool strip but can't figure out how to do it in an OO way.
ToolStripTextBox is derived from ToolStripControlHost and TextBox is derived from TextBoxBase and as multiple inheritance is not allowed, you will be best off creating a 3rd utility class and putting all similar functions in it. You can then leverage an instance of this class in your derived controls to get the common functionality you want.

Resources