Domanda

I have little issue with CssResource in GWT. I want to change styles of AbsolutePanel and label, but it doestnt run. When I add style class with setStyleName method, nothing is happend.

In this snippet of code I use a resource :

public CustommerView() {
        MyResource cssResource = GWT.create(MyResource.class);
        MyCss myCss = cssResource.css();

        AbsolutePanel basePanel = new AbsolutePanel();

        initWidget(basePanel);
        basePanel.setStyleName(myCss.rootPanel());


        Label label = new Label();
        label.setText("Im label");
        label.setStyleName(myCss.label());
        basePanel.add(label);

    }

This is my interface which extends CssResource:

public interface MyCss extends CssResource {
    /**
     * Method for return command button class name
     * @return command button class name
     */
     public String rootPanel();

     public String label();
}

This is my css file, which is next to MyCss interface on filesystem :

.rootPanel {
   position:absolute !important; 
   top:0px;
   left:0px;
   background-color:yellow !important;
   height: 20px !important;
   width: 18px !important;  
}

.label {
  color:red;    
}

Custommer view is GWT Composite. When I want to move on view, i call simply RootPanel.get("mainArea").add(view.asWidget) in presenter. mainArea is div element.

When I pasted css class in css file in web inf, everything run ok. Can someone give me the point how to solve this issue? Thanks.

È stato utile?

Soluzione

The ensureInjected() call is missing.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top