Page rendering problem with named parameters

Splash Forums PrettyFaces Users Page rendering problem with named parameters

This topic contains 6 replies, has 2 voices, and was last updated by  Christian Kaltepoth 3 years, 4 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #19763

    Anonymous

    Hello,

    I am trying to use the named path parameters that are outlined in the prettyfaces documentation. The parameter gets passed to my page and the managed bean retrieves the value from the httprequest object. The issue is that the page rendering goes to hell. It looks like the context gets all messed up. All the links on the page are appending the url to the existing url. The css files are not loaded appropriately. The page renders fine when I don’t use named parameter. Is there something specific that I need to do to get this working correctly? I checked the logs and there are no errors in the tomcat logs.

    This is my configuration for the url:

    <url-mapping id=”admin-agent-profile”>

    <pattern value=”/admin-agent-profile/#{ id }” />

    <view-id value=”/admin/AgentProfile.xhtml” />

    </url-mapping>

    I am using Tomcat 7, JSF 2, Primefaces 3.4, Primefaces Extensions, and Prettyfaces 3.3.3.

    Thanks. Jim.

    #23479

    Do you have any other configuration in your pretty-config.xml? Could you please give an example for “All the links on the page are appending the url to the existing url”? And what do you mean with “The css files are not loaded appropriately”? Do the requests result in a 404?

    I never heard of something like this before. And it only happens for named path parameters? Not for EL ones? You could try to rename the named path parameter to “agentId” or something like this. Perhaps there is some kind of conflict regarding the name “id”.

    #23480

    Anonymous

    Hmmm…. i do have another config item in the xml that has the same named parameter, but i changed this one to agentId and it still didn’t work.

    The links appending issue is like this — if a url is something like manage-agents for a link. It becomes localhost/context/admin-agent-profile/manage-agents instead of localhost/context/manage-agents.

    The css issue is that none of the css rules are being applied. The web page layout is completely destroyed. This tells me the files are not being parsed.

    I will check for 404 errors tomorrow morning when I get in the office to see if there is an error with the files loading. This is a super strange issue. Like a said before every other page renders fine that doesn’t have named parameter.

    #23481

    Ok, please let me know if the CSS files don’t load correctly because of a 404 or something else. This could give a clue what is going on in your app.

    Could you perhaps also post your complete web.xml and pretty-config.xml?

    #23482

    Anonymous

    Looks like there are 404 errors. The same thing that is happening to the links on the page are happening to the css file references.

    The url for the css file is coming up as http://localhost:8084/Agents/admin-agent-profile/css/default.css

    The admin-agent-profile part of the link is the url mapping in the prettyfaces config. It shouldn’t be in the url of the css file.

    The snippet for my css file in the facelets template page is like this:

    <link href="css/default.css" rel="stylesheet" media="screen" type="text/css" />

    Again, this has worked up till now with the named parameter.

    Web.xml:

    <web-app version="3.0" 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-app_3_0.xsd">
    <context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Production</param-value>
    </context-param>
    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
    <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>
    30
    </session-timeout>
    </session-config>
    <welcome-file-list>
    <welcome-file>Index.xhtml</welcome-file>
    </welcome-file-list>
    <login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
    <form-login-page>/Login.xhtml</form-login-page>
    <form-error-page>/Error.xhtml</form-error-page>
    </form-login-config>
    </login-config>
    <resource-ref>
    <res-ref-name>jdbc/UCPPool</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    </web-app>

    pretty-config.xml:

    http://dl.dropbox.com/u/4179337/pretty-config.xml

    #23483

    Anonymous

    I went back to my templates and changed the urls for the css files and all links to include this prefixed:

    #{request.contextPath}/

    My guess is that there is some kind of internal processing with the urls that contain parameters that alters any existing url paths. I guess that processing doesn’t occur when it is a straight redirect. This change fixes my problem, but I wish I had the real reason why the urls broke with the named parameters. For my own knowledge and insight. I think it is more of my ignorance on understanding the mechanics of prettyfaces.

    #23484

    I think the reason that your CSS files didn’t load is caused by the fact that you are using relative paths for loading the css:

    <link href="css/default.css" rel="stylesheet" media="screen" type="text/css" />

    For the browser this means that the file has to be downloaded relative to the “current directory”. With your mapping, If you request an URL like this:

    http://localhost/mycontextpath/admin-agent-profile/23

    The “current directory” is:

    http://localhost/mycontextpath/admin-agent-profile/

    So the browser will request:

    http://localhost/mycontextpath/admin-agent-profile/css/default.css

    Which won’t work of cause. Therefore you should always use absolute paths like this:

    <link href="#{request.contextPath}/css/default.css" rel="stylesheet" media="screen" type="text/css" />

    I hope this clears up the situation. :)

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

Comments are closed.