Editing a ValueProxy on an EntityProxy

134 views
Skip to first unread message

RyanD

unread,
Jan 23, 2011, 2:25:20 AM1/23/11
to Google Web Toolkit
I'm missing something basic here. Given File EntityProxy, and
FileData ValueProxy, I've tried several combinations such as:

----
File file = req.edit(existingFile);
file.getData().setTextData("something");
req.persist().using(file).fire(...);

and

File file = req.edit(existingFile);
FileData data = req.edit(existingFile.getData());
data.setTextData("something");
req.persist().using(file).fire(...);

and

File file = req.edit(existingFile);
FileData data = req.create(FileData.class);
data.setTextData("something");
file.setData(data);
req.persist().using(file).fire(...);
----

None of these will update the FileData ValueProxy on the existing File
object. On the server side the setter just receives a FileData
instance with a null property value for getTextData().

- Logging shows that persist() is being called as expected
- No exceptions thrown for any technique
- FileData implements hashCode and equals()
- file.setData(...) is being called on the server, and it is being
passed an instance of FileData, however the text property is always
null
- I am able to edit other non-ValueProxy properties on the File object
successfully, so it doesn't appear to be a problem with the process as
a whole

Any idea what I'm missing (is there a correct example out there)?

Thanks,

Ryan

SrArcos

unread,
Jan 23, 2011, 4:36:08 AM1/23/11
to Google Web Toolkit
Hi,

Can you post the entity code? "data" is a basic value, or another
related entity?

Thomas Broyer

unread,
Jan 23, 2011, 5:08:30 AM1/23/11
to google-we...@googlegroups.com
It's possible that the setData is called before the FileData's setTextData is called; have you checked the value of TextData from within the persist() method?

RyanD

unread,
Jan 23, 2011, 11:53:46 AM1/23/11
to Google Web Toolkit
SrArcos: FileData is a simple ValueProxy. It is just a wrapper
around a potentially large String so I can easily include / exclude it
from certain requests.

Thomas: I retried the first scenario (above) with additional logging:

- First: file.setData(..) is called first by GWT. It is passed an
instance of FileData.
- Second: fileData.setTextData(...) is called by GWT on the instance
it just passed to file.setData(..). However setTextData is passed a
null String value.

For testing purposes on the client side I'm truly just setting a plain
String value of "something".

So it's odd, but GWT server side seems to be going through the motions
of setting the ValueProxy -- but it's setting it with a null String.

I'll presume that my first example is a valid approach for future
tests.. Any ideas on what to test or log next?

Thanks,

Ryan

Thomas Broyer

unread,
Jan 23, 2011, 2:13:20 PM1/23/11
to google-we...@googlegroups.com


On Sunday, January 23, 2011 5:53:46 PM UTC+1, RyanD wrote:
SrArcos:  FileData is a simple ValueProxy.  It is just a wrapper
around a potentially large String so I can easily include / exclude it
from certain requests.

Depending on the exact use case, note that you can also do this by listing in a .with() all properties you do want (excluding the "potentially large String" property when not needed). If you're using the Editor framework, it's a no-brainer: just use the RequestFactoryEditorDriver's getPaths() method.
 
Thomas:  I retried the first scenario (above) with additional logging:

- First: file.setData(..) is called first by GWT.  It is passed an
instance of FileData.
- Second: fileData.setTextData(...) is called by GWT on the instance
it just passed to file.setData(..).  However setTextData is passed a
null String value.

I believe you have to .edit() the FileData, as in the second scenario.

RyanD

unread,
Jan 23, 2011, 3:00:57 PM1/23/11
to Google Web Toolkit
> I believe you have to .edit() the FileData, as in the second scenario.

Tried that -- produces the same null result via logging. Not sure
what's going on here. I may push forward with your second suggestion
and ditch the ValueProxy for now. Perhaps by the time I truly need a
ValueProxy there will be an example or insight into why this isn't
working. Thanks for your thoughts.

Ryan

Thomas Broyer

