tags:

views:

85

answers:

1

hi all. i am new to primeface.

i have tried to test an example of primefaces about tag as in its documentation,

this is my jsf page code:

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://primefaces.prime.com.tr/ui" prefix="p"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

 <head>

  <base href="<%=basePath%>">

  <title>My JSP 'index.jsp' starting page</title>
 </head>

 <body>
  <f:view>
   <h:form>
    <h:outputText id="txt_count" value="#{counterBean.count}" />
    <p:poll actionListener="#{counterBean.increment}" update="txt_count" />
   </h:form>
  </f:view>
 </body>


</html>

and this is my backbean code: [code]

import javax.faces.event.ActionEvent;


public class CounterBean {
private int count;
public void increment(ActionEvent actionEvent) {
count++;
}
//getters and setters
public int getCount() {
 return count;
}
public void setCount(int count) {
 this.count = count;
}
}

but when i tried to running it. i got this error:

java.lang.IllegalStateException: Component javax.faces.component.UIViewRoot@ed32c4 not expected type.  Expected: javax.faces.component.UIForm.  Perhaps you're missing a tag?
 com.sun.faces.taglib.html_basic.FormTag.setProperties(FormTag.java:199)
 javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:586)
 javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1070)
 com.sun.faces.taglib.html_basic.FormTag.doStartTag(FormTag.java:273)
 org.apache.jsp.index_jsp._jspx_meth_h_005fform_005f0(index_jsp.java:120)
 org.apache.jsp.index_jsp._jspService(index_jsp.java:93)
 org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
 com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:428)
 com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:444)
 com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:116)
 com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
 com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
 com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
 javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)

what is wrong? how can i solve it? i am using tomcat 6 thanks in advance

+1  A: 
java.lang.IllegalStateException: 
  Component javax.faces.component.UIViewRoot@ed32c4 not expected type. 
  Expected: javax.faces.component.UIForm. Perhaps you're missing a tag? 

The exception suggests that you've a h:form somewhere in the page which is not been placed inside a f:view.

Since your code example looks fine (apart from the ugly scriptlets), you're likely not running the code you think you're running. Redo the build and deployment and check if you did everything correctly.

BalusC
thanks for your reply it has been fixed. but i have another problemwhen my pages is loaded it says that "yahoo is not defined" and it does not work. i have defined resources servlet and <p:resources> but it does not work yet!
arash
That's a new question. You need to post a new question. Don't forget to mark this answer accepted. Also see http://stackoverflow.com/faq (and don't forget to accept some of previous answers as well whenever applicable: http://stackoverflow.com/users/332289/arash)
BalusC