Mocking onResponseReceived response.getText()

2016-09-22 Thread Jonathan Cook
Hello,

I wanted to know if it could be possible to Mock out the response.getText() 
in a callback when using RequestBuilder. This way I can write tests to 
simulate the responses etc.

 RequestBuilder expRequestBuilder = new RequestBuilder(RequestBuilder.GET, 
encodedUrl);
try {
expRequestBuilder.sendRequest(null, new RequestCallback() {

@Override
public void onResponseReceived(final Request request, final 
Response response) {
if (response.getStatusCode() == Response.SC_OK) {
String json = response.getText();
//populate the map with the data we retrieve
JsArray array = evalJsonGetData("(" + 
json + ")");
for (int i = 0; i < array.length(); i++) {
EntityLite entity = array.get(i);
String oid = entity.getValue(
ExperimentEntityLite.EXPERIMENT_OID.getAttributeId());
...

The above shows the code which is inside a method inside a class. I thought 
maybe I could pass in the RequestBuilder as a mock but I don't think that 
will work as I want to exercise the code inside onResponseReceived

I didn't find examples unfortunately in the framework for this simple kind 
of testing.

Many thanks

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Refresh of CellTable via data transmitted via WebSocket delayed

2016-09-22 Thread Kay Pac
I have a somewhat complex problem related to a CellTable that updates based 
on messages received over a WebSocket connection. The problem is as 
follows: The table does not update in real-time, even though "setRowData" 
and redraw* are called in real-time. There is a delay in the row appearing 
in the CellTable, or rather in the DOM as a table row. I realize that 
redraw does not actually redraw but sets a flag via 
HasDataPresenter.redraw, which checked elsewhere. It is often the case that 
mouse movement causes the row to appear - and I have been able to reproduce 
this behavior. When I put in a timer firing every 300 milliseconds, its 
execution also causes the row to appear.

It is flummoxing because the problem did not occur until I switched from a 
prototype implementation of basic websockets to a prototype implementation 
of STOMP-wrapped websockets (stomp being a MOM-supported protocol for 
supported messaging from "simple clients"). However, in both cases, there 
is no difference as to when the data is delivered via setData and redraw is 
called, so the change should not affect how or when the cellTable gets 
updated.

I am considering eliminating the use of CellTable and have a simpler DOM 
manipulation, but I'd prefer to determine what I am doing that is causing 
this problem, whether it is misuse of CellTable API or inappropriate 
expectations of CellTable behavior. I can't really post any code because it 
is all integrated, and I can kind of work around it.

Does anyone have any ideas how to approach this problem or where I might 
begin to look for a solution?

Sincerely,
Kay

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Re: JSON to Client Side GWT JavaScriptObject

2016-09-22 Thread Velusamy Velu
Thank you very much! I just can't believe I missed that.

On Thursday, September 22, 2016 at 11:10:15 AM UTC-4, Jens wrote:
>
> Missing "return" statement in your JSNI method. Because you returned 
> nothing, the method returns null automatically.
>
> Also you can use 
>
> ServerResponseJson resp = JsonUtils.safeEvel(jsonString);
>
> which is safer than using JS eval() directly.
>
> -- J.
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Re: chrome 53 styleSheet insertRule not working

2016-09-22 Thread fenyoapa
I solved it by not storing the sheet in a gwt JavaScriptObject field but 
always get it with a native js method: styleElement.sheet.


-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Re: JSON to Client Side GWT JavaScriptObject

2016-09-22 Thread Jens
Missing "return" statement in your JSNI method. Because you returned 
nothing, the method returns null automatically.

Also you can use 

ServerResponseJson resp = JsonUtils.safeEvel(jsonString);

which is safer than using JS eval() directly.

-- J.

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


JSON to Client Side GWT JavaScriptObject

2016-09-22 Thread Velusamy Velu


I'm looking for help in converting a JSON to an instance of a POJO with 
embedded objects, on the GWT client side. I'm partially successful but 
unable to convert every piece of the JSON I have.


I have removed all but one working piece of code here to narrow down to the 
problem area. Specifically, my question is why the following method returns 
null?


public final native JsonArray getServerStatusCodeMap() /*-{

// debugger shows serverStatusCodeMap is valid below

this.serverStatusCodeMap; 
}-*/;


The JSON is valid (given below) and I have provided all the relevant code 
in this post. I would greatly appreciate any help.


Here's the JSON:

{
  "idOfSavedObject": "AVc-CQ4OI-SZQb7PIPb_",
  "serverStatusCodeMap": [
{
  "name": "AVc-CTACI-SZQb7PIPcO",
  "value": 202
},
{
  "name": "AVc-CTACI-SZQb7PIPcP",
  "value": 100
}
  ]}

Its JS overlay class is

public class ServerResponseJson extends JavaScriptObject {

protected ServerResponseJson() {}

public static final native ServerResponseJson build(String json) /*-{
return eval('(' + json + ')');
}-*/;

public final native String getIdOfSavedObject() /*-{
return this.idOfSavedObject;
}-*/;

public final native JsonArray getServerStatusCodeMap() /*-{
this.serverStatusCodeMap;
}-*/;}

I debugged and found the method below has the right values

public final native JsonArray getServerStatusCodeMap() /*-{
this.serverStatusCodeMap; // this attribute has the right value, the caller 
of this method gets a null
}-*/;

[image: Screen clip showing the right values for serverStatusCodeMap] 



JsonArray.java

public class JsonArray extends JavaScriptObject {
protected JsonArray() {}

public final native int length() /*-{
return this.length;
}-*/;

public final native E get(int i) /*-{
return this[i];
}-*/;}

the NameNumberJson.java

public class NameNumberJson extends JavaScriptObject {
protected NameNumberJson() {}

public static final native NameNumberJson buildNameNumberJson(String json) 
/*-{
return eval('(' + json + ')');
}-*/;

// Return the whole JSON array, as is
public static final native JsonArray 
getNameNumberJsons(String json) /*-{
return eval('(' + json + ')');
}-*/;

public final native String getName() /*-{
return this.name;
}-*/;

public final native int getValue() /*-{
return this.value;
}-*/;}

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.