Skip to content

Commit 19cf896

Browse files
authored
Update HttpAjaxContext.java (#548)
* Update HttpAjaxContext.java Support for multiple refresh executions for the same grid instance * Update HttpAjaxContext.java Keep legacy generated code compatibility
1 parent 7b1fc3c commit 19cf896

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

java/src/main/java/com/genexus/internet/HttpAjaxContext.java

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import java.util.Enumeration;
77
import java.util.Hashtable;
88
import java.util.Stack;
9+
import java.util.Collections;
10+
import java.util.Arrays;
911

1012
import com.genexus.IGXAssigned;
1113
import com.genexus.diagnostics.core.ILogger;
@@ -28,7 +30,8 @@ public abstract class HttpAjaxContext
2830
protected JSONObject Messages = new JSONObject();
2931
private JSONObject WebComponents = new JSONObject();
3032
private Hashtable<Integer, JSONObject> LoadCommands = new Hashtable<>();
31-
private JSONArray Grids = new JSONArray();
33+
private ArrayList Grids = new ArrayList();
34+
private Hashtable<String, Integer> DicGrids = new Hashtable<String, Integer>();
3235
private JSONObject ComponentObjects = new JSONObject();
3336
protected GXAjaxCommandCollection commands = new GXAjaxCommandCollection();
3437
protected GXWebRow _currentGridRow = null;
@@ -485,13 +488,23 @@ public void ajax_rsp_assign_hidden_sdt( String SdtName, Object SdtObj)
485488
}
486489
}
487490

488-
public void ajax_rsp_assign_grid(String gridName, com.genexus.webpanels.GXWebGrid gridObj)
491+
public void ajax_rsp_assign_grid(String gridName, com.genexus.webpanels.GXWebGrid gridObj)
492+
{
493+
Object jsonObj = ((IGxJSONAble) gridObj).GetJSONObject();
494+
Grids.add(jsonObj);
495+
}
496+
497+
public void ajax_rsp_assign_grid(String gridName, com.genexus.webpanels.GXWebGrid gridObj, String Control)
489498
{
490-
try {
491-
Grids.putIndex(0, gridObj.GetJSONObject());
492-
}
493-
catch (JSONException e) {
494-
}
499+
Object jsonObj = ((IGxJSONAble) gridObj).GetJSONObject();
500+
if (DicGrids.containsKey(Control)) {
501+
Grids.set(DicGrids.get(Control), jsonObj);
502+
}
503+
else
504+
{
505+
Grids.add(jsonObj);
506+
DicGrids.put(Control, Grids.size() - 1);
507+
}
495508
}
496509

497510
public void ajax_rsp_clear(){
@@ -586,6 +599,8 @@ protected String getJSONResponsePrivate(String cmpContext)
586599
GXJSONObject jsonCmdWrapper = new GXJSONObject(isMultipartContent());
587600
try
588601
{
602+
Collections.reverse(Arrays.asList(Grids));
603+
JSONArray JSONGrids = new JSONArray(Grids);
589604
if (commands.AllowUIRefresh())
590605
{
591606
if (cmpContext == null || cmpContext.equals(""))
@@ -598,7 +613,7 @@ protected String getJSONResponsePrivate(String cmpContext)
598613
jsonCmdWrapper.put("gxValues", AttValues);
599614
jsonCmdWrapper.put("gxMessages", Messages);
600615
jsonCmdWrapper.put("gxComponents", WebComponents);
601-
jsonCmdWrapper.put("gxGrids", Grids);
616+
jsonCmdWrapper.put("gxGrids", JSONGrids);
602617
}
603618
for(Enumeration loadCmds = LoadCommands.keys(); loadCmds.hasMoreElements();)
604619
{

0 commit comments

Comments
 (0)