[OmniFaces utilities] The
getResource()
method returns a URL for an application resource mapped to the specified path, if it exists; otherwise, return null
.Method:
See also: Faces#getContext()
Usage:
import
org.omnifaces.util.Faces;
import
java.net.URL;
...
try {
// e.g. file:/D:/wildfly/standalone/deployments/MyApp.war/resources/default/images/rafa.jpg
URL url =
Faces.getResource("/resources/default/images/rafa.jpg");
} catch
(MalformedURLException ex) {
Logger.getLogger(LoginBean.class.getName()).log(Level.SEVERE, null, ex);
}
Niciun comentariu :
Trimiteți un comentariu