unread,
Jan 23, 2011, 3:42:08 PM1/23/11
to google-we...@googlegroups.com
We do use ValueProxy-s and I believe they work (my co-workers would have blamed me otherwise, as I'm the one who pushed for the switch between GWT-RPC and RequestFactory).

Do you see the "something" string (should be something like {"textData":"something"}) in the payload sent by the browser? (use Firebug or similar)

RyanD

unread,
Jan 23, 2011, 4:09:26 PM1/23/11
to Google Web Toolkit
Here is the payload from both the 1st approach and the 2nd approach
(they were identical payloads):

{"O":[{"C":5,"T":"x.x.FileDataProxy","R":"1"},
{"O":"UPDATE","T":"x.x.FileProxy","S":"Ii1EWVRoRUVfU2VxWGVvX09mTU5jT1E6TXRGSlVuNG1UN3VDUW51WlY2djJjQSI=","V":"IjEyOTU3NjU3NDkyNDIi"}],"I":
[null],"S":[true]}

So it seems like it has both objects in the payload as expected.. but
no "something" value.

Ryan

Thomas Broyer

unread,
Jan 23, 2011, 4:37:04 PM1/23/11
to google-we...@googlegroups.com
Looking at AbstractRequestContext, it looks like you don't have to explicitly .edit() ValueProxy-s if you .edit()ed the containing EntityProxy (or ValueProxy), so scenarios 1 and 2 would be identical (and req.edit(file.getData() should be == file.getData()).

As SrArcos already asked, could you show us the code of your proxies?

RyanD

unread,
Jan 23, 2011, 5:15:35 PM1/23/11
to Google Web Toolkit
Absolutely:

---
@ProxyFor(File.class)
public interface FileProxy extends EntityBaseProxy{
public String getPath();
public void setPath(String path);
public String getContentType();
public DefinitionFileDataProxy getData();
public void setData(DefinitionFileDataProxy data);
}

@ProxyFor(FileData.class)
public interface FileDataProxy extends ValueProxy {
public String getTextData();
public void setTextData(String textData);
}
---

As mentioned, I am able to successfully "edit" other properties such
as "File.path" clear through to server side, which is why I'm focusing
on the ValueProxy.

Anything useful gleaned there?

Thanks,

Ryan

RyanD

unread,
Jan 23, 2011, 5:22:34 PM1/23/11
to Google Web Toolkit
Oh, and EntityBaseProxy is simply the following at the moment:

public interface EntityBaseProxy extends EntityProxy {
public String getId();

Y2i

unread,
Jan 23, 2011, 5:38:21 PM1/23/11
to google-we...@googlegroups.com
What is the difference between FileDataProxy and DefinitionFileDataProxy?  FileProxy doesn't have anything that works with FileDataProxy.

RyanD

unread,
Jan 23, 2011, 5:42:05 PM1/23/11
to Google Web Toolkit
Apologies for the confusion. I was originally retyping some of this
to make the example shorter / simpler.

So yes, the correct example proxy is:

public FileDataProxy getData();
public void setData(FileDataProxy data);

(On my end these classes are all prefixed with "Definition").

Y2i

unread,
Jan 23, 2011, 5:49:10 PM1/23/11
to google-we...@googlegroups.com
It might not help, but may be you can try this code?

File file = req.edit(existingFile);
FileData data = file.getData(); 
data.setTextData("something"); 
file.setData(data);
req.persist().using(file).fire(...); 

RyanD

unread,
Jan 23, 2011, 5:59:35 PM1/23/11
to Google Web Toolkit
OK, I tried that. Unfortunately it produces the same payload as the
other examples.

Interesting:

I tried not setting any properties on the File object whatsoever.

Simply:

File file = req.edit(existingFile);
req.persist().using(file).fire(...);

And this also produces the same payload as all of our "setData"
examples.

So it appears that from GWT's standpoint, all of our approaches have
been no-op's.

Ryan

Smithimage

unread,
Oct 26, 2012, 5:51:23 AM10/26/12
to google-we...@googlegroups.com
Hi there RyanD!

Did you find a solution to this problem?
I am in a similar predicament.. I also try to persist a large string on a EntityProxy (not using a valueproxy though) and I also get only null values on the server side when the persist method is called..

Best regards!
Reply all
Reply to author
Forward
0 new messages