PDA

View Full Version : TextField.setStyleName("pflichtFelder") has no effect



Ceene
12 Sep 2011, 4:28 AM
Hey all

I have a problem with a TextField<String>.
I tried to change the background in my project css file, but I don't get it.
In my project.css is an entry ".pflichtFelder".
Then in my code ist TextField.setStyleName("pflichtFelder");
Wher is my mistake? I pray for help :)

sven
12 Sep 2011, 4:30 AM
In my project.css is an entry ".pflichtFelder".

You missed the most important information. What is the content of ".pflichtFelder"?



Then in my code ist TextField.setStyleName("pflichtFelder");
You should use addStyleName in 99,99% of all cases.

sven
12 Sep 2011, 4:31 AM
I always suggest to use Firebug or IE Developer Tools. These tools will tell you always exactly why your styling has no effect.

Ceene
12 Sep 2011, 4:53 AM
Thanks for the reply

I installed Firebug for Firefox 4 but I get no errors.

I changed the the Code to TextField.addStyleName("pflichtFelder");
But no change.
In my project.css in the following entry


.pflichtFelder {
background-color: yellow;
}


I don't know why the background of the TextField isn't yellow.

sven
12 Sep 2011, 4:57 AM
I installed Firebug for Firefox 4 but I get no errors.

Why would you expect to get errors? With Firebug you can analyse what the correct rules would be.


In your case it would be something like

.pflichtFelder .x-form-text {
background-color: yellow;
}

Please not that this is not related to GXT.
There is a background image set too, which you probably want to remove.

Ceene
12 Sep 2011, 5:12 AM
Please not that this is not related to GXT.
There is a background image set too, which you probably want to remove.

Ok if I understands you right there is a defaultName for the style in the gxt.css and this name I must override in the project.css?

sven
12 Sep 2011, 5:13 AM
Ok if I understands you right there is a defaultName for the style in the gxt.css and this name I must override in the project.css?


Not exatly. Altough there are default values, your rules gets assigned to the wrong element.

Ceene
12 Sep 2011, 5:19 AM
Sorry I don't get it (Steh gerade aufm Schlauch)
In GWT the addStyleName-Method is to override the default-CSS-Style. You can use every name you like.
If you say background-color:yellow; the background was yellow.

In my GXT-application I have a LabelField with an other StyleName and there I have no problems.

Which default-css-Names I must override that I get after die Dialog is load a yellow background?
That is all I would like to get.

sven
12 Sep 2011, 5:23 AM
This is not about GWT or GXT. This is about how CSS works.


.pflichtFelder .x-form-text { background-color: yellow;
background-image: none;
}


textField.addStyleName("pflichtFelder");

Ceene
12 Sep 2011, 5:27 AM
Oh, I'm really sorry. I have not good knowlage in CSS.
Thank for your help. Thank you very much.

I will learn more about CSS.