Sunday, September 25, 2011

Re: Edit an object in a List without a ListEditor

So if I understand correctly, ValueAwareEditor basically allows you to
muck with how the object obtains its values? I have tried to
implement this in 2.3 but now I am getting a problem with the Config
object not retaining the values set for the LanguageProxy. That is,
the returned ConfigProxy seems to have the values but once the code
calls to the Server side, the values have been reset to "null".

In my code:

In ConfigViewImpl (which implements ConfigView which in turn
implements ValueAwareProxy<ConfigProxy>):

<pre>
@Override
public void flush()
{
List<LanguageProxy> languages = new ArrayList<LanguageProxy>();

// Not sure if this is the correct way to create an editable
ValueProxy
LanguageProxy lang =
requestFactory.configRequest().create(LanguageProxy.class);

lang.setString(language.getText());
lang.setDefault(true);
languages.add(lang);
proxy.setLanguageList(languages);
}
...
@Override
public void setValue(ConfigProxy value)
{
proxy = value;
}
</pre>


Then in ConfigPresenter:

<pre>
public void save()
{
ConfigRequestContext context =
(ConfigRequestContext)view.getEditorDriver().flush();

// If I use this code, the values persist properly.
//LanguageProxy language = context.create(LanguageProxy.class);
//language.setString("FRA");
//editProxy.setLanguageList(new ArrayList<LanguageProxy>());
//editProxy.getLanguageList().add(language);

if (null == saveRequest)
{
saveRequest = context.save(editProxy);
}

view.setLocked(true);

// Up to this point, the editProxy contains an ArrayList with
the correct LanguageProxy
saveRequest.fire(new Receiver<Void>()
{
@Override
public void onSuccess(Void response)
{
view.setLocked(false);
view.close();
}
}
</pre>

On the server side's Save code, my Config object still contains an
ArrayList with a Language object but the fields of the Language object
are all null. If I use the commented code which sets the values in the
Presenter then those values will persist to the server side
correctly. Is this an issue with the way I have setup my
ValueAwareEditor, how I created the LanguageProxy, or something else?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment