PDA

View Full Version : [FIXED] FieldLabel: fieldSeparator is shown even you set the separator to "" for a field



gishmo
15 Jan 2012, 10:14 AM
I would expect, that it is possible to set a for one field in a form.

pete_by
11 Feb 2012, 3:31 PM
This works for me:

label.setLabelSeparator("");
label.setText(""); // set any text

gishmo
12 Feb 2012, 8:37 AM
It works! Thanks

@Sencha:
Is it possible to add the label separator to the signature of the constructor?

Something like that:


public FieldLabel(Widget widget, String label, String labelSeparator) {
this(widget);
this.labelSeparator = labelSeparator;
setText(label);
}

public FieldLabel(Widget widget, String label, String labelSeparator, FieldLabelAppearance appearance) {
this(widget, appearance);
this.labelSeparator = labelSeparator;
setText(label);
}



This will save some code.

sven
12 Feb 2012, 8:40 AM
Normally you do not change the separator so often. This means having extra a contructor for this does not make so much sense. If you require this, you can easily subclass FieldLabel and add this to your own contructor.

gishmo
12 Feb 2012, 8:50 AM
Creating large forms with a lot of fields might be annoying, because you need four statements to do the same thing you can do with one having these constructor.

FieldLabel fl = new FieldLabel(widget, "", "");
fl.setLabelSeparator("");
fl.setText("");
fc.add(fl, new VerticalLayoutData(1, -1));

compare to

fc.add(new FieldLabel(widget, "", ""), new VerticalLayoutData(1, -1));

Of course, I can subclass FieldLabel, but this looks a little bit nicer to me... ;-)

sven
12 Feb 2012, 10:18 AM
This is only the case when you really want to change the separater, which, as i said, is not used that often. If you do not want to change it than there is already a contructor which only takes the label.

pete_by
12 Feb 2012, 10:48 AM
This is only the case when you really want to change the separater, which, as i said, is not used that often. If you do not want to change it than there is already a contructor which only takes the label.

I think it is misleading behaviour: you can specify separator character using UiBinder but it does not take any effect! It is impossible to initialize widget that way. Why then have a setter for it at all, if we can subclass the FieldLabel and do it the right way? Same is for setting field label length (there is a post in the thread): you cannot change it after the label has been constructed, though there is a public setter for it :)

Konstantin.Scheglov
15 Feb 2012, 1:16 PM
+1
Please, guys, think about UiBinder users too.
UiBinder is one of the major benefits of GXT 3.0, right?

sven
15 Feb 2012, 2:02 PM
UiBinder users should not be effected by this request at all.

Mark Anderson
15 Feb 2012, 4:51 PM
Actually as Konstantin told, UiBinder is affected.

FieldLabel.setText() uses "labelSeparator".
But when "labelSeparator" is set, it does not change text!


Look into BeanParser.


for (Map.Entry<String, String> entry : setterValues.entrySet()) {
String propertyName = entry.getKey();


"setterValues" is {text="myText", labelSeparator="sss"} here, because it is HashMap, so order of items is almost random. So, problem is that FieldLabel is not actually bean, because its behavior depends on order of setters calling.

We had same problem during developing GXT 2.x support in GWT Designer.
But that was Java and we can solve this by using "correct" (i.e. expected by Ext GWT) order of setters calling. I'm not sure what to do in case of UiBinder...

WesleyMoy
15 Feb 2012, 8:25 PM
We made some changes to FieldLabel's innards in Beta 3. Specifically, calling setLabelSeparator (and a few other setters) immediately updates the label to reflect these changes. This should make it unnecessary to make the setText call after setLabelSeparator. Also, this should make it possible to use FieldLabel reliably in UiBinder.

This change has been included in Beta 3, so give it a try to see if this fixes your issue.

Mark Anderson
15 Feb 2012, 8:45 PM
Yes, I can now set "labelSeparator" attribute in UiBinder and it works.
Empty value for "labelSeparator" also works.

sven
15 Feb 2012, 9:28 PM
The comment was for adding a new contructor or not. That is completely not UiBinder related.