I want to use the Data Source mechanism for granite/ui/components/coral/foundation/form/select widget in AEM dialog.
I want to render additional data attributes in the HTML of select items. When not using data source and having the select items directly in the dialog's XML file, I can add the data attributes using granite:data node:
<text
jcr:primaryType="nt:unstructured"
text="Text"
value="text">
<granite:data
jcr:primaryType="nt:unstructured"
custom-attribute="custom-attribute-value"/>
</text>
Is it possible to somehow include the data attribute when the items are coming from a Data Source Servlet? I am using this example code for my data source servlet. In particular, I'm updating the value map of the resource and returning it to the dialog. Is there anything I can do with this value map to render `data-custom-attribute="custom-attribute-value" in the particular element's HTML?
private Resource getItemResource(ResourceResolver resolver, String text, String value) {
ValueMap vm = new ValueMapDecorator(new HashMap<>());
vm.put("text", text);
vm.put("value", value);
return new ValueMapResource(resolver, "", "", vm);
}
Adding additional entries to this map indeed causes rendering of data attributes for granite/ui/components/foundation/form/select, but not for granite/ui/components/coral/foundation/form/select which I want to use.
We can add a child node with a name granite:data to the resource that we will be returning from the DataSource servlet. The properties of this child node will become pairs of data attributes in the markup. I don't think this is possible using ValueMapResource, as in the question, but can be done using real resources that are stored in JCR.
A number of other properties can be added to the original resource (not as children), and they will get rendered in the HTML markup, too:
granite:id
granite:rel
granite:class
granite:title
granite:hidden
granite:itemscope
granite:itemtype
granite:itemprop
Related
What is the best approach to creating and organizing localized content in Amplience Dynamic Content. Should it be done through a content type (json) or rendering (html, css, .js) or other methods (web hook integrations)
I use multiple repositories one for each language. I put my localised content in each one then create slot type with JSON schema that creates an array of content links that you can point at each local variant. Alternatively you can have an array of content types with a field defined as a locale enumeration and a content link.
e.g.
Slot
--localized content array
----local:en
----content:link to content in en repository
----local:es
----content:link to content in es repository
----local:fr
----content:link to content in fr repository
Example localized slot content type
https://github.com/zestrax/dynamic-content-samples/blob/Development/content-types/slot/localized-slot.json
Use the render service to filter the graph on request e.g.
Create a partial for each country en.HBS which loops through the slot array and return the content matching its locale
you would create a handlebars partial ‘en.hendlebars’ like this to filter the local content in a slot for language 'en'.
{{#each content-list}}
{{#compare locale "==" "en"}}
{{!-- call a partial for to render the locale content --}}
{{>mapping this.content.content-type}}
{{/compare}}
{{/each}}
type:nt:unstructured
path=/content/dam/en_us
node=jcr:content
group.1_property=Cmg_name
group.1_property.operation=exists
group.1_property.value=Web Standard
I have assets like pdf and images inside \content\dam\en-us and also i have meta data for respective assets .i want to get pdf or image by asset metadata property values .but i am notable to get exact output.I have asset c012666.png inside jcr:cotent inside metadata.now, if give property value i have to get that pdf file.so, pls can any one help???
if you want to list the properties of a hit you have to use p.hits = full. And if you want to list all it's children you have to use the p.nodedepth = AMOUNT_OF_SUBLEVELS.
For example the query http://localhost:4502/bin/querybuilder.json?p.hits=full&property=jcr%3atitle&property.value=Default%20Design&p.nodedepth=2
will list the properties of the the node called "Default design" and also list the children of it
Hope that this suits your needs
Here's some documentations https://hashimkhan.in/2015/12/02/query-builder/
I'm a newbie with Angular2 (beta1) and I'd like to implement a sort of simple editable grid, built of 2 components. Here I use two fake-data components to keep things simple. They are (see this Plunker: http://plnkr.co/edit/5cZfLTIlhLc82wWV4PQI):
the parent component, named contact. Say it represents a contact with a name.
the child component, named entry. Say it represents an entry for a contact, where each contact can include 0 or more entries. Each entry has an address and a zip code.
I'd like to create a form where the user can edit the contact's properties, and also its children entries: he could add a new entry, delete an existing entry, or edit an existing entry.
To this end, the views for both these components provide a form-based template.
I can think of this data flow:
contact: the user edits the form and then clicks a submit button to save
the whole thing. Thus, I can just have some code handling the submit button
and emitting an event as the component output. The contact has an entries
array property: I can thus use an ngFor directive in its template to render
an entry component for each of them.
entry: the entry has properties addressCtl and zipCtl which represent
the control directives included in the ControlGroup representing the whole
form. Also, I need a couple of properties to be bound as the input of the
component (address and zip), so that in the parent template I can do something like:
<tr *ngFor="#e of entries">
<td><my-entry [address]="e.address" [zip]="e.zip"></my-entry></td>
</tr>
Now, it's not clear to me how to shape the relation between the "model" properties representing the control's input, and the "form" directives properties. I should be able to get the address and zip values from the parent component through the [...] binding, and pass the updated values up through an event fired by the child component (e.g. blur?). Does this make sense in the NG2 world? Anyway, I'm missing a piece here: how can I connect the form controls values to the model properties values? Could anyone make this clearer or point to some good docs?
In fact, using the [...] binding only corresponds to a one-way binding. When the parent property is updated in the parent component, the value is also updated in the child component.
But if you want to update parent attributes from the child, you need to leverage events and #Ouput attribute.
Here is a sample with a labels component:
export class LabelsComponent implements OnInit {
#Input()
labels:string[];
#Output()
labelsChange: EventEmitter;
(...)
removeLabel(label:string) {
var index = this.labels.indexOf(label, 0);
if (index != undefined) {
this.labels.splice(index, 1);
this.labelsChange.emit(this.labels);
}
}
addLabel(label:string) {
this.labels.push(this.labelToAdd);
this.labelsChange.emit(this.labels);
this.labelToAdd = '';
this.addAreaDisplayed = false;
}
}
This way you can leverage two way binding on this component:
<labels [(labels)]="company.labels"></labels>
Hope it answers your question,
Thierry
Just moved the comment to answer...
You can pass the object e, instead of passing string.
i.e
<my-entry [entry] = "e"></my-entry>
then in your my-entry component, use ng-model for each input. so you automatically gets 2 way bindings.
I was trying to understand how can we make drop-down values in dialog box easily authorable?
Select lists in dialogs can load their options dynamically from anywhere, so long as they are provided as an array of values in JSON format (from the docs):
[
{
value: "pink",
text: "Pink",
qtip: "Real Pink"
}
]
So one solution would be to:
Create a new template that would allow an editor to add/remove values from a list — make this editable for content authors as per any other content (e.g. using the page properties, or components that you can drag onto that template).
Create a Servlet that will parse those values & output them in the expected JSON.
Register that servlet, e.g. via a path (/bin/selectvalues).
Using the cqinclude xtype to load in your values:
i.e.
<select
type="select"
xtype="selection"
options="/bin/selectvalues"/>
If you are looking for a drop-in solution for this, take a look at http://adobe-consulting-services.github.io/acs-aem-commons/features/generic-lists.html. This supports easily authorable lists of name/value pairs which can be used (without writing additional code) in:
Classic UI Dialogs
Touch UI Dialogs
Touch UI Asset Metadata Editor
I'm having a hard time testing our Wicket application using Selenium because of the random markup ids.
For individual elements, I can use abc.setOutputMarkupId(true).setMarkupId("myId")
to set their markup id explicitly.
But what if the element is added dynamically using a repeater (like ListView)? Is there a way to specify how the markup id sequence should look like?
Well, can't you do the same thing with ListView? If you make your own ListView implementation, and then in the populateItem(final ListItem<?> listItem) method, on that respective listItem you do:
listItem.setOutputMarkupId(true); // write id attribute of element to html
listItem.setMarkupId("id"+i);
where i is some index you initialize in the ListView's constructor or something?
as Andrei told that its possible but dangerous.
setMarkupId doc:
Retrieves id by which this component is represented within the markup. This is either the id attribute set explicitly via a call to
org.apache.wicket.Component.setMarkupId(java.lang.String), id
attribute defined in the markup, or an automatically generated id - in
that order. If no explicit id is set this function will generate an id
value that will be unique in the page. This is the preferred way as
there is no chance of id collision.
http://www.kiwidoc.com/java/l/p/org.apache.wicket/wicket/1.4.0/p/org.apache.wicket/c/Component#top
and also you cant get the markup id with getMarkupId()