How to add external style sheets in Primefaces mobile

UI Components for JSF
Post Reply
vbose
Posts: 49
Joined: 07 Jul 2009, 00:22

26 Apr 2011, 18:44

When I add the below line above or within <p:page>, the entire page's style gets messed up especially the navigation/toolbar. What is the work around to add custom style sheets in Primefaces mobile . Also the view transitions are not very smooth if I put any css wrapped in <style></style> tags in top of the page before <pm:page> tag. .
e.g.
<link href="styles/mws.css" rel="stylesheet" type="text/css" />

I even tried the below code but has to effect at all.

Code: Select all

<pm:page title="TEST" swatch="b">
     	   <f:facet name="meta">				
				<link href="styles/mws.css" rel="stylesheet" type="text/css" />				
	  </f:facet>
</pm:page>	
I would highly appreciate any help in this regard. Thanks.
Last edited by vbose on 26 Apr 2011, 22:54, edited 1 time in total.

vbose
Posts: 49
Joined: 07 Jul 2009, 00:22

26 Apr 2011, 22:53

The issue here is PM spits the entire HTML code using the page renderer class and this makes it a little harder to add custom style sheets or any other meta tags within the head element.
I have put in a workaround for this issue by using JQuery to append the link and meta tags to the html head element. Place the script right before </f:view> tag in the page. This does not interfere with the view transitions and I am able to get the desired icon when I add the page to Home Screen as well as link the custom style sheet.

Code: Select all

<script type="text/javascript">
		jQuery(document).ready(function(){
		    jQuery('head').append('<link rel="apple-touch-icon" href="images/dmvlogo.jpg"/>');
			jQuery('head').append('<link rel="apple-touch-startup-image" href="images/splash.png"/>');			
			jQuery('head').append('<meta name="apple-mobile-web-app-capable" content="yes" />');
			jQuery('head').append('<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width"/>');
			jQuery('head').append('<link href="styles/mws.css" rel="stylesheet" type="text/css"/>');
		});
	 </script>

smallya
Posts: 264
Joined: 19 Mar 2010, 19:22
Contact:

28 Apr 2011, 03:04

I have the same issue - wondering if there is a standard extensibility capabilities at the PrimeMobile level to do a clean overlay of custom stylesheet.
Netbeans 7.2| GlassFish 3.2 | PostgreSQL 9.1| MongoDB | Primefaces 3.4.2
_______________________________________________________________
Subraya Mallya
http://tinyhabit.com |http://twitter.com/tinyhabit

vbose
Posts: 49
Joined: 07 Jul 2009, 00:22

08 May 2011, 21:42

I am not sure there is one available at this time.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

24 May 2011, 12:39

There is a facet for this;

Code: Select all

<f:facet name="postinit">
   your stuff here
</f:facet>

krutikf
Posts: 9
Joined: 15 Jun 2010, 10:45

24 May 2011, 22:32

Hi optimus.prime,

is it also the correct tag to integrate a javascript like SQLite ? ( look at http://primefaces.prime.com.tr/forum/vi ... ile#p37831 ) ?

Thanxs.

krutikf
Posts: 9
Joined: 15 Jun 2010, 10:45

26 May 2011, 18:53

Hi,

i tried successfully the tag facet for including a Javascript :mrgreen: :

<f:facet name="postinit">
<script type="text/javascript" src="js/offlinedb.js">
</script>
</f:facet>

But i want to call a function of it at the moment the view is loaded by the browser. I tried onload="initDB();" in tag view, page and nothing happens:

<pm:page title="MyPage" onload="initDB();">

If i call the function from a button everything works well. The algorithm is quiet simple. I want to initialize a SQLite Database on start to create the tables if they don't exists. The program uses the Database for logon purposes (don't worry, only to identify the user, the authentication runs secure over the server :shock: ). Every time the user uses the program i can recognize for which user i have to select the data.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 21 guests