View Full Version : Change Text in a Dialog (with AdapterField)

27 Oct 2011, 8:40 AM

I'm dealing with a simple custom Dialog to login.. I have the error displayed at the the bottom like through an AdapterField, such as

Text errorText = new Text(errorMessage);
LayoutContainer errorPanel = new LayoutContainer();
AdapterField errorAdapter = new AdapterField(errorPanel);

This first try went all fine, but problem is, i can get a few different error messages from the RPC, and i need to change the errorMessage string and display it accordingly. How do I do that?

I tried creating a first errorAdapter as before, and then change it and re-render it with the new error message i get from the RPC with something like:

errorAdapter = new AdapterField(errorPanel);

and even add (from random googling..)


but no luck. Always the same message I set at the very beginning. Any hints?

Is it possible to do want I'm trying to accomplish here?
I found this thread on changing field labels after rendering (http://www.sencha.com/forum/showthread.php?38066-Set-field-labels-after-rendering-a-form-panel) but the question remains unresolved (also, it's not exaclty the same thing..).

Thank you so much

3 Nov 2011, 1:30 AM
Help anyone? :)

Colin Alworth
3 Nov 2011, 10:17 AM
Unfortunately, you haven't given us enough to even replicate the setup you are currently using - several lines refer to 'this', which means you've subclassed something, but we can't see what, or what else has been changed. It also isn't clear how 'this' is added to the Dialog, or if perhaps it is the dialog itself.

Couple of things to try: First, use firebug, and see if you can see the text you've tried to add. If it is there, but hidden, then there is a style or layout issue. If it isnt there at all, it could still be a layout issue, or one of the fields/local vars you are using isn't actually being drawn.

Then, try to reproduce the issue in a very simple example, and paste the full example here. Reproducing it will make you tear it down until all that is left is the code that should be relevant here. If there happens to be a mistake in your own code, you often find it during this process. We can then look at the full example, and see everything that is going on - and even run it to reproduce your result.

7 Nov 2011, 7:15 AM
Thanks for you answer, Colin. Sorry, that was dumb of me not specifying what that this was: i subclassed the Dialog itself.

Anyway, your tip sent me in the right direction and I solved. I'm very new to Gxt and it didn't cross my mind to check the layout with Firebug! Thank you very much!

Just for history, brief report...
I gave up all the panel.add and panel.remove and by creating my Adapter field -inside a MyDialog class, that extends Dialog - as:

errorPanel = new LayoutContainer();
errorText = new Text("");
AdapterField adapter = new AdapterField(errorPanel);

then replacing the error message with my custom one each time, with

Element errorElement = errorPanel.getElement();

That works!