in one of my dialog I'm trying to build dropdown list based on JSON data. It's straight forward with classic but more complicated with touchUI. I'm using client libs with JS to get JSON object and I have a trouble with appending that to my dialog.
<select_dropdown
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/select"
fieldDescription="Select:"
name="./selection"
value="">
<items jcr:primaryType="nt:unstructured">
<unselected
jcr:primaryType="nt:unstructured"
text="---"
value="---"/>
</items>
and my data:
{
mydata: [
{
a: "ABC",
b: "abc"
},
{
a: "DEF",
b: "def"
},
{
a: "GHI",
b: "ghi"
}
]
}
any help would be appreciate.
You can use a datasource to load dynamic data into a Granite UI select: https://helpx.adobe.com/experience-manager/using/creating-granite-datasource.html
You can also check an example at ACS AEM Commons
Related
So, I have a logic app that looks like below
enter image description here
The main idea of the app is to get the list items of a list and copy the contents in a csv file in blob storage.
The site name and list name are passed through the HTTP request body.
However, I would like to also define the Select operation column mapping dynamically.
The body looks like this
{
"listName" : "The list name",
"siteAddress" : "SharepointSiteAddress",
"columns" : {
"Email": " #item()?['Employee']?['Email']",
"Region": " #item()?['Region']?['Value']"
}
}
In the 'Map' section of the 'Select' Operation I use the 'columns' property as shown below
enter image description here
However, in the output stream of the 'Select' Operation, email and region column values are resolved with the string that is passed instead of retrieving the actual item value that I am trying to refer to.
Can I somehow create the csv table dynamically through the HTTP request while also being able to access the items' values?
Using expressions, you can create CSV file with Dynamic data. I have reproduced issue from my side and below are the stepts I followed.
Created Logic app as shown below,
In Http trigger, I have defined sample payload as shown below,
{
"listName" : "The list name",
"siteAddress" : "SharepointSiteAddress",
"columns" : {
"Email": " Email",
"DisplayName": "DisplayName"
}
}
In select action, from is taken from Get items value. In Map row, key is taken from Http trigger and value is from SharePoint item as shown below,
Map:
Key -triggerBody()?['columns']?['Email']
Value - item()?['Editor']?['Email']
Output of Get Items action in my case is like below. Hence written expression according to that.
"value": [
{
"#odata.etag": "\"1\"",
"ItemInternalId": "3",
"ID": 3,
"Modified": "2022-11-15T10:49:47Z",
"Editor": {
"#odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
"Claims": "i:0#.f|membership|xyzt.com",
"DisplayName": "Test",
"Email": "v#mail.com",
"JobTitle": ""
}
Tested logic app. It ran successfully and csv file is generated like below,
Csv file:
So I have this class:
class Table(BaseModel):
__root__: Dict[int, Test]
and I'm using the __root__ since it is a dynamic value but when I go to /redoc (I'm using FastAPI) the example values it defaults to is property1, property2 as in the image below but I wanted the default example to be id_1, id_2 for example. How can I achieve this?
I tried changing the alias and title using the Field method of the library but didn't seem to work like I expected.
Have you tried doing it with the schema customization ?
class QcastTable(BaseModel):
__root__: Dict[int, Test]
class Config:
schema_extra = {
"examples": [
{
"id_1": {
"title": "yourTitle",
"description": "yourDescription",
},
"id_2": {
"title": "yourTitle2",
"description": "yourDescription2",
}
}
]
}
I have the following components
my-app: contains a layout-toolbar and a layout-container
layout-container: contains one or more layout-pages
layout-page: contains one or more layout-elements
layout-element: component to visualize certain data, f.e. a styled numeric label.
The layout-container has an options property that is bound to the apps layoutContainerOptions property like this:
<layout-container .options="${this.layoutContainerOptions}"></layout-container>
layoutContainerOptions is initialized like this:
this.layoutContainerOptions = {
name: "Project 1",
pages: [
{
name: "Page 1",
elements: [
{
name: "Element 1",
color: "red"
},
{
name: "Element 2",
color: "yellow"
}
]
},
{
name: "Page 2",
elements: [
...
]
}
]
}
This correctly renders a layout with two pages and some elements. Now the user should be able to use the toolbar to interactively edit selected elements, f.e. to change the color of an element. How do I propagate a property change to a selected child element?
I could use something like
this.layoutContainerOptions.pages[0].elements[0].color = "blue";
this.layoutContainerOptions = Object.assign({}, layoutContainerOptions, { });
This works but seems to be very inefficient because there may be hundreds of elements which all get re-rendered (or don't they?)
What is the most efficient way to update properties of individual child elements?
I have following problem
I have a field mapping update to an index .Payload is complex where
I have:
{
"type": "abc",
"Party": [{
"Type": "abc",
"Id": "123",
"Name": "manasa",
"Phone": [{
"Type": "Office",
"Number": "12345"
}]
}]
}
And now I want to create a field for an index. The field name is phonenumber of type Collection(Edm.String)
where mapping is
{
"sourceFieldName" : "/Party/Phone/Number",
"targetFieldName" : "phonenumber",
"mappingFunction" : { "name" : "jsonArrayToStringCollection" }
}
In http post body
But still after indexing i get phone number result as null.That means the mapping went wrong.If you see the phone number in source json, it is inside a json array and it itself is an array and result needs to get stored inside a collection of a string.Is it possible how can I achieve this?
If this is not possible I atleast want field mapping till phone array ie., /Party/Phone/
If i index complete party array as a text, I get an error while running the index saying:
"Field 'partydetails' contains a term that is too large to process. The max length for UTF-8 encoded terms is 32766 bytes. The most likely cause of this error is that filtering, sorting, and/or faceting are enabled on this field, which causes the entire field value to be indexed as a single term. Please avoid the use of these options for large fields."
Can someone please help!
If party would have been a Json object than an array and phone would have been only a string array for example
{
"type": "abc",
"Party": {
"Type": "abc",
"Id": "123",
"Name": "manasa",
"Phone": [{
"12345",
"23463"
}]
}
}
Then I could have mapped
{
"sourceFieldName" : "Party/Phonenumber",
"targetFieldName" : "phonenumbers",
"mappingFunction" : { "name" : "jsonArrayToStringCollection" }
}
It map as collection of type odata EDM.string.
So to put this in better and straight forward way,
Either transform your json to something flatter (the example that I
gave above) or
Use the proper index incase if you know before inhand as
#Luis Cabrera said,
“sourceFieldName”: “/Party/0/Phone/0/Type
It is a limitation from azure search side.
Note that Party and Phone are arrays, so the field mapping you mention won't work.
You will need to index into the specific element. For example:
{
"sourceFieldName": "/Party/0/Phone/0/Type",
"targetFieldName": "firstPhoneNumberTypeOfFirstParty"
}
You may want to give that a shot.
Thanks!
Luis Cabrera | Program Manager | Azure Search
I am using a Groovy library call ws-lite for web service testing. The way it works is it takes a closure and generate XML and send it to a web service end point.
See below for a simple example of what this closure looks like:
def bookXml = {
books {
book(available: "20", id: "1") {
title("Don Xijote")
author(id: "1", "Manuel De Cervantes")
}
book(available: "14", id: "2") {
title("Catcher in the Rye")
author(id: "2", "JD Salinger")
}
book(available: "13", id: "3") {
title("Alice in Wonderland")
author(id: "3", "Lewis Carroll")
}
}
}
Will generate XML in the request as below:
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book available="20" id="1">
<title>Don Xijote</title>
<author id="1">Manuel De Cervantes</author>
</book>
<book available="14" id="2">
<title>Catcher in the Rye</title>
<author id="2">JD Salinger</author>
</book>
<book available="13" id="3">
<title>Alice in Wonderland</title>
<author id="3">Lewis Carroll</author>
</book>
</books>
In order to make my clients more flexible, I normally pass the data structure from my test to the client as a map:
def bookMap = [
books: [[
id : "1",
available: "20",
title : "Don Xijote",
author : [
id : "1",
name: "Manuel De Cervantes"
]
], [
id : "2",
available: "14",
title : "Catcher in the Rye",
author : [
id : "2",
name: "JD Salinger"
]
], [
id : "3",
available: "13",
title : "Alice in Wonderland",
author : [
id : "3",
name: "Lewis Carroll"
]
]
]
]
This is how the client looks like now:
def bookXml = {
books {
bookMap.books.book.each {
book(available: it.available, id: it.id) {
title(it.available.title)
author(id: it.author.id, it.author.name)
}
}
}
}
One thing I want to do is in the bookXml closure, is there a way that I can take out a tag, if the value in my data structure is null?
For example, if title of my first book is null in the map, then in the closure, it won't create this tag title for book one.
I know how this can be done in groovy collection using collectentries for map and collect for list, but I don't know much about transforming closure.
Can you please share some insight with me?
Thanks.
I do not have much knowledge of builders, but it seems that the question is about how to ignore keys will null values in a map.
This can be achieved by using the each() method with a two-arg closure. The two arguments passed to the closure in this case will be each entry's key and value.
To demonstrate -
def book = [
id : "1",
available: "20",
title : null
]
book.each {key, value->
if (value) {
println "$key->$value"
}
}
I highly doubt you can do what you want in a simple way. If you are not into ASTs, then a closure is not a data structure which you can manipulate easily.
IMO, you should make your input map consistent before passing it to bookXml. Other than that, stick to #diveshpremdeep answer.