jsf 2 - jsf2 template and adding style sheet -
trying utilize jsf2 templates feature.the base.xhtml page looks below
<?xml version="1.0" encoding="utf-8"?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" > <h:head> <h:outputstylesheet name="test.css" library="style" target="head"/> </h:head> <h:body> <div id="page"> <div id="header"> <ui:insert name="header" > <ui:include src="/layout/header.xhtml" /> </ui:insert> </div> <div id="content"> <ui:insert name="content" > ??? </ui:insert> </div> <div id="footer"> <ui:insert name="footer" > <ui:include src="/layout/footer.xhtml" /> </ui:insert> </div> </div> </h:body> </html>
trying inherit template page (testpage.xhtml)
<?xml version="1.0" encoding="utf-8"?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" > <h:body> <ui:composition template="/layout/base.xhtml"> <ui:define name="content"> default page content!!!! <h:outputtext value="foo bar" style="green"/> </ui:define> </ui:composition> </h:body> </html>
the test.css file available under folder webcontent/resources/style , content of css file follows
.green{ color:#0000ff; }
now problem when seek run testpage stylesheet adding page (with view source able identify) not reflecting in ui.
is wrong in above code? help on appreciated.
you should utilize styleclass
attribute (equivalent class
attribute of plain html)
replace
<h:outputtext value="foo bar" style="green"/>
with
<h:outputtext value="foo bar" styleclass="green"/>
jsf-2
No comments:
Post a Comment