Skip to main content

Problem loading Faces js libraries in Firefox

4 replies [Last post]
napartar
Offline
Joined: 2012-02-16
Points: 0

Hello everybody,

I have a problem with my JSF based web application. I have a login page which access to the application general site. My problem is that even in general site I can use RichFaces components, that's no possible in loggin page, because JSF and Rich javascript libraries are not loaded, they appear in red with 404 not found error in Firebug. However, when I'm inside the application, I have the same libraries with 304 not modified status. My login page follows this composition:

<?xml version='1.0' encoding='ISO-8859-15' ?>

<ui:composition xmlns="http://www.w3.org/1999/xhtml"

xmlns:h="http://java.sun.com/jsf/html"

xmlns:f="http://java.sun.com/jsf/core"

xmlns:ui="http://java.sun.com/jsf/facelets"

xmlns:a4j="http://richfaces.org/a4j"

xmlns:rich="http://richfaces.org/rich">

<f:view>

<h:head>

...

I don't know exactly where the error is, because the page format looks to be well done. Libraries which are appearing red-highlighted are

javax.faces.resource/jquery.js.jsf

javax.faces.resource/richfaces.js.jsf

javax.faces.resource/richfaces-base-component.js.jsf

javax.faces.resource/richfaces-event.js.jsf

javax.faces.resource/message.js.jsf?ln=org.richfaces

.........

Anybody knows what can be happening?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
gubaojian
Offline
Joined: 2011-07-30
Points: 0

You can use getServletPath() method in HttpServletRequest to get the request path in the login filter. if the request path start with the prefix " /javax.faces.resource" , don't check the request or redirect it to login page, just pass the request. because JSF resources file always start with the prefix of " /javax.faces.resource".

napartar
Offline
Joined: 2012-02-16
Points: 0

Hello gubaojian, thanks for responding:

Don't know how to do your method, considering JSF is internally managing every single request, I don't know where can I check for current HttpServletRequest...

My faces-navigation.xml file looks like this, I don't know if this can be the source of the problem...

<?xml version="1.0"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<description>
</description>
<from-outcome>home</from-outcome>
<to-view-id>/login.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<description>
</description>
<from-outcome>success</from-outcome>
<to-view-id>/general2.xhtml</to-view-id>
</navigation-case>
</navigation-rule>

<navigation-rule>
<from-view-id>/login.xhtml</from-view-id>
<navigation-case>
<description>
</description>
<from-outcome>success</from-outcome>
<to-view-id>/general2.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<description>
</description>
<from-outcome>retry</from-outcome>
<to-view-id>/login.xhtml</to-view-id>
</navigation-case>
</navigation-rule>

...

I have tried dozens of options, changing Maven imported libraries and XHTML tags, but everything seems to be like at the beginning :-(

gubaojian
Offline
Joined: 2011-07-30
Points: 0

you can use

FacesContext context = FacesContext.getCurrentInstance();

ExternalContext elc = context.getExternalContext();

HttpServletRequest req = (HttpServletRequest)elc.getRequest();

then you get the HttpServletRequest object and you can do operate on it , you can see jsf api to get more info about it.

but it's not recommended to do permission on like you code style.

checking permission offen happens in a servlet Filter or user a security framework like spring security.

please see servler api or google to get more detail about it.

napartar
Offline
Joined: 2012-02-16
Points: 0

Yes, in fact it was filter problem, which was discarding library requests.

Thanks a lot!