求一个primefaces中p:commandButton组件无法以ajax方式调用bean的问题。
xhtml页面如下:<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
<title>welcome!</title>
</h:head>
<h:body>
<f:view>
<h:form prependId="false">
<p:panel>
<h:panelGrid>
<h:outputText value="search by course name:" />
<p:inputText value="#{paginateBean.cName}" />
<p:commandButton value="Search" process="@form" update="ot" actionListener="#{paginateBean.searchCourse}" />
</h:panelGrid>
</p:panel>
</h:form>
<h:outputText id="ot" value="#{paginateBean.cName}" />
</f:view>
</h:body>
</html>
bean中调用的方法:public String searchCourse(ActionEvent actionEvent){
System.out.println("do search course!" + "courseName:" + cName);
return null;
}
此处p:commandButton无法正常执行Ajax操作,不使用Ajax是可以的,我想知道这其中的原理。补充:
若去掉<h:head></h:head>,p:commandButton是可以执行Ajax操作了,但是primefaces的主题就没有了,button变成普通的button了。
或者改成<head></head>,也可以执行,但有错误信息:
一个或多个资源具有 'head' 的目标,但视图中却未定义 'head' 组件。 这又是啥情况?求高手指点一二。
xhtml页面如下:<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
<title>welcome!</title>
</h:head>
<h:body>
<f:view>
<h:form prependId="false">
<p:panel>
<h:panelGrid>
<h:outputText value="search by course name:" />
<p:inputText value="#{paginateBean.cName}" />
<p:commandButton value="Search" process="@form" update="ot" actionListener="#{paginateBean.searchCourse}" />
</h:panelGrid>
</p:panel>
</h:form>
<h:outputText id="ot" value="#{paginateBean.cName}" />
</f:view>
</h:body>
</html>
bean中调用的方法:public String searchCourse(ActionEvent actionEvent){
System.out.println("do search course!" + "courseName:" + cName);
return null;
}
此处p:commandButton无法正常执行Ajax操作,不使用Ajax是可以的,我想知道这其中的原理。补充:
若去掉<h:head></h:head>,p:commandButton是可以执行Ajax操作了,但是primefaces的主题就没有了,button变成普通的button了。
或者改成<head></head>,也可以执行,但有错误信息:
一个或多个资源具有 'head' 的目标,但视图中却未定义 'head' 组件。 这又是啥情况?求高手指点一二。
解决方案 »
- 三天了ocx 不能这样了 如何给ocx传 java对象的地址 在想等
- struts2 页面问题求助高手
- 利用DIV如何实现一个页面动态包含多个页面?
- struts2中重复提交问题
- struts标签<html:messages>当中的name属性问题
- 运行时老是错误
- 读取XML文件,并将数据导人到数据库---用哪种技术好?
- 防止程序重复启动
- javax.mail.SendFailedException: 530 delivery not allowed to non-local recipient, try authenticating
- 根据http://www.csdn.net/develop/Read_Article.asp?Id=15250例子,频频出错,请各位多帮帮忙,谢谢!!!
- 疑问...请教,在线等
- 文件递归查询错误
我也是新学,异步提交的话就不能体现primefaces的p:commandButton控件的优势了
<p:inputText value="#{paginateBean.cName}" />按回车就能提交,不解。