0

I have been using pretty faces for urls without issue until i started using mapped URLs feature (Section 3.6). http://ocpsoft.org/docs/prettyfaces/3.3.3/en-US/html/Configuration.html#config.actions

I'm getting the output and the actions i want to happen working fine. The problem though is i can't get to to any of my assets under assets folder. i'm getting a 404. The weird thing is that for every other config there hasn't been a problem. And isn't a problem when I run them together. The app is using a template so the links to css's, js's, etc.. are exactly the same. When I go to a plain ol' (e.g. /home) mapping they work fine, go to the other page with the action, they don't work. The template rendering does though. In fact the parameter injection and the action work as well.

PRETTY CONFIG:

<url-mapping id="home"> <!-- assets work -->
    <pattern value="/home" />
    <view-id value="/home.jsf" />
</url-mapping>
<url-mapping id="validate-token"> <!-- assets don't work -->
  <pattern value="/validate-token/type/#{id:validateByTokenController.tokenType}/token/#{validateByTokenController.token}" />
  <view-id value="/validate-token.jsf" />
  <action>#{validateByTokenController.init}</action>
</url-mapping>

BEAN:

@RequestScoped
@Named
public class ValidateByTokenController {

private String tokenType;

private String token;

public void init() {
    token = "J" + token;
    tokenType = "J" + tokenType;
}

XHTML SAMPLE CSS LINKS: (same links for "home" config, but not for "validate-token")

<link rel="stylesheet"
    href="assets/plugins/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="assets/css/style.css" />

Thanks in advance.

Steve Holt
  • 85
  • 9

1 Answers1

2

The problem is that you are using relative URLs for your CSS files.

With an URL like /validate-token/type/foo/token/bar the browser thinks that /validate-token/type/foo/token/ is the current directory. So he tries to load the CSS file from /validate-token/type/foo/token/assets/css/style.css.

Try using absolute URLs for your CSS instead:

<link rel="stylesheet" href="#{request.contextPath}/assets/css/style.css" />
chkal
  • 5,598
  • 21
  • 26
  • makes sense, and it worked, i'm just not clear on why adding the "action" in the url-mapping for prettyfaces made it not work, and the rest still worked. either way thanks for the tip! – Steve Holt Jun 10 '14 at 00:01