Resource Servlet

UI Components for JSF
rabeetkamran
Posts: 11
Joined: 30 Mar 2010, 08:58

30 Mar 2010, 10:06

Hi, any body tell me how can we load ResouceServlet and use in primeface with jsf-2.0 with complete example ,
i have done all the things that i fond on net but they didn't covert it with example here is my web.xml

Code: Select all

<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
 <context-param>   
 <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
 <param-value>server</param-value>
 </context-param>
   <context-param>
  <param-name>javax.faces.CONFIG_FILES</param-name>
  <param-value>/WEB-INF/faces-config.xml</param-value>
 </context-param>
 <listener>
  <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
 </listener>
    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>

<servlet>
 <servlet-name>Faces Servlet</servlet-name>
 <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
 <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
 <servlet-name>Faces Servlet</servlet-name>
 <url-pattern>/faces/*</url-pattern>
 </servlet-mapping>

 <!-- Configuration part for the Primefaces-->

 <servlet>
 <servlet-name>Resource Servlet</servlet-name>
 <servlet-class>
 org.primefaces.resource.ResourceServlet
 </servlet-class>
  <load-on-startup>2</load-on-startup>
 </servlet>
 <servlet-mapping>
 <servlet-name>Resource Servlet</servlet-name>
 <url-pattern>/primefaces_resources/*</url-pattern>
 </servlet-mapping>

 <!-- End of the configuration part for the Primefaces-->

<session-config>
 <session-timeout>
 30
 </session-timeout>
 </session-config>
 <welcome-file-list>
 <welcome-file>faces/welcomeJSF.jsp</welcome-file>
 </welcome-file-list>
</web-app>
and here is my login.jsp

Code: Select all

<%-- 
    Document   : Login
    Created on : Dec 3, 2009, 11:37:28 AM  
    Author     : Christopher Lam
--%>
   
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib prefix="p" uri="http://primefaces.prime.com.tr/ui" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<f:view>
    <html>
         <body>
            <center><br><br><br>
    
            <h2><h:outputText value="Please Login"/></h2>
            <form action="j_security_check">
            <p:panel header="Login Window" footer="Visca el Barca!">
                <h:panelGrid columns="2" bgcolor="#eff5fa" cellspacing="5" frame="box">
                <h:outputLabel value="User ID:"/>
                <h:inputText id="j_username" tabindex="1" />
                <h:outputLabel value="Password:"/>
                <h:inputSecret id="j_password"/>
                <h:outputLabel value=""/>
                <h:commandButton id="login" value="Login"/>
            </h:panelGrid>
                 </p:panel>
                 
<p:breadCrumb preview="true">
<p:menuitem label="Categories" url="#" />
<p:menuitem label="Sports" url="#" />
<p:menuitem label="Football" url="#" />
<p:menuitem label="Countries" url="#" />
<p:menuitem label="Spain" url="#" />
<p:menuitem label="F.C. Barcelona" url="#" />
<p:menuitem label="Squad" url="#" />
<p:menuitem label="Lionel Messi" url="#" />
</p:breadCrumb>

                 
            </form>
            </center>
        </body>
    </html>
</f:view>
<%
    session = request.getSession(true); //Force to create a new session
%>
i heave read that no need to insert <p:resources/> in jsf 2.0
in my above code there is no error
but i am not able to achieve characteristic of primefaces
when i run application just behave normally there is no effect of css or js for event

rosemeyer2
Posts: 55
Joined: 05 Oct 2009, 16:04

30 Mar 2010, 10:27

Even though you don't need to add <p:resources/>, you still have to include a <h:head /> (if head should be empty) in front of body tag.
Primefaces 2.0.2 - Mojarra 2.0.2 - Windows XP SP3 - IE 8 / Firefox 3.6

rabeetkamran
Posts: 11
Joined: 30 Mar 2010, 08:58

30 Mar 2010, 12:23

rosemeyer2 wrote:Even though you don't need to add <p:resources/>, you still have to include a <h:head /> (if head should be empty) in front of body tag.
thanks to your quick reply but i have already try to use it in my index.xhtml file but there is no response

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

30 Mar 2010, 12:26

See the updated getting started section for detailed information.

http://www.primefaces.org/gettingStarted.html

rabeetkamran
Posts: 11
Joined: 30 Mar 2010, 08:58

30 Mar 2010, 12:30

i have seen but what should i do , i have already checked it out and try to apply but there is no response it gives the script error on internet explorer but doesn't show any error on fire fox. i am using firefox3.0

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

30 Mar 2010, 15:51

So what is the script error?

rabeetkamran
Posts: 11
Joined: 30 Mar 2010, 08:58

31 Mar 2010, 07:35

Error :'PrimeFaces' is undefined
i couldn't understand what 's wrong in code while everything is perfect
i have also seen you reply about the above error that you have posted before but there were no change
could you please send me a complete a simple example using primefaces 2.0 with jsf 2.0

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

31 Mar 2010, 13:44

What is the rendered html output in head section?

rabeetkamran
Posts: 11
Joined: 30 Mar 2010, 08:58

01 Apr 2010, 07:00

hi cagatay.civici,
when i see the error console show the error (jQuery is not defined ) as i click on it to show the detail as following
here the complete detail code that is displaying on Error console on firefox
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<script type="text/javascript" src="/PrimeFacesTest/primefaces_resource/2.0.0/yui/utilities/utilities.js"></script>


<link rel="stylesheet" type="text/css" href="/PrimeFacesTest/primefaces_resource/2.0.0/primefaces/layout/layout.css" />


<script type="text/javascript" src="/PrimeFacesTest/primefaces_resource/2.0.0/jquery/jquery.js"></script>


<script type="text/javascript" src="/PrimeFacesTest/primefaces_resource/2.0.0/jquery/plugins/layout/jquery.layout.min.js"></script>

<script type="text/javascript" src="/PrimeFacesTest/primefaces_resource/2.0.0/jquery/plugins/ui/jquery.ui.custom.js"></script>


<script type="text/javascript" src="/PrimeFacesTest/primefaces_resource/2.0.0/primefaces/core/core.js"></script>


<script type="text/javascript" src="/PrimeFacesTest/primefaces_resource/2.0.0/primefaces/layout/layout.js"></script>


<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="style.css" rel="stylesheet" type="text/css" />

<title>greeting page</title></head>
<body>
<p><script type="text/javascript">jQuery(document).ready(function() {
j_idt7_widget = new PrimeFaces.widget.Layout('j_idt7', {west: {paneSelector:'#j_idt8',size:100},center: {paneSelector:'#j_idt10'}});});
</script><div id="j_idt7" style="width:400px;height:200px;"><div id="j_idt8">Left Pane</div><div id="j_idt10">Right Pane</div></div>
</p>
</body>
</html>

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

01 Apr 2010, 10:07

Files seem to be included what happens when you try to access;

Code: Select all

http://localhost:8080/PrimeFacesTest/primefaces_resource/2.0.0/primefaces/core/core.js
Assuming your port is 8080

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 44 guests