English 中文(简体)
problem with primefaces library (jsf)
原标题:

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

最佳回答
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.

问题回答

They changed the uri in version 3. Use: http://primefaces.org/ui





相关问题
JSF a4j:support with h:selectManyCheckbox

I m having trouble with a JSF selectManyCheckbox and A4J support. The purpose is to run some action when a checkbox is selected. This works perfectly in Firefox. Yet, when testing in any IE (ie6 / ie7 ...

Mojarra for JSF Encoding

Can anyone teach me how to use mojarra to encode my JSF files. I downloaded mojarra and expected some kind of jar but what i had downloaded was a folder of files i don t know what to do with

如何拦截要求终止?

在共同基金中,如果用户要求终止,就需要采取一些行动。 我需要某种拦截器,但我不知道如何这样做。 我需要帮助。 增 编

ICEFaces inputFile getting the file content without upload

Is there any way of just getting the content of the browsed file without any upload/file transfer operations? I currently use ICEFaces inputFile component but I do not need the default uploading ...

Weird behaviour of h:commandLink action (MethodExpression)

I have two JSPs where I am displaying some info from database in a h:dataTable. One of them is showing all the info, and one of them user specifically. I have showXML.jsp that shows the "XML" column ...

How to correctly use ResultSet with h:dataTable

The problem is, that after displaying the ResultSet with <h:dataTable>, the connection is left open. If I close it, it closes the ResultSet too. I m thinking about copying the ResultSet data ...

热门标签