I have a project in netbeans that works perfectly. But, I load .war in my glassfish standalone 4.1 (This version is the same as netbeans version)
I make the default .war from netbeans (clean and build)
In the project deployed in GFish StandAlone it does not show neither photos nor the elements inside the main components. Also, the primefaces theme doesn't load the CSS
Sample of the use of images and css in the .xhtml
<h:head>
<h:outputStylesheet library="resources" name="css/login.css"/>
<style type="text/css">
body{
background-image: url("resources/images/fondoBlanco.jpg");
background-size: cover;
background-repeat: no-repeat;
background-attachment:fixed;
}
</style>
</h:head>
Sample button images
<p:commandLink action="#{loginBean.sessGmail()}" ajax="true" type="submit" >
<h:graphicImage library="resources" name="images/iconGmailBlack.png" style="width: 150px; height: 150px; "/>
<f:param name="idParamtro" value="#{loginBean.userLog}" />
</p:commandLink>
All help is appreciated
If it works in GF/Netbeans, it will work with the "standalone" GF unless it has a configured
datasource,connectionpool, Realm
, if that is the case, you have to configure it manually since there are times whenglassfish-resources.xml
it is not taken into account. (a bit absurd but it happens). But if this is the case you should get some kind ofStackTrace
. You can checkserver log
to see what's going on since you're not using Netbeans, so you have no way to see the "console". you can find the server log at:in my case:
Most likely, this file will clarify why it is not working as it should, but I don't think it has much to do with the deployment descriptor
web.xml
since it is configured by netbeans when creating a web project.If you modified it, make sure you have at least the following configuration, otherwise the pages will not be able to be interpreted by the browser:
EDITION
JSF helps us load external resources dynamically through the resource handler .
This works as follows:
With this structure:
If we want to call a resource
CSS|Javascript
we use:either
There is no need to explicitly call the folder
resources
The same goes for javascript:
either
Ok, now what about
Primefaces
JSF components<h:...
.To call an image resource located in
resources/
you have to use the attributename
either
The attribute
value
is for binary information.To call resources from a file
css|js
, use the resource bundle: