I rigged up a test of sendEmailTemplate by putting this in a transition:
<actions>
<!--
<service-call name="org.moqui.impl.UserServices.reset#Password"/>
-->
<service-call name="org.moqui.impl.EmailServices.send#EmailTemplate">
<field-map field-name="emailTemplateId" value="PASSWORD_RESET"/>
<field-map field-name="toAddresses" value="test#gmail.com"/>
<field-map field-name="bodyParameters" from="[userAccount:userAccount, newPassword: 'xxxxxxx']"/>
</service-call>
...
and I end up with this error:
java.lang.NullPointerException: Cannot execute null+null
at org.codehaus.groovy.runtime.NullObject.plus(NullObject.java:121)
...
at org.moqui.impl.context.WebFacadeImpl.getWebappRootUrl(WebFacadeImpl.groovy:272)
because both webappName and servletContextPath are null.
This comes from the text render in sendEmailTemplate (ln 77) so webappName is not set as it is in the call right above.
But all of this misses the point - I think. I think the error is in ScreenUrlInfo (~ln 450):
if (sri.baseLinkUrl) {
baseUrl = sri.baseLinkUrl
if (baseUrl && baseUrl.charAt(baseUrl.length()-1) == '/') baseUrl.substring(0, baseUrl.length()-1)
} else {
baseUrl = WebFacadeImpl.getWebappRootUrl(sri.webappName, sri.servletContextPath, true,
this.requireEncryption, (ExecutionContextImpl) ec)
}
sri.baseLinkUrl is not set and I think that is the problem. Where should sri.baseLinkUrl be being set?
Related
It looks like a bug but asking the question just in case I have missed something.
Karate version is 1.1.0
The post request is as below. Note that content type is text/turtle and I use logPrettyResponse because further requests in test are testing RDF/XML and other serialisations.
* configure logPrettyResponse = true
Given path '/graph'
* text payload =
"""
<http://example.com/a7460f22-561a-4dde-922b-665bd9cf3bd9> <http://schema.org/description> "Test"#en.
"""
And request payload
And header Accept = 'text/turtle'
And header Content-Type = 'text/turtle'
When method POST
Then status 200
And I get below error
ERROR com.intuit.karate - org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 8; Element type "http:" must be followed by either attribute specifications, ">" or "/>"., http call failed
Reason this seems to be happening is that fromString method in JsValue.java is trying to parse turtle as XML because condition case '<' is true when response is turtle.
public static Object fromString(String raw, boolean jsonStrict, ResourceType resourceType) {
String trimmed = raw.trim();
if (trimmed.isEmpty()) {
return raw;
}
if (resourceType != null && resourceType.isBinary()) {
return raw;
}
switch (trimmed.charAt(0)) {
case '{':
case '[':
return jsonStrict ? JsonUtils.fromJsonStrict(raw) : JsonUtils.fromJson(raw);
case '<':
if (resourceType == null || resourceType.isXml()) {
return XmlUtils.toXmlDoc(raw);
} else {
return raw;
}
default:
return raw;
}
}
To solve the problem I have set logPrettyResponse to false. I would love to know if anyone has any other thoughts or if someone can confirm that it is a bug?
Following the answer on this post I was using #:<div class="col-md-6">
Problems
The Formatting gets all messed up:
The intellicode gets all messed up (I only deleted the paragraph on the second #:)
Also, my if (i == (Model.CellsNotStarted.Count - 1) && i % 2 != 0) won't work when using the #:; it will always go on the else. If I don't use the #: markup, and if I, for instance put all my html in a if/else instead of only the <div> tag it will work with no problems.
My question is:
Is the #: markup viable? If so, what am I doing wrong. If not what is the alternative (that does not imply putting my entire code in an if/else)
PS: I know I should not post images of code, but I wanted to show the format and syntax errors.
There are neater ways to manage conditions within your Razor code. It's difficult to provide a full example because you don't provide the full code, but you can do this, for example:
<div class="col-md-#(i+1 == Model.CellsNotStarted.Count && i % 2 ! = 0 ? "12" : "6")">
Whenever you are tempted to use a remainder operator (%) in Razor, you should also consider whether a GroupBy would be better. It most often is, as I was shown in this question: Building tables with WebMatrix
You can try to use js to set html.Here is a demo:
<div id="myDiv"></div>
<script>
$(function () {
var html = "";
if ("#(Model.CellsNotStarted != null)"=="True")
{
for (var i = 0; i <#Model.CellsNotStarted.Count; i++)
{
if (i == (#Model.CellsNotStarted.Count - 1) && i % 2 != 0)
{
html += '<div class="col-md-12">';
}
else
{
html += '<div class="col-md-6">';
}
html += i+'</div>';
}
}
$("#myDiv").html(html);
})
</script>
result:
I am filtering some of the characters from the string. I went across few questions which has a same problem ie error in the console, but could not find any good answers.
Here is my string:
response_out1|response_out2|response_out3
Here is the method that i have used:
<vs-select v-model="change">
<vs-select-item :key="index" v-bind="item" v-for="(item,index) in
userFriendly(out.changes)" />
</vs-select>
...
methods: {
userFriendly (str){
return str.replace(/_/g, ' ').split('|').map(value => ({text: value, value }))
}
Here is the output that i am getting in the vs-select:
response out1
response out2
response out3
The error that i am getting in my console:
Here i want to know why i am getting this error and i wanna know how to rectify it and the output that i am expecting is: Response Out1, here how to capitalize first character of each word in the same method.
you're using a method directly in the template which causes multiple calls whenever your data changes,
you can use computed property to avoid such a scenario, not sure about how you are accessing out.changes
this might help you to solve your error and capitalize your text,
capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
},
sentenceCase (sentence) {
return sentence.split(' ').map(s => this.capitalize(s)).join(' '));
},
userFriendly (str) {
if (!str) return;
return str.replace(/_/g, ' ').split('|').map(value => ({text: this.sentenceCase(value), value }))
},
Does anyone know if there is a way to deploy a BrowserFormWebPart (custom InfoPath form for a list content type) using standard AllUsersWebPart element and a CDATA section for the properties? So far I have tried without success. Any help is appreciated.
After 2 days of research - Following code works
private void UpdateInfoPathForms(SPSite oSite)
{
UpdateInfoPath(oSite, "Lists/Audit Calendar/Item/newifs.aspx");
UpdateInfoPath(oSite, "Lists/Audit Calendar/Item/displayifs.aspx");
UpdateInfoPath(oSite, "Lists/Audit Calendar/Item/editifs.aspx");
}
private void UpdateInfoPath(SPSite oSite, string formFileLocation)
{
var file = oSite.RootWeb.GetFile(formFileLocation);
using (SPLimitedWebPartManager manager = file.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared))
{
try
{
var wp1 = new Microsoft.Office.InfoPath.Server.Controls.WebUI.BrowserFormWebPart();
wp1.SubmitBehavior = Microsoft.Office.InfoPath.Server.Controls.WebUI.SubmitBehavior.FormDefault;
wp1.FormLocation = "~list/Item/template.xsn";
wp1.ContentTypeId = oSite.RootWeb.Lists["Audit Calendar"].ContentTypes["Item"].Id.ToString();
IListWebPart listWebpart = wp1 as IListWebPart;
listWebpart.ListId = oSite.RootWeb.Lists["Audit Calendar"].ID;
if (formFileLocation.Contains("newifs.aspx"))
{
listWebpart.PageType = PAGETYPE.PAGE_NEWFORM;
}
else if (formFileLocation.Contains("displayifs.aspx"))
{
wp1.ListFormMode = Microsoft.Office.InfoPath.Server.Controls.WebUI.ListFormMode.ReadOnly;
listWebpart.PageType = PAGETYPE.PAGE_DISPLAYFORM;
}
else if (formFileLocation.Contains("editifs.aspx"))
{
listWebpart.PageType = PAGETYPE.PAGE_EDITFORM;
}
listWebpart.ViewFlags = SPViewFlags.None;
manager.AddWebPart(wp1, "Main", 0);
manager.SaveChanges(wp1);
}
finally
{
manager.Web.Dispose();
}
}
I have had the same problem. Here is what I tried:
<AllUsersWebPart WebPartZoneID="Main" WebPartOrder="2">
<![CDATA[
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.Office.InfoPath.Server.Controls.WebUI.BrowserFormWebPart, Microsoft.Office.InfoPath.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="ChromeType" type="chrometype">None</property>
<property name="HelpMode" type="helpmode">Modeless</property>
<property name="ChromeState" type="chromestate">Normal</property>
</properties>
</data>
</webPart>
</webParts>]]>
</AllUsersWebPart>
I then have a Feature Receiver that configures the web part:
using (SPLimitedWebPartManager manager = file.GetLimitedWebPartManager(PersonalizationScope.Shared))
{
try
{
BrowserFormWebPart webpart = GetWebPart(manager);
webpart.SubmitBehavior = SubmitBehavior.FormDefault;
webpart.FormLocation = "~list/MyList/template.xsn";
webpart.ContentTypeId = "0x01003C8AD6E14DAD5342BBFAA84E63F8022C";
manager.SaveChanges(webpart);
}
finally
{
manager.Web.Dispose();
}
}
The BrowserFormWebPart properties are required for getting the form to display, but for some reason, setting those properties in the AllUsersWebPart section did not work. The form displays and I can fill it out, but the values from the form do not get inserted into the fields of the list item. I added the following section to the Feature Receiver to try to get the form to tie into the fields of the list item:
IListWebPart listWebpart = webpart as IListWebPart;
listWebpart.PageType = PAGETYPE.PAGE_EDITFORM;
listWebpart.ViewFlags = SPViewFlags.None;
Unfortunately, no joy. And that is as far as I got. Hopefully you'll have better luck.
In my PHP error handler I want to do something like:
if (ini_get('display_errors') IS ON)) {
// show debug info
} else {
// show just "oops!"
}
I've look through the docs and stuff, but I can't really find out what the possible values for display_errors are (such as "on", 0, "Yes") and what it does for what value.
What should I put in place of the "IS ON" to reliably read this value?
I use the following code:
if (in_array(strtolower(ini_get('display_errors')), ['1', 'yes', 'on', 'true']) {
// is enabled
} else {
// is disabled
}
Or regexp
if (preg_match('/^(1|yes|on|true)$/i', ini_get('display_errors')) {
// is enabled
} else {
// is disabled
}
You can get the string representation of the values through ini_get(), values that display_errors can be set to is either, true\false, 0\1 and On\Off. But when user's set their php.ini it is more common to use 1 or On
if (ini_get('display_errors') == "1") {
// show debug info
}
or to check for ALL cases, you can perform a switch-case
ini_set('display_errors', 1);
switch (ini_get('display_errors')) {
case "1":
case "On":
case "true":
// show debug info
}
If you prefer the equality comparison approach, notice that ini_get returns a String value of 1, if you test the returned value with ini_get using the == with the int value 1, it becomes true. If you use the === it checks if both are equal and of the same type. String is not the same type as int so it would return false.
1 == "1"; // in PHP, this returns true, it doesn't check the type.
1 === "1"; // would be false, this however checks the type.
Using ini_get('display_errors') you can check against values like, TRUE, FALSE, and
even NULL. They will return a boolean value of either 0 which is false and anything other than 0 evaluates to true.
if (2) {
echo "2 is true!"; // echos "2 is true!"
}
I saw your comment about a discrepancy so I decided to test it myself, here is what I used
<?php
ini_set('display_errors', 1);
$verbose = ini_get('display_errors');
echo $verbose; // echo's 1
// just to test its return values.
if ($verbose) {
echo "verbose is true"; // echos "verbose is true"
}
ini_set('display_errors', 0);
$verbose = ini_get('display_errors');
echo $verbose; // echo's 0
if ($verbose) {
echo "verbose is not true"; // does not get evaluated
}
?>
This answer is a bit lengthy, but I hope this is what you need.
Use filter_var
if ( filter_var( ini_get('display_errors'), FILTER_VALIDATE_BOOLEAN) ){
}
And that should catch all of the different ways display_errors could get turned on ("1", "true", "on", "yes", etc.).
I also can't find any official documentation on this, but from what I've experienced, I believe using filter_var with the FILTER_VALIDATE_BOOLEAN flag will cover the full gamut of possible ways an ini setting can be set to true/false.
The default is '1' according to the documentation. However, you might want to check the inverse, that it isn't off:
!= FALSE or !empty()
if (ini_get('display_errors') != FALSE))
{
// show debug info
}
else
{
// show just "oops!"
}
Or as Anthony pointed out, you could just check for 1
if(ini_get('display_errors') == 1))
You might also want to check error_reporting, as it is another common setting that is used to control the displaying of errors, although its meaning is slightly different than display_errors
if(error_reporting() != 0)