【发布时间】:2012-06-07 11:36:37
【问题描述】:
我正在使用JSF 1.2和RichFaces 3.3.3,我有一个很奇怪的问题,代码所做的是将要搜索的媒体项的名称放入支持bean属性searcTitle中,当用户单击搜索按钮,onSearch 操作侦听器会填充结果列表。
这是代码
<rich:panelBar>
<rich:panelBarItem>
<rich:tabPanel>
<rich:tab label="Media">
<h:panelGrid columns="1">
<h:panelGrid columns="2">
<h:inputText value="#{media.searchTitle}"/>
<a4j:commandButton value="Search" actionListener="#{media.onSearch}"/>
</h:panelGrid>
<a4j:outputPanel id="mediaSearchResults" ajaxRendered="true">
<rich:dataTable value="#{media.results}" var="item">
<h:column>
<h:outputText value="#{item.title}"/>
</h:column>
</rich:dataTable>
</a4j:outputPanel>
</h:panelGrid>
</rich:tab>
</rich:tabPanel>
</rich:panelBarItem>
</rich:panelBar>
还有后台bean代码
private String searchTitle="";
private List<MediaItem> results;
public void setSearchTitle(String title){
getLogger().log(Level.INFO,"At the setter of the search title string");
this.searchTitle = title;
}
public String getSearchTitle(){
return searchTitle;
}
//Setter and getter for the results list;
//Action Listener
public void onSearch(ActionEvent evt){
getLogger().log(Level.INFO,"At the actionListener");
//Some function that searches and populates the results list
populateResults();
}
现在的问题是,每当我点击搜索按钮时,动作监听器永远不会被调用,尽管在检查带有火错误的页面时,每次我点击它都会向服务器发送一个请求,但动作监听器本身不是触发。
有人知道我为什么会遇到这个问题吗?我是这方面的初学者,所以请保持你的语言简单。
提前致谢。
这是来自 firebug 的 Reposne/ 请求标头
响应标头
Ajax-Response true
Cache-Control no-cache, must-revalidate, max_age=0, no-store
Content-Type text/xml;charset=UTF-8
Date Sat, 02 Jun 2012 16:03:13 GMT
Expires 0
Pragma no-cache
Server Sun GlassFish Enterprise Server v2.1.1
Transfer-Encoding chunked
X-Powered-By Servlet/2.5, JSF/1.2
请求标头
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en,ar;q=0.7,en-us;q=0.3
Connection keep-alive
Content-Length 17986
Content-Type application/x-www-form-urlencoded; charset=UTF-8
Cookie JSESSIONID=de975352b3adc4f59d57006755ea; JSESSIONID=de682f835c0fa928413ba7e5f59d; form:tree-hi=form:tree:applications:enterpriseApplications
Host localhost:8080
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0
以及响应http://justpaste.it/10uh的xml有效负载的链接
【问题讨论】:
-
您的请求包含 2 个会话 cookie。这看起来不正确,可能是您的问题的一个可能原因。重新启动浏览器或清除 cookie 并重试。
-
我确实尝试过,并重述了应用程序本身但没有用
-
那么,请仔细检查所有可能原因的列表:stackoverflow.com/questions/2118656/… 到目前为止发布的代码中看不到可能的原因。如果您无法根据列表确定,那么您需要编辑您的问题以包含真正的 SSCCE 而不是仅部分 sn-p。
标签: java jsf jakarta-ee richfaces