PDA

View Full Version : [CLOSED] problem with vvout_toJsonPair(...)


ThierryC
04-28-2010, 07:59 AM
i'm having trouble to send Html-formatted data back to ext.
i thought it had something to do with the length of the string, but according to the api-manual; it can be 65K(?)
so.. for some reason the string gets splitted...

thx for having a look at this.

here's what happens

in firebug i see: (value gets splitted for some reason?)
{"SUCCESS":"1",
"PARM":"<p style=\"font-family:Arial; font-weight:bold\">Updates due to change in calendars<hr></p>
<table border=\"1\" cellpadding=\"2\" cellspacing=\"0\"style=font-family:courier new; text-align-right\">
<tr style=\"background-color:silver\"><td>Month</td>
<td>Before</td>
<td>After</td></tr>
<tr><td>2010/08</td><td>15</td><td>13</td></tr></table><br>
<p style=\"font-family:Arial; font-weight:bold\">Data<hr></p>
<table border=\"1\" cellpadding:\"2\" cellspacing:\"0\" style=\"font-family:courier new; font"}


although when i debug my rpg-program i'm sending this :

d string s 5000a varying

vvOut_toJsonPair(string);

this is the content of "string" just before the vvout_toJsonPair
(i've restyled it a little for visibility.. but normally this is 1 long string.
SUCCESS:1,PARM:<p style="font-family:Arial; font-weight:bold">
Updates daa to change in calendars<hr></p><table border="1"
cellpadding="2" cellspacing="0"style=font-family:courier new;
text-align-right">
<tr style="background-color:silver"><td>Month</td>
<td>Before</td><td>After</td></tr><tr><td>2010/08</td>
<td>15</td>
<td>13</td></tr>
</table><br><p style="font-family:Arial; font-weight:bold">Data<hr></p>
<table border="1" cellpadding:"2" cellspacing:"0" style="font-family:courier new; font-size:11px; text-align:right">
<tr style="background-color:silver"><td colspan=2></td>
><td>Jan</td>
<td>Feb</td>
<td>Mrt</td>
<td>Apr</td>
<td>May</td>
<td>Jun</td>
<td>Jul</td>
<td>Aug</td>
<td>Sep</td>
<td>Oct</td>
<td>Nov</td>
<td>Dec</td>
</tr>
<tr style="background-color:LightSteelBlue">
<td colspan=15 style="text-align:center; font-size:15px">YEAR : 2010</td></tr>
<tr><td>FC/TO</td>
<td>Before</td>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>3220,00</td>
<td></td><td></td><td></td><td></td></tr><tr><td></td>
<td>After</td>
<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>3220,01</td>
<td></td><td></td><td></td><td></td>
</tr>
</table>

sean.lanktree
04-28-2010, 08:40 AM
There are 3 possible parameters to vvOut_toJsonPair:

data
name value separator
pair separator


If you do not pass a name value separator, the procedure will assume that the data uses a ":". For example....

FIELD:VALUE

If you do not pass a pair separator, the procedure will assume that the data uses a ",". For example...

FIELDA:VALUE,FIELDB:VALUE

In your case, the data is using a ":" as the name value separator and a "," as the pair separator.

SUCCESS:1,PARM:<p style="font-family:Arial; font-weight:bold">
Updates daa to change in calendars<hr></p>

However, the problem may be that your data also contains the name value separator (":") in the string where it is really not meant to separate the data.

SUCCESS:1,PARM:<p style="font-family:Arial; font-weight:bold">
Updates daa to change in calendars<hr></p>

So I would try the following:


string = 'SUCCESS*1,PARM*<p style=...............

vvOut_toJsonPair(string:'*');


Instead of separating the name values with the standard ":", I used a "*". Then I just need to pass that value to vvOut_toJsonPair so it knows what to look for.

ThierryC
04-28-2010, 11:52 AM
Hi Sean,

i've tried as suggested, but still get the same result :
characters in red were not returned(?)


{"SUCCESS":"1","PARM":"<p style=\"font-family:Arial; font-weight:bold\">
Updates daa to change in calendars<hr></p>
<table border=\"1\" cellpadding=\"2\" cellspacing=\"0\"style=font-family:courier new; text-align-right\">
<tr style=\"background-color:silver\">
<td>Month</td><td>Before</td><td>After</td></tr><tr><td>2010/08</td><td>15</td><td>13</td></tr></table><br>
<p style=\"font-family:Arial; font-weight:bold\">Data<hr></p>
<table border=\"1\" cellpadding=\"2\" cellspacing=\"0\"
style=\"font-family:courier new; font"}

this is what was sent to the api

SUCCESS*1,PARM*<p style="font-family:Arial; font-weight:bold">
Updates daa to change in calendars<hr></p>
<table border="1" cellpadding="2" cellspacing="0"style=font-family:courier new; text-align-right">
<tr style="background-color:silver">
<td>Month</td><td>Before</td><td>After</td></tr>
<tr><td>2010/08</td><td>15</td><td>13</td></tr></table><br>
<p style="font-family:Arial; font-weight:bold">Data<hr></p><table border="1" cellpadding="2" cellspacing="0"
style="font-family:courier new; font-size:11px; text-align:right">
<tr style="background-color:silver"><td colspan=2></td><td>Jan</td><td>Feb</td><td>Mrt</td><td>Apr</td>
<td>May</td><td>Jun</td><td>Jul</td>
<td>Aug</td><td>Sep</td><td>Oct</td>
<td>Nov</td><td>Dec</td></tr>
<tr style="background-color:LightSteelBlue"><td colspan=15 style="text-align:center; font-size:15px">YEAR : 2010</
td></tr><tr><td>FC/TO</td><td>Before</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>3220,00<
/td><td></td><td></td><td></td><td></td></tr><tr><td></td><t
d>After</td><td></td><td></td><td></td><td></td><td></td><td
></td><td></td><td>3220,01</td><td></td><td></td><td></t
d><td></td></tr></table>

richard.milone
04-28-2010, 12:39 PM
I only use toJsonPair for small snippets of data. I'm not really sure if it has a size limitation (that's Sean's area) but for this you might want to just construct the JSON manually and send it out to the browser through vvOut_data like this:

vvOut_data('{"SUCCESS":"1","PARM":' + YOURFIELDWITHHTMLDATA + '}':JSON);This would also guarantee that toJsonPair wouldn't be confused by special characters in your HTML string.

ThierryC
04-29-2010, 07:23 AM
Thx Richard,

your advice works, but needs some extra details;

There were still some issues when posting back the Json data.
The (to Json) special chars in the Html string need to be converted.
- f.e no Double quotes allowed (in the text the " needed to be replaced by \",) and also double quote preceding and followed by a double quote

Isn't there a vv...api capable of doing this.. or should the html-string be exported in another way(?)
Normally it would be great if the vvout_tosjsonpair would be capable of doing this.

richard.milone
04-29-2010, 10:01 AM
Try wrapping your HTML field around a vvUtility_encode like this. vvUtility_encode should replace any of the special characters needed for the JSON response.

vvOut_data('{"SUCCESS":"1","PARM":' + vvUtility_encode(YOURFIELDWITHHTMLDATA:JSON) + '}':JSON);

richard.milone
09-28-2010, 06:34 PM
Determined that this is not a bug. Moving to the community support forum.

richard.milone
09-28-2010, 06:36 PM
Proper way to load html into an existing page is not really an Ajax call. Instead, use a standard Ext.Panel with autoLoad option to load html into the panel dynamically.