presentViewController does not exist - nativescript

I am building a plugin in NativeScript.
When I try to access "presentViewController" method on rootViewController, I get the error "property presentViewContrller does not exist".
const rvc = UIApplication.sharedApplication.keyWindow.rootViewContrller;
rvc.presentViewContrller(myViewController, true, completion() {});
It suggests to use presentViewContrllerAnimatedCompletion which does not accept my view controller.
Could you please assist what part of my code (or maybe setup!) is wrong?

The right method name is presentViewControllerAnimatedCompletion only.
You should combine the parameter names with method name while marshalling Objective C to JS/TS.
presentViewController:animated:completion

Related

how to use the expand parameter in Xrm.WebApi.retrieveRecord

I am using below scripts to get the reference entity from email entity. When the scripts was triggered, it prompts 'Could not find a property named 'new_queue' on type 'Microsoft.Dynamics.CRM.email''.
The reference entity's scheme name is new_queue, and I think the structure of the script is same as the guidance of microsoft knowledge article.
(https://learn.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-webapi/retrieverecord)
Can anybody point out what's wrong here?
Xrm.WebApi.retrieveRecord("email", '4884f79f-42f3-ea11-a815-000d3a44afcc', "?$select=subject&$expand=new_queue($select=queueid,name)").then(
function success(result) {
var toLookup = new Array();
toLookup[0] = new Object();
toLookup[0].id = result.queueid;
toLookup[0].entityType = "queue";
toLookup[0].name = result.name;
alert(result.name);
}, function (error) {
Xrm.Utility.alertDialog(error.message);
});
This issue is usually an outcome of case sensitive schema name, try new_Queue instead of new_queue. You can always verify this by checking in xml metadata.
Update:
I remember that the activity (email, task, appointment, etc) is special and little different. Make sure you download the metadata xml from Developer resources and check the correct navigation property. It should look like email_new_queue or new_queue_email
To know the correct navigation property name to use it in $expand:
Request the "Email" entity and Include the following header Prefer: odata.include-annotations="*".
In the response, you should find a field that looks something like:
"_new_queue_value#Microsoft.Dynamics.CRM.associatednavigationproperty": "????"
Use the name you'll find in the place of "????" in the $expand expression.

Symfony and Swift Mailer

https://swiftmailer.symfony.com/docs/introduction.html
Documents are lacking some information, like all symfony documents are but my problem at moment is that how to instantiate the new Swift_SmtpTransport()?
I cannot find namespace for it. If i do like the document says, i get this error -> Attempted to load class "Swift_SmtpTransport" from namespace App\Controller.
plus, documents don't say how to instantiate Swift_Message class either.
Trying container hasn't worked for me, like so -> $this->container->get
I think the answer is here if you want to send a message -> Attempted to call an undefined method named "newInstance" of class "Swift_Message"
I quote :
Now it is:
$message = \Swift_Message::newInstance()->setSubject('Hello Email')
instead of
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')

How to Use Internalization i18n in a Controller in SAPUI5?

Could anyone please explain how it's possible to use a i18n text in a setValueStateText method in a controller?
oTP.setValueStateText("{i18n>co_Maximal_60_h}");
The error msg in the dialog shows only "{i18n>co_Maximal_60_h}" and not the real text.
the resource bundle is in the following way accessible in a controller:
...
var oResourceBundle = this.getView().getModel("i18n").getResourceBundle();
oTP.setValueStateText(oResourceBundle.getText("co_Maximal_60_h"));
...
You cannot set the binding string via setter method.
Here you have 2 options:
set the binding right in the view (use the same string but in XML)
utilize the ResourceBundle:
var oResourceBundle = this.getOwnerComponent().getModel("i18n").getResourceBundle();
var sTxt = oResourceBundle.getText("co_Maximal_60_h");
oTP.setValueStateText(sTxt);
I'd recommend to add a reusable method to your BaseController with a name "i18n", so whenever you need it, call 'this.i18n("i18n_key")'.

Linkto cast issue in spring HATEOAS

When I try to form the link like below.
Link userLink = linkTo((controllerClass).slash("?location="+location+"&scheduledDepartur="+scheduleDepatur).withRel(USER_REL));
and it shows error as
The method slash(String) is undefined for the type Class<TrainController>
When try to use below link method I got
Link selfLink = linkTo(methodOn(controllerClass).getOffTrains(trainStatus, valid, locale).slash("?depatureLocation="+depatureLocation+"&scheduledDepartureDate="+scheduleDepatureDate).withSelfRel());
got below error
The method slash(String) is undefined for the type HttpEntity<TrainStatus>.
Help me to resolve this issue.
all your parenthesis are off.
Link selfLink = linkTo(methodOn(controllerClass).getOffTrains(trainStatus, valid, locale).slash("?depatureLocation="+depatureLocation+"&scheduledDepartureDate="+scheduleDepatureDate).withSelfRel());
should be
Link selfLink = linkTo(methodOn(controllerClass).getOffTrains(trainStatus, valid, locale)).slash("?depatureLocation="+depatureLocation+"&scheduledDepartureDate="+scheduleDepatureDate).withSelfRel());
I'm surprised those query string parameters you have aren't methods on the getOffTrains controller method..then it would just work for you.

Is it possible to RenderPartial a default or error View if the specified View is not found?

I am using MVC3.
I am wondering whether it is possible to render an error View if the specified View is absent.
ie if "MyTableX" is absent:
RenderPartial("MyTableX");
would return "Error.cshtml" as the Partial View, saying something like "Partial View not found" in the page.
MVC got an attribute called [HandleError] which you should set on your BaseController (or on each controller). There is no need to specify any of the options for the attribute.
The problem with [HandleError] is that it can’t handle 404 (not found), thus we need to create a custom error controller and tell ASP.NET to use it (by configuring web.config and creating and ErrorController):
http://blog.gauffin.org/2011/11/how-to-handle-errors-in-asp-net-mvc/#.UTknoxyfjmA
You can do something based off of this - the trick is in getting the view path.
A missing view returns an InvalidOperationException. So we really need to determine if the view is missing or if it's caused from something different. One way is to figure out how to get the IView in the filter, cast it to a RazorView and grab the path off of it - or the 'hacky' way is to do the below code, but actually look for "the view" and "was not found" in the exceptions message. Its ugly, I know, but if you want something that works tonight, thats all I got before I head to bed, otherwise try to get the view info from that filter.
This code from Phil Haack in this link may help in trying to get the path name, a quick test yielded I wasn't able to get the IView because my filterContext.ParentActionViewContext was null.
Retrieve the current view name in ASP.NET MVC?
So I wrote this basic one, but again, anything throwing an InvalidOperationException will cause this.
Also note a missing 'MissingView.cshtml" could cause an infinite loop here (untested assumption)
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
public class ViewCheckFilterAttribute : FilterAttribute, IExceptionFilter
{
public void OnException(ExceptionContext filterContext)
{
var exception = filterContext.Exception;
if (exception is System.InvalidOperationException)
{
//ideally here we check to ensure view doesn't exist as opposed
//to something else raising this exception
filterContext.Result = new ViewResult
{
ViewName = "~/Views/Shared/MissingView.cshtml"
};
filterContext.ExceptionHandled = true;
}
}
}

Resources