jsTree: How to *set* opened/selected node by path (not ID)? - jstree

So, I can get the full path of a selected node like so (thanks to #ggrandes for that one):
.on('changed.jstree', function (e, data) {
var path = data.instance.get_path(data.node,'/');
console.log('Selected: ' + path);
})
What I now need, is to set select/open a node according to a given path.
All the solutions I've found so far refer to some mysterious ID, which appears to simply assume that the data in question has IDs. My problem is that I don't. It's simply a recursive JSON dict/array describing a directory layout. All I have with each node, is its name and a list of its children (and their names and children and so forth).
So, what I need is something like:
data.instance.set_path('/some/arbitrary/path');
Is it possible to do this with jsTree in some reasonable way?

I ended up creating a full path of every item on the server-side and using that as an ID that could then be selected on the client-side. As far as I can tell, there is no other way, at the time of this writing.

Related

Access Path Name for Transporter Speed Limit

I want to customize the "Speed limit for transporters" option in the Path object. I do call a global function which gives the speedlimit based on the Path Name (Lookup-Table).
Unfortunately
this.name()
does not return the name of the Path. Any idea how to access the individual Paths name from inside this function?
Best,
Felipe
There is no "handle" to make this work. this does not refer to your Path element here.
You can find out by clicking inside the code box. If there is no small "light bulb" with some help text, you have no "handle" for such special functionality. I wrote a full blog post about this.
With this setup, you can only get the name by calling the object directly as path.getName().

Defining a new variable in order to make a huge iteration giving me an error

I have an endpoint, you can have informaciĆ³n about products
{{URL_API}}/products/
If i perform a GET method over that endpoint i will obtain the information of every product
BUT i can also specify the product that i want to know about, i.e:
{{URL_API}}/products/9345TERFER (the last code is the id of the product, called SKU)
The problem is that if i want to make a CSV in order to update the information of different products i have to define a variable called sku in the endpoint so i will be able to pass the corresponding SKU
I want to create the variable {{sku}} but i do not understand how to do that.. i tried so many times and i failed, i've searched a lot but i do not really understand
Also, should i use ":" before the declaration of the variable? i mean:
{{URL_API}}/products/:{{sku}}
or simply:
{{URL_API}}/ns/products/{{sku}}
Can you help me?
I'm super lost :(
EDIT:
I want to perform a PUT method, i want to pass different values to the body and then.. send the request (it throws an error: 404 not found)
This is what i did:
PUT|{{URL_API}}/products/{{sku}}
body:
{
"tax_percentage":"{{tax_percentage}}",
"store_code":"{{store_code}}",
"markup_top":"{{markup_top}}",
"status":"{{status}}",
"group_prices": [
{
"group":"{{class_a}}",
"price":"{{price_a}}",
"website":"{{website_a}}"
}
]
}
CSV:
POSTMAN:
Your issue seems to be just a basic understanding of how data files work with variables in Postman, here's a simple example that will work the same way for you too.
This is a basic request I'm using to resolve the variable from the data file - It's a GET request but that doesn't matter as all we're look at here is using a data file to resolve variables. All you need to do is ensure the URL is correct and that you SAVE the request before using the runner.
Here's a simple CSV file created in a text editor. The heading sku in the name on the variable it will reference inside the Postman request. Each value under that is the value that will be used for each iteration.
In the Runner, select your Collection from the list (If you have more than one) then select the CSV file. Once imported, you will be able to see a preview of the data.
If that's correct, press the Run button. The Runner will then iterate through the file and pick up the sku value in the CSV file and use it in the request. I've expanded one of the requests so you can see that the value was used in the request.

How to map urls?

I would like to map pages such domain/content/myProject/home.html to domain/home.html. /content/myProject/ is not needed. I have the following code:
String newpath = getResourceResolver().map(page.getPath());
this does not change anything. newpath is stay page.getPath()
how to solve this issue?
Answering as this question as it remains unanswered. Here is an example of how the etc mappings should look like:
Trick is you add 2 entries to sling:internalRedirect as / and /content/example/
AEM first tries to resolve resources with first entry '/'. So non page URLs like /etc/designs, /content/dam etc will be addressed by the first entry. If it is unable to resolve using the first one, it uses the second entry to resolve the page.
This is also the adobe recommended way for URL shortening compared to other techniques like apache redirect.
You need to create map in etc.Then Resource Resolver will take care of trimming the path .
CREATING MAPPING DEFINITIONS IN AEM
In a standard installation of AEM you can find the folder:
/etc/map/http
This is the structure used when defining mappings for the HTTP protocol. Other folders (sling:Folder) can be created under /etc/map for any other protocols that you want to map.
Configuring an Internal Redirect to /content
To create the mapping that prefixes any request to http://localhost:4503/ with /content:
Using CRXDE navigate to /etc/map/http.
Create a new node:
Type sling:Mapping
This node type is intended for such mappings, though its use is not mandatory.
Name localhost_any
Click Save All.
Add the following properties to this node:
Name sling:match
Type String
Value localhost.4503/
Name sling:internalRedirect
Type String
Value /content/
Click Save All.
This will handle a request such as:
localhost:4503/geometrixx/en/products.html
as if:
localhost:4503/content/geometrixx/en/products.html
had been requested.
You can refer here for further documentation http://docs.adobe.com/docs/en/cq/5-6-1/deploying/resource_mapping.html

Data binding - getBindingContext() returns absolute path rather than relative

I've got a table which I'm firing an event on row selection. In the handler I want to get the context for the selected row and then create a new context for a lower level oData object and then bind that to a Text view.
I'm sure there is a beautifully succinct way of doing this but currently I am:
Getting the binding path and adding a string to create a path to my lower level object:
var path = oEvent.getParameters().listItem.getBindingContext().sPath + "/ComplianceNote";
This is returning a path with / as the first character, from what I understand this means it's the root object of the service or this is an "absolute" path. My current workaround is to remove the first character:
path = path.substr(1, path.length);
Then I can bind my Text view:
noteText.bindElement(path);
noteText.bindProperty("text", "Note");
This works fine but seems to me to be a code smell hacking around with the string. My questions are:
Why is the path returned as "absolute" rather than "relative"
What is the correct way to achieve this. I've been looking at things like setBindContext and bindText.
Cheers,
Gregor

Getting / ussing full path to find controls in UIA and White

I'm using Microsoft UI automation + White framework. Is it possible to get a full path from to the control from the top parent, and then use it to find an element? For example, use UI spy to get the full path, and then somehow get the control by the taken path?
Thanks
I use the unmanaged version of MSUIA and don't use white, but something like this should do what you are asking. Pass in an element.
CUIAutomation auto = new CUIAutomation();
var desktop = auto.GetRootElement();
var walker = GetRawTreeWalker();
while (true)
{
element = walker.GetParentElement(element);
if (auto.CompareElements(desktop, element) == 1)
{
break;
}
winPath = AppendWinPathPart(winPath, element);
}
AppendWinPathPart is a call to a method that builds something like a path in string form that I use in my automation. It is much like XPath for MSUIA.
I have done something in the past similar to what it sounds like you're trying to do. Unfortunately, it's not necessarily all that easy to do.
I essentially built my own simplified version of UI Spy that used some code similar to what's in the answer from #chrismead above to build a '\' delimited path of automation IDs (unfortunately, as you may have already discovered, AutomationIDs can be unreliable, so for the sake of robustness I also had to add the capability to identify AutomationElements by things like name, position among siblings, or position relative to parent).
Then, I had code in another application that could take those paths as input in order to locate those specific AutomationElements and interact with them.