1 Reply Latest reply on Oct 22, 2009 6:17 AM by Anton Belevich

    url from custom .xcss file is not working for background ima

    Asfak Mahamud Newbie

      I've put button.gif in the buildpath and I've got the background image for h:commandButton

      <u:selector name="input[type='submit'], input[type='button']">
       ----------------------------------
       --------------------------------
      
       <u:style name="background-image">
       <f:resource f:key="/button.gif"/>
       </u:style>
      
       -----------------------------------
       -----------------------------------
      
      </u:selector>
      
      



      But then I tried to use url instead of <f:resource like the following way

      <f:verbatim>
       <![CDATA[
       input[type="submit"], input[type="button"] {
       background:url(../images/button.gif) no-repeat right top;
       border-color: #FF0000;
       }
       ]]>
       </f:verbatim>
      


      My .xcss file is in META-INF/skins/styles.xcss

      My application is getting border color but NOT getting the background image. My application is giving exception

      
      org.ajax4jsf.resource.ResourceNotFoundException: Resource not registered : META-INF/skins/styles.xcss/images/button.gif
       at org.ajax4jsf.resource.ResourceBuilderImpl.getResource(ResourceBuilderImpl.java:397)
       at org.ajax4jsf.resource.ResourceBuilderImpl.getResourceForKey(ResourceBuilderImpl.java:341)
       at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:152)
       at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:141)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:500)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:51)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
       at java.lang.Thread.run(Thread.java:619)
      22:33:11,559 WARN [renderkit] 'for' attribute cannot be null
      22:33:45,695 WARN [renderkit] 'for' attribute cannot be null
      22:34:35,318 ERROR [[default]] Servlet.service() for servlet default threw exception
      org.ajax4jsf.resource.ResourceNotFoundException: Resource not registered : META-INF/skins/styles.xcss/images/button.gif
       at org.ajax4jsf.resource.ResourceBuilderImpl.getResource(ResourceBuilderImpl.java:397)
       at org.ajax4jsf.resource.ResourceBuilderImpl.getResourceForKey(ResourceBuilderImpl.java:341)
       at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:152)
       at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:141)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:500)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:51)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
       at java.lang.Thread.run(Thread.java:619)
      


      I believe url will not search the image in the build path. I've kept image file all possible places both in the build path and all possible locations around styles.xcss file.

      My Question:

      Is it possible to use url from .xcss file? If it is would you please let me know how will be the file structure I should follow?

      Please let me know as soon as possible.

        • 1. Re: url from custom .xcss file is not working for background
          Anton Belevich Novice

          Hi asfak.mahamud

          suppose you are creating custom skin if so you must register your custom resource in the resource config file.

          Create next resources-config.xml file in the META-INF dir

          
          <?xml version="1.0" encoding="UTF-8"?>
          <resource-config>
           <resource>
           <name>foo.gif</name>
           <path>path/to/the/foo.gif</path>
           </resource>
          </resource-config>
          


          now you could use it in the your xcss

          <u:style name="background-image">
           <f:resource f:key="foo.gif"/>
          </u:style>