• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it possible to map URL's with independent view dir structure?  RSS feed

 
Peter Noordzij
Greenhorn
Posts: 28
Java jQuery Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to map URL's with independent view dir structure?
If so how?

My goal is to simply point an url to a specific view file:
i.e.

to

and

to


A couple solutions I found so far where:

Solution 1

PrettyFaces
I just didn't wanted to use a third party solution.
This is my best solution so far.

Solution 2(a JSF solution):

navigation rule entries in the faces-config.xml file.

A bean is required, not a bad thing in above example but not great in combination with static navigation like:

Solution 3 (another JSF solution)

Resource Library Contracts
This forces me to work in the contracts file.


None of the solutions gave me a clear solution except prettyfaces.

Are there some elegant native JSF solutions ?
Something flexible and reusable? Something like a mvc controller i used to use in php applications. In this controller I was able to add a template file in the constructor and an content file in specific function. Custom paths where no problem.
I didn't want to use mvc nor the php language in this project.

Maybe I should go completely custom. But I just wanted to ask if there was something out of the box for this.
I'm still studying Java EE and jsf a lot, forgive me for asking a noob question. :)

Thanks a lot!
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PrettyFaces is a lightweight easy-to-use way of making "logical URLs" and bookmarkable URLs. While JSF2 added features that can make JSF URLs bookmarkable, I can't recall much it did to support the concept of abstract (logical) URLs.

Installation of PrettyFaces requires only a small amount of effort, and in modern-day versions, you can define the URL maps right on your backing beans using annotations.

I use it for almost all my JSF projects. I really don't know of anything I'd rather use.
 
Peter Noordzij
Greenhorn
Posts: 28
Java jQuery Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed pretty faces was the best option. I've started using it as well.
Till so far i can't mention anything bad about it.
I like it!
Actually shouldn't PF not be a part of JSF in the first place?

Thanks a lot.



 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PF was independently developed by Lincoln Baxter, who these days works for Red Hat/JBoss. He's been known to show up here occasionally.

I wouldn't mind it being part of core JSD, but to get it into JSF itself would probably require getting it into the JCP process and they'd probably "improve" and mangle it, as committees often do. So perhaps we're better off as it is. And, of course, if an app doesn't need it, that means that there's no deadwood if you don't include it.
 
Peter Noordzij
Greenhorn
Posts: 28
Java jQuery Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to PF I'm finally getting my custom "design" working (mostly).

Trying to use all benefits from JSF using for example contracts, composite components and resources. It still wasn't enough for this project, for a specific purpose i still also needed an extra custom "layout" folder for custom reusable layout parts.
Now in this custom layout folder I had an xhtml file with a matching css file.
But JSF wouldn't let me use an old-fashioned relative path:

Neither JSF's way of doing stuff was helping.

Maybe I need to use a JAR file instead of my original "Layout folder"?
Or this is becuase I'm not in JSF's resources folder, right?

I wasn't going to use:

Am I right in thinking that JSF wouldn't let me think outside the JSF box at all? Using third party PF and still not being able to apply my custom design?
Should I have picked Servlets and JSP for my custom http needs?

At least with:
I can move on.

Thanks :D





 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The technical term for custom "layout" is "skin" and skinning is a very big thing in JSF. In fact, a lot of the third-party JSF tagsets come with a set of skins pre-defined plus mechanisms for making your own.

A "link" raw html tag isn't the recommended way to handle skins in JSF2, however. There's an actual JSF2 tag for that. It's h:outputStylesheet. It works in conjunction with a standardized resource structure within the WAR.
 
Peter Noordzij
Greenhorn
Posts: 28
Java jQuery Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Allright.
The thing is that I wanted to keep the resources folder for my composite components.
I guess I would have to repend.
I'll use h:outputStylesheet.
Do you know such a third party tagset?
 
Peter Noordzij
Greenhorn
Posts: 28
Java jQuery Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it working the way I want to.
I am satisfied. I got the reusable css in the resources folder in the css library with different "sub" libraries.

The specific css is in the library contracts. So double swappable :)
Weird design perhaps but conveniant for me.

Thanks again!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!