terça-feira, 15 de novembro de 2011

GWT - Background Image no CSS utilizando UIBinder e ImageResource

Em meu projeto GWT tenho imagens e css utilizando um ClientBundle.

Perdi algum tempo fazendo pesquisas para inseir uma imagem de fundo através do arquivo de CSS.

Cconhecimento aprendido é conhecimento compartilhado!

O link abaixo foi muito útil:

http://stackoverflow.com/questions/4535094/how-do-i-use-image-sprites-in-gwt


Trechos do meu código:

Arquivo de Recursos
----------------------------------------------------------------------------------------------
 public interface Resources extends ClientBundle{
     public static final Resources INSTANCE = GWT.create(Resource.class);

    @Source("br/com/inaciojr9/client/resources/circuito1.png")
     @ImageOptions(repeatStyle=RepeatStyle.Both)
     ImageResource circuito1();

    @Source("br/com/inaciojr9/client/resources/GlobalStyles.css")
     @CssResource.NotStrict
     GlobalStylesheet css();
}
----------------------------------------------------------------------------------------------

Arquivo GlobalStyles.css
----------------------------------------------------------------------------------------------
@sprite .painelRegistro{
     background-color: #FFFFFF;
     color: #660066;
     border-color: #660066;
     border-style: dotted;
     border-width: 1px;
     padding: 1px;
     margin: 3px;
     border-collapse: collapse;
     font-family: tahoma;
     font-size: 11px;
     gwt-image: "circuito1";
     height: auto;
     width: auto;
}
 ----------------------------------------------------------------------------------------------

Arquivo UIBinder
-----------------------------------------------------------------------------------------------
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
     <ui:with field='res' type='br.com.inaciojr9.client.resources.Resources' />

     <g:HTMLPanel styleName="{res.css.painelRegistro}">
         <g:Label ui:field="loginTitle">REGISTRO</g:Label>
     </g:HTMLPanel>
</ui:UiBinder>
-----------------------------------------------------------------------------------------------

Espero ter ajudado!

Nenhum comentário:

Postar um comentário