1. #1
    Ext GWT Premium Member
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    30
    Vote Rating
    0
    Ceene is on a distinguished road

      0  

    Question Answered: TextField.setStyleName("pflichtFelder") has no effect

    Answered: TextField.setStyleName("pflichtFelder") has no effect


    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

  2. This is not about GWT or GXT. This is about how CSS works.

    Code:
    .pflichtFelder .x-form-text {    background-color: yellow; 
    background-image: none;
    }
    Code:
    textField.addStyleName("pflichtFelder");

  3. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,691
    Vote Rating
    107
    Answers
    60
    sven is just really nice sven is just really nice sven is just really nice sven is just really nice

      0  

    Default


    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.

  4. #3
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,691
    Vote Rating
    107
    Answers
    60
    sven is just really nice sven is just really nice sven is just really nice sven is just really nice

      0  

    Default


    I always suggest to use Firebug or IE Developer Tools. These tools will tell you always exactly why your styling has no effect.

  5. #4
    Ext GWT Premium Member
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    30
    Vote Rating
    0
    Ceene is on a distinguished road

      0  

    Default


    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
    Code:
    .pflichtFelder {
        background-color: yellow;
    }
    I don't know why the background of the TextField isn't yellow.

  6. #5
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,691
    Vote Rating
    107
    Answers
    60
    sven is just really nice sven is just really nice sven is just really nice sven is just really nice

      0  

    Default


    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
    Code:
    .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.

  7. #6
    Ext GWT Premium Member
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    30
    Vote Rating
    0
    Ceene is on a distinguished road

      0  

    Default


    Quote Originally Posted by sven View Post
    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?

  8. #7
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,691
    Vote Rating
    107
    Answers
    60
    sven is just really nice sven is just really nice sven is just really nice sven is just really nice

      0  

    Default


    Quote Originally Posted by Ceene View Post
    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.

  9. #8
    Ext GWT Premium Member
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    30
    Vote Rating
    0
    Ceene is on a distinguished road

      0  

    Default


    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.

  10. #9
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,691
    Vote Rating
    107
    Answers
    60
    sven is just really nice sven is just really nice sven is just really nice sven is just really nice

      0  

    Default


    This is not about GWT or GXT. This is about how CSS works.

    Code:
    .pflichtFelder .x-form-text {    background-color: yellow; 
    background-image: none;
    }
    Code:
    textField.addStyleName("pflichtFelder");

  11. #10
    Ext GWT Premium Member
    Join Date
    Aug 2011
    Location
    Germany
    Posts
    30
    Vote Rating
    0
    Ceene is on a distinguished road

      0  

    Default


    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.