Group AEM (6.2) component configurations - aem

I'm currently building a component that has TouchUI configuration properties separated with three tabs (Standard, CASL, GDPR). Each tab has the same set of options available and my current config names are similar to the following:
./standardMarketingText
./standardThirdpartyText
./gdprMarketingText
./gdprThirdpartyText
./caslMarketingText
./caslThirdpartyText
(There are several other options for standard,gdpr,casl but I left them out for brevity)
While this works, I'm hoping to instead store the values in the JCR as a JSON node per category. For example:
casl = {"marketingText"="m test", "thirdpartyText"="tp test"}
gdpr = {"marketingText"="gdpr m test", "thirdpartyText"="gdpr tp test"}
This way I can load all "casl" (or others) options at once when I need them (there isn't a case where I would only load one "casl" option)
I have attempted using granite/ui/components/foundation/form/multifield however, it asks to "Add field". I only want one set of each, and not provide the ability to add another set of properties under each tab. Is there a way to accomplish this without overriding the multifield resourceType?

There are multiple ways to achieve what you are looking at, I would look at the reusability as there are similar named properties for different categories (in your case tabs). To group them you could do that at node level by correctly defining the name property for each tab.
For above provided values, you could do something like -
./standard/marketingText
./standard/thirdpartyText
./gdpr/marketingText
./gdpr/thirdpartyText
./casl/marketingText
./casl/thirdpartyText
Your each tab stores the properties in named node (standard, gdpr, casl). In addition you could have a single SlingModel/WCMUsePojo that can adapt to these nodes to provide the Pojo with accessor to property values.
As far as getting JSON is concerned, your SlingModel or WCMUsePojo can provide a method to return JSON based string for the values.

Related

Difference between currentstyle and currentdesign in AEM

In AEM speak - what is the exact conceptual difference between between currentstyle and currentdesign objects available after including the tag in template / component?
Just to add some clarify to what's already here:
Global content (that is, component values that are common across multiple instances of the same template) are stored as "styles" and edited via a "design dialog".
They are stored as follows:
/etc/designs/<design>/jcr:content/<template>/<component>
So, for the component logo in the template homepage, using the default design:
currentStyle is /etc/designs/default/jcr:content/homepage/logo
currentDesign is /etc/designs/default
currentStyle is of type com.day.cq.wcm.api.designer.Style(1) whereas currentDesign is an instance of com.day.cq.wcm.api.designer.Design (2).
The Design object contains information about the design that is used with the current object, it is most of the time set in the cq:designPath property of the page's template.
If you have the Design object, you can get Style objects for each included Cell(3) from it. On the other hand you can get the surrounding Design, if you have the Style.
So the Design is something like a container object for the Styles used in the included Cells.
In this path
/etc/designs/geometrixx/jcr:content/page/image
image is a Cell, the design path is /etc/designs/geometrixx and the Style object attached to the Cell object has two properties: maxHeight and maxWidth.
(1): https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/index.html?com/day/cq/wcm/api/designer/Design.html
(2): https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/index.html?com/day/cq/wcm/api/designer/Style.html
(3): https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/index.html?com/day/cq/wcm/api/designer/Cell.html
I would say it is more like:
/etc/designs/<design>/jcr:content/<resource-type-of-page>/<component>
so that different templates having the same page resource type will share the same style

Configure symfony2 automatic form label generation

I'd like to know if there is a way to configure, disable or otherwise override the way Symfony handles automatically generating form labels for entity properties.
We also use the Sonata Admin Bundle and Symfony native and Sonata do not always produce the same label for complex form fields based on a given entity property, specifically when adding related entity properties e.g. something.somethingRelated. Sometimes it seems there is an extra space added to the label string (where the "dot" is) so we end up with two different labels being generated for the exact same property in two different forms.
Sonata has a configuration that allows some control over how the label is generated; e.g underscores, native, do nothing, etc.
We are trying to get our translations under control but still use the automatic generation of form labels rather than having to add a label (key) to each form field.
Right now I think my best alternative is to just turn it off in Symfony and let the actual property name be the "string" that is generated without any processing on it. So, thisIsTheProperty would have an automatically generated label string "thisIsTheProperty", not "This Is The Property" or whatever.

enterprise architect api: Add element to a collection

I have few short questions regarding Enterprise architect.
My question is regarding the automation interface. When following the instructions provided on this page: http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/colle... in order to add a new element to the collection ( and the .eap file) it does not add the element. I can get data from the elements, modify and even delete them, but adding a new element does not work?
Instructions provided:
Call AddNew to add a new item.
Modify the item as required.
Call Update on the item to save it to the database.
Call Refresh on the collection to include it in the current set.
my java example:
elements is a collection of all the elements in the model...
org.sparx.Element elementEa = elements.AddNew("Requirement", "non-functional");
elementEa.Update();
elements.Refresh();
With the api is it possible to change the id or guid of an element since there are no methods specified in org.sparx for that?
One last thing... Is it possible to create a custom element in EA, for example a requirement which will not have the standard properties like difficulty, priority etc.. , but will have others? (normal properties, not tagged values)
The arguments to AddNew() are Name and Type, so to create a Requirement element you should specify "SomeRequirementName" and "Requirement".
You can't change the ID or GUID through the API, and your models would crash and burn if you did (connectors would be left dangling, elements would vanish from diagrams, etc, etc).
With an MDG Technology you can create very detailed stereotyped elements if you like, with their own visual representations (shape scripts) etc, but if you're after creating an element type with its own properties dialog the answer is no; there is no hook for a custom dialog in the API.
Collection<Package> packageCollection = myPackage.GetPackages();
Package consolidatedCfsSpecPackage = packageCollection.AddNew("somePackageName", "");
if (!consolidatedCfsSpecPackage.Update()) {
System.err.println("Not Updated: somePackageName");
}
packageCollection.Refresh();
This works for me. I suggest you to check return value of elementEa.Update() method you called. If it returns false, you can get the reason by calling elementEa.GetLastError().

transfer netbeans made component to lwuit's "Resource Editor"

I tried to use "table" Component in a Form with "Resource Editor" in lwuit, but I could not add/edit the rows items. so I end up with this question:
Is it possible to create/edit the table component in the generated "StateMachine" class in Netbeans and see the result in "Resource Editor"?
And if it's not possible, how can I hack the .res file in order to make the "table" as it should be?
There is support for live embedding in the resource editor but its deprecated and obtuse.
I suggest you just add a label where you want the custom component to be, give it a unique name and override the method createComponentInstance which is invoked internally with the name of the label (name it something unique).
You can then just return the instance of your custom made component and it will appear where the label is in the GUI builder.

How to make dynamic drop down lists on parameterized build page in a custom Hudson plugin?

I am trying to achieve the following for a parameterized hudson job: when a user clicks on 'build now' he should be presented with three drop down list parameters viz., Environment, Server, Port. I want the drop down to be dynamic i.e on changing the value of environment the list of servers should change accordingly and similarly the values of port should change on the basis of selected server.
Once a user makes the final selection, all three values from the dropdowns are to be used to make a single value to be passed to the build job as a parameter. I am stuck at how to achieve this in a single parameter and make it dynamic. In my custom plugin i have extended the ParameterDefinition class and within it i have a static nested class extending the ParameterDescriptor class with doFillXXXItems() for these three fields. The values in environment dropdown are populated on the basis of logged in username. I would really appreciate it if somebody could help me figure out how to make the drop downs dynamic. I have already tried the dynamic drop down listbox in ui-samples plugin but its not working in my case :(
You could inherit hudson.model.ChoiceParameterDefinition, and override its method of getChoicesText. return the options based on whatever you want, in your situation, you could get environments from Hudson.getInstance().
Below snippets is shown how get environment variable.
Hudson.getInstance().getGlobalNodeProperties()
.get(EnvironmentVariablesNodeProperty.class).getEnvVars().get(name);