So I load a basic page with the canvas and everything seems to work except newlines are shown as \n
here is the body as a java method:
input = StringEscapeUtils.unescapeShell(this.getData());
private String htmlBody(String input){
return "<html><head>" +
"<link href=\"fonts.css\" type=\"text/css\" rel=\"stylesheet\" />" +
"<script src=\"jquery.min.js\" type=\"text/javascript\"></script>" +
"<script src=\"fontfaceobserver.js\" type=\"text/javascript\"></script>" +
"<script src=\"fabric.min.js\" type=\"text/javascript\"></script>" +
"<style type=\"text/css\">" +
".canvas-container {" +
"margin: 0 auto;" +
"}"+
"</style>" +
"<script src=\"javascript_fabric.js\" type=\"text/javascript\"></script>" +
"</head><body>"+
"<div id=\"sb2div\" class=\"row\" style=\"margin: 0 auto!important; max-height: 100vh\">" +
"<canvas id=\"fabricjs-branding\" width=\"600\" height=\"600\" style=\"margin: auto!important;\"></canvas>" +
"</div>" +
"<script>" +
"$(document).ready(function(){" +
"setUpBranding();" +
"var o = " + input + ";" +
"console.log(o);" +
"fabricjscanvas.loadFromJSON(o);"+
"});" +
"</script>" +
"</body></html>";
}
setUpBranding() does my initialization of fabricjscanvas which does add some feature prototypes but the issue has nothing to do with them.
itext and textbox are standard using the current release 4
on the desktop using the same setup everything is fine...
based on a comment i found the newline characters were not getting unescaped with the rest of the json data... strange but I was able to fix it using the Java String Replace method... after using the StringEscapeUtils.unescapeShell
input = StringEscapeUtils.unescapeShell(this.getData());
input = input.replace("\\\\n", "\\n");
Related
I have this JavaScript in my transformer
var dbConn;
try {
dbConn = DatabaseConnectionFactory.createDatabaseConnection($gc('DataWarehouseXMLDataConfig').sqlDriver,
$gc('DataWarehouseXMLDataConfig').sqlConnString,
$gc('DataWarehouseXMLDataConfig').sqlUsername,
$gc('DataWarehouseXMLDataConfig').sqlPassword);
var data = dbConn.executeCachedQuery('EXEC [dbo].[GetDataWarehouseData]');
var xml = "";
var xml2 = "";
var row = "";
while(data.next()) {
row = '<referral>' + '\n' +
'<careid>' + data.getString('careid') + '</careid>' + '\n' +
'<patientid>' + data.getString('patientid') + '</patientid>' + '\n' +
'<dateofreceipt>' + data.getString('dateofreceipt') + '</dateofreceipt>' + '\n' +
'<datefirstseen>' + data.getString('datefirstseen') + '</datefirstseen>' + '\n' +
'<nhsnumber>' + data.getString('nhsnumber') + '</nhsnumber>' + '\n' +
'<hospitalnumber>' + data.getString('hospitalnumber') + '</hospitalnumber>' + '\n' +
'<surname>' + data.getString('surname') + '</surname>' + '\n' +
'<forename>' + data.getString('forename') + '</forename>' + '\n' +
'<dateofbirth>' + data.getString('dateofbirth') + '</dateofbirth>' + '\n' +
'</referral>';
xml = xml + row;
xml2 = '<?xml version="1.0" encoding="utf-8"?>' + '\n' + '<results>' + xml + '</results>';
}
channelMap.put('xml2', xml2);
} finally {
if (dbConn) {
dbConn.close();
}
}
I'm using this outbound message template
<referral>
<careid></careid>
<patientid></patientid>
<dateofreceipt></dateofreceipt>
<datefirstseen></datefirstseen>
<nhsnumber></nhsnumber>
<hospitalnumber></hospitalnumber>
<surname></surname>
<forename></forename>
<dateofbirth></dateofbirth>
</referral>
I have a File Writer destination and the File Name has a .xml extension.
My template in the File Writer is ${XmlUtil.prettyPrint(${message.encodedData})}.
The SQL data is being retrieved ok.
I don't think I'm a million miles away but I'm doing something fundamentally wrong.
What do I need to do to send the required xml file please?
I fixed this by adding a mapping step to the source transformer and using JavaScript, like
tmp['referral']['dateofbirth'] = msg['dateofbirth'].toString();
I'm using HttpURLConnection to post to https://api.twilio.com/2010-04-01/Accounts/****/Messages.json
this works for SMS - but when the txtTo and txtFrom are changed to To=whatsapp:+12345567&From=whatsapp:+123456778&Body=sacsacsac
it stops working ..... any ideas?
String message = "To=" + txtTo + "&From=" + txtFrom + "&Body=" + txtBody;
byte[] postData = message.getBytes( StandardCharsets.UTF_8 );
String message = "From=" + URLEncoder.encode("whatsapp:" + txtFrom, "UTF-8") +"&Body=" + URLEncoder.encode(txtBody, "UTF-8") + "&To=" + URLEncoder.encode("whatsapp:" + txtTo, "UTF-8");
<%Response.Write("<img class="lazy" src=img_cart/image28/" + Session["image1"] + ".jpg" + " />"); %>
This code gives error only assignment,call,increment,decrement, and new object
expressions can be used as a statement.
So how to write images src and class using response.write method like this:
<%Response.Write("<img class="lazy" src=img_cart/image28/" + Session["image1"] + ".jpg" + " />"); %>
Expected end result:
<img class="lazy" src="img_cart/image28/IMAGENAME.jpg" />
If you're using C#, the problem is that you must use escape chars because of the double quotes symbols " . They should be written as \" because they are contained in other double quotes. So try this:
<%Response.Write("<img class=\"lazy\" src=\"img_cart/image28/" + Session["image1"] + ".jpg\" />"); %>
I have got the following problem. I encountered an error regarding the default parameters. I added a simple piece of code for an overload. Now I get in the new code (line 3: CreatePageSection(sItemID, "", null);) gives the error mentioned in the title.
I looked for the answer in the other topics, but I can't find the problem. Can someone help me?
The code is found here:
public void CreatePageSection(ref string sItemID)
{
CreatePageSection(sItemID, "", null);
}
public void CreatePageSection(ref string sItemID, ref string sFrameUrl, ref object vOnReadyState)
{
if (Strings.InStr(msPresentPageSections, "|" + sItemID + "|", 0) > 0) {
return;
}
msPresentPageSections = msPresentPageSections + sItemID + "|";
string writeHtml = "<div class=" + MConstants.QUOTE + "PageSection" + MConstants.QUOTE + " id=" + MConstants.QUOTE + "Section" + sItemID + "Div" + MConstants.QUOTE + " style=" + MConstants.QUOTE + "display: none;" + MConstants.QUOTE + ">";
this.WriteLine_Renamed(ref writeHtml);
//UPGRADE_WARNING: Couldn't resolve default property of object vOnReadyState. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
//UPGRADE_NOTE: IsMissing() was changed to IsNothing_Renamed(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="8AE1CB93-37AB-439A-A4FF-BE3B6760BB23"'
writeHtml = " <iframe id=" + MConstants.QUOTE + sItemID + "Frame" + MConstants.QUOTE + " name=" + MConstants.QUOTE + sItemID + "Frame" + MConstants.QUOTE + " frameborder=" + MConstants.QUOTE + "0" + MConstants.QUOTE + (!string.IsNullOrEmpty(sFrameUrl) ? " src=" + MConstants.QUOTE + sFrameUrl + MConstants.QUOTE : "") + ((vOnReadyState == null) ? "" : " onreadystatechange=" + MConstants.QUOTE + Convert.ToString(vOnReadyState) + MConstants.QUOTE) + ">";
this.WriteLine_Renamed(ref writeHtml);
writeHtml = " </iframe>";
this.WriteLine_Renamed(ref writeHtml);
writeHtml = "</div>";
this.WriteLine_Renamed(ref writeHtml);
}
you must pass params by reference
public void CreatePageSection(ref string sItemID)
{
var missingString = String.Empty;
object missingObject = null;
CreatePageSection(ref sItemID, ref missingString, ref missingObject);
}
Since your are not manipulating sFrameUrl and vOnReadyState, remove the ref keyword from those parameters.
See: http://msdn.microsoft.com/en-us/library/14akc2c7(v=vs.71).aspx
hth
Mario
OK so this is a very strange problem. I have a servlet running on my machine that returns XML code for use in fusion charts. I know the server is writing the data to to the stream because I have it printing out what it is writing. Which looks like this:
Data: "<chart caption='FusionChart' xAxisName='Month in 1200' yAxisName='Men Killed'>" + "<set label='January' value='10.0' />" + "<set label='February' value='13.0' />" + "<set label='March' value='18.0' />" + "<set label='April' value='12.0' />" + "<set label='May' value='22.0' />" + "<set label='June' value='14.0' />" + "<set label='July' value='18.0' />" + "<set label='August' value='12.0' />" + "<set label='September' value='14.0' />" + "<set label='October' value='10.0' />" + "<set label='November' value='19.0' />" + "<set label='December' value='15.0' />" + "</chart>"
Now heres the strange part when GWT 2.3 gets the data from a response and is shown in an alert window or an HTML widget all it shows is "" + "" + "" + "" + "" + "" + "" + "" and so on. Its like all the XML data was stripped out. Anyone know a reason for that?
Thanks.
How are you adding the returned data to the DOM? If you're treating it as raw HTML (e.g. calling setInnerHtml()) that would explain the behavior that you're seeing. If you inspect the DOM structure with FireBug/WebInspector, do you see a <chart> element?
Depending on the widget that you're using to display the XML, you'll want something like setInnerText().