my dog learned polymorphism
The moose likes JSF and the fly likes Control Position of Resources within <h:head> in JSF 2.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Control Position of Resources within <h:head> in JSF 2.0" Watch "Control Position of Resources within <h:head> in JSF 2.0" New topic
Author

Control Position of Resources within <h:head> in JSF 2.0

David Sawyer
Greenhorn

Joined: May 19, 2010
Posts: 14
Is there a way to control the location where resources are placed within <head></head> ?

I've noticed that most component libraries include css or js resources and that in the html output they appear at the very beginning of <head>. Ideally I would like them to appear at the very end right before </head> so that my title and meta elements are all above them. Any simple way to accomplish this?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14491
    
    7

It's a difference that makes no difference, unless you're into opening up web page source and admiring the results. HTML itself won't care.

I'm not actually sure what, if any mods to the HTML head section JSF2 does. In earlier versions of some of the extended frameworks, there were several pre-defined points that could be used to arrange things so that they would produce stuff in the proper order. Mostly, this applies to ensuring that the relative precedences of CSS and JavaScript elements didn't get scrambled. However at the app developer level, the precise location wasn't being controlled, only the context.


Customer surveys are for companies who didn't pay proper attention to begin with.
David Sawyer
Greenhorn

Joined: May 19, 2010
Posts: 14
I work for a company that spends lots of money on SEO advice and those guys are very picky about the title element and supporting meta elements being the first children of <head>.

In 1.2 it was easy enough to control the position of items in the markup. I totally respect and enjoy the modular nature of JSF 2.0 and the ability of components to easily include their supporting resources, but it would be nice if you could specify the location within <h:head> for resources to be included.
David Sawyer
Greenhorn

Joined: May 19, 2010
Posts: 14
The SEO guys reviewed the site and are insisting that the js and css resources included by Openfaces and Richfaces be moved below the title and meta elements.

Does anyone else have any insight on how this can be accomplished (outside of a filter which would be horribly inefficient)?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14491
    
    7

Who ARE these guys? Dogbert & Ratbert, LLC? I can't believe that any search engine of note would blindly assume the ordering of non-ordered elements.
David Sawyer
Greenhorn

Joined: May 19, 2010
Posts: 14
lol. yeah. it's tough. They argue that having these elements appear within the first X characters is important to some off-broadway non-Google search engines. They assume we're working w/ PHP or something and can't really appreciate the benefits of a component based paradigm.

Tim, do you happen to know where I could look in majarra to see how resources are introduced in the head. It seems like extension/decoration of this mechanism to change the position within the element shouldn't be terribly difficult.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14491
    
    7

David Sawyer wrote:

Tim, do you happen to know where I could look in majarra to see how resources are introduced in the head. It seems like extension/decoration of this mechanism to change the position within the element shouldn't be terribly difficult.


I don't remember offhand. Only time I did anything like that in detail was using the MyFaces stuff prior to JSF2, where I was injecting Google Maps support JavaScript at the page header/footer. However it wouldn't have been trivial. What they did was provide a collection of named markers and then you injected stuff into them on a FIFO basis. The page renderer would decant the code for each marker in turn when it was darn good and ready to, and the only absolute guarantees as to position was that everything would be located in an appropriate place. No micro-managing.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Control Position of Resources within <h:head> in JSF 2.0
 
Similar Threads
The State Machine
Problem validating form with jQuery validation plugin
unable to redirect to google.com using RequestDispatcher
Running Multiple Java Programs
Singleton Pattern