Sitecore "webedit:sortcontent" command - sitecore

I am wondering if it it possible to call the command "webedit:sortcontent" with an ID or datasource. Do you have to use an editframe for this or can you pass a parameter with ID?
I tried calling it directly from javascript, like this: Sitecore.PageModes.ChromeManager.postRequest('webedit:sortcontent(' + myid + ')');, with no luck.

Sitecore.PageModes.ChromeManager.postRequest('webedit:sortcontent(itemid=' + id + ')');
This seems to work.

Related

POSTMAN - Issue with resolving of variables

I have two environmental variables set.
1] firstName = "abc"
2] firstNameUpdate = "{{firstName}}Update"
when I say -
console.log(postman.getEnvironmentVariable("firstNameUpdated"));
I am getting --> {{firstName}}Update instead of abcUpdate in the console log.
which fails my below code
tests["Success"] = jsonData.data.firstName === postman.getEnvironmentVariable("firstNameUpdated");
Problem is postman.getEnvironmentVariable() returns the value of the variable, but it does not resolve the variable. How to achieve it?
I don't want to use regular expression here, want to achieve it from Postman itself. Any help guys?
Other details :
Postman for Chrome
Version 5.0.2
win / x86-64
Chrome 59.0.3071.115
I don't think it is possible for postman to resolve your environment variable like this. If it is a matter of building your variable dynamically you may proceed like this in your "tests" tab:
postman.setEnvironmentVariable("firstname","abc");
var name_update = postman.getEnvironmentVariable("firstname")+"update";
console.log(name_update); // you can see your second env var name
postman.setEnvironmentVariable("firstnameupdate",name_update);
// you can check your env var content:
var check_env = postman.getEnvironmentVariable("firstnameupdate");
console.log(check_env); // this should give you abcupdate
hope this helps
Alexandre

Regex with XPages SSJS to replace querystring value

I have integrated oAuth2 (Facebook, LinkedIn, etc) with my XPages app to allow for authentication to easily add comments (response docs). When a user authenticates, it has to redirect to the facebook/linkedin page, then return to complete the document creation. I use the state variable to do this, and pass it in the querystring of the url. When the page reloads and sees the state variable, it calls a "beforePageLoad" event and creates the response document if the user authenticated and has the correct state document.
My problem is when there is already a state parameter in the querystring. I want to replace the value, not add it to the end. I use a solution here from stackOverflow by ellemayo called updateQueryStringParameter. When I call it from my beforePageLoads it runs, but never replaces the parameter, it only appends it to the end. I end up with ...&state=E5A&state=E5F
I have a feeling that it is in the line,
return uri.replace(re, '$1' + key + "=" + value + '$2');
I can write the code using #ReplaceSubstring(), etc, but want to know if there are problems running regex in XPages SSJS. I read on Lotus.com that
A Regular Expression can be specified as Server-side, which uses the
Java (java.util.regex) API or Client-side, which uses the browser
JavaScript Regular Expression Engine. Client-side and Server-side
Regular Expression syntax is similar, but there are differences that a
user must be aware of.
Should I avoid regex in XPages SSJS ? I have it working extensively in client and in some field validations on the XPage itself.
Here is the call to the function:
if(#Contains( qString,"state=")){
qString=updateQueryStringParameter(qString, "state", linkDoc.getNoteID() );
}else{
qString="?"+qString+"&state=" + linkDoc.getNoteID()
}
the function:
function updateQueryStringParameter(uri, key, value) {
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
// I also tried --> if (re.test(uri)) {
return uri.replace(re, '$1' + key + "=" + value + '$2');
}
else {
return uri + separator + key + "=" + value;
}
}
It was not an XPage or Regex problem. I was using the querystring provided by Domino the excludes the "?" as part of the querystring. when I send "?" + qString to the function, it works. Regex needed to know where to start looking, thus it never found the start of the query string.

Bukkit.getIp() in player.sendMessage - Possible solution?

I'm making a plugin for my staff that can help them with some basic information.
I'm trying to add a /ip for the server that will show the server ip, instead of the dns that they connect to.
I'm trying something like this
var InfoIP = Bukkit.getIp();
player.sendMessage("Server Ip: " + InfoIP);
Apparently it does work with Bukkit.getPort(); but it doesnt work with the ip.
Is there another way to fix this?
I'm not looking for anything like this
var myip = "0.0.0.0";
player.sendMessage("Server Ip:" + myip);
I want the myip to be filled by the getIp instead of manually filling it.
Hopefully someone has a solution for this :)
tnx.
In order to use the getIP method you must define it in your server properties.
there should be a line called server ip.
once you have defined your ip in the properties it will return the ip.
when you use the getIP method.
Or you could use:
player.sendMessage(getServer().getAddress() + ":" + getServer().getPort());
hope this helped
~~
AceStudios
Or this:
if (!getServer().getPort() == "25565") {
player.sendMessage(getServer().getAddress() + ":" + getServer().getPort());
}
else {
player.sendMessage(getServer.getAddress());
Instead of using Bukkit.getIP(); try using Bukkit.getServer().getAddress();

error with RegExp inside angular.toJson

I'm trying to do a 'like' query in mongodb. I see that's done with a regexp so I'm trying to set it like this:
$scope.clients = Client.query({
q:angular.toJson({
name: RegExp($routeParams.str)
})
});
The thing is angular.toJson function does not get any regexp:
http://plnkr.co/edit/idXMT1
Is there any other way to do that?
From my understanding of your question, you want your JSON object to contain the regular expression as a string?
In that case, you can manually convert it to a string in the declaration, i.e:
$scope.object = angular.toJson({
"param" : new RegExp(str).toString()
});
See updated plunk:
http://plnkr.co/edit/yLogI8
I finally found a solution.
The problem is using the toJon function as it does not allow any key starting with / or $ so the solution is avoiding the use of this function and just write the object as a string
$scope.clients = Client.query({
q:'{src:{$regex:"' + $routeParams.str + '"}}'
};

Variable name in the method of ColdFusion Object

I am trying to set a variable in a cffunction.
The result is this:
<cfset local.layouts.appLayout = '../../app/layouts' & local.appController.new()>
The above code works. In the local.layouts.appLayout structure it assigns the return of the new method in the appControler. That is what I need it to do.
My problem is that I need to dynamically assign the method portion of that statement. I have another variable coreRoute.action that equals "new" in that function but I cannot seem to get the syntax right.
I have tried this:
<cfset local.layouts.appLayout = '../../app/layouts' & local.appController.coreRoute.action()>
That does not work and I can see why. I have also tried this:
<cfset local.layouts.appLayout = '../../app/layouts' & local.appController & #coreRoute.action# & '()'>
I have tried many variations of this syntax and I just cannot get it right.
Anyone have any ideas about how to do this. I am stuck.
Thanks in advance for any help.
UPDATE: With Todd Sharp's help I ended up using this and it worked great:
<cfinvoke component="#local.appController#" method="#coreRoute.action#" returnvariable="local.act">
<cfset local.layouts.appLayout = '../../app/layouts' & local.act>
You should look into using <cfinvoke> for dynamic method invocation. Try a Google search for "coldfusion dynamic method invocation" - here's one of the top results:
http://www.bennadel.com/blog/1320-ColdFusion-CFInvoke-Eliminates-The-Need-For-Evaluate-When-Dynamically-Executing-User-Defined-Functions.htm
In addition, if you want to do it entirely in script, you can, using this approach:
dynFn = this["foo" & bar];
dynFn(stuff);
This is in a cfc, if you're doing it from outside the cfc or not using a cfc at all, just change "this" to wherever your method is.