【发布时间】:2011-11-03 18:28:18
【问题描述】:
问题解决了!! 我的支持 bean 上有一个验证错误,告诉我这样的事情: 'null Converter' 的转换错误设置值'Africa (AFR)'。
由于 JSF 生命周期,我的 backingbean 上的侦听器方法没有被调用
我遇到了 JSF2 的问题。 我有一个带有 ajax 标记的 selectOneMenu 标记,当它的值改变时应该触发一个监听器。 xhtml 页面如下所示(去掉了一些东西)
<h:selectOneMenu id="selectedContinent" value="#{searchExtendedAction.destination.continent}">
<f:selectItems value="#{searchExtendedAction.continents}" />
<f:ajax render="locationSelector" listener="#{searchExtendedAction.doUpdateLocations}" />
</h:selectOneMenu>
在我的支持 bean 中,我有以下内容(省略了一些属性):
@ManagedBean
@SessionScoped
public class SearchExtendedAction implements Serializable{
// Left some properties out
@Valid
private Location departure;
@PostConstruct
public void init(){
System.err.println("INIT called");
allContinents = continentService.getAllContinents();
}
@EJB
private ContinentService continentService;
public void doExtendedSearch()
{
System.err.println("SEARCH");
}
public void doUpdateLocations(AjaxBehaviorEvent event)
{
System.err.println("BONZAI");
}
public List<SelectItem> getContinents()
{
List<SelectItem> continents= new ArrayList<SelectItem>();
continents.add(new SelectItem("--- Select Continent ---"));
for(Continent c : continentService.getAllContinents()){
continents.add(new SelectItem(c.getName()));
}
return continents;
}
}
现在,当我从 selectOneMenu 中选择一个值时,会触发一个 HTTP Post。我知道这一点是因为我的 PostConstruct 方法被调用并且消息在我的控制台中弹出。但是没有调用监听器。我也不知道为什么。
有关我正在使用的技术的更多信息:
16:21:08,282 INFO [AbstractServer] Starting: JBossAS [6.1.0.Final "Neo"]
16:21:11,725 INFO [ServerInfo] Java version: 1.7.0,Oracle Corporation
16:21:11,725 INFO [ServerInfo] Java Runtime: Java(TM) SE Runtime Environment (build 1.7.0-b147)
16:21:11,725 INFO [ServerInfo] Java VM: Java HotSpot(TM) 64-Bit Server VM 21.0-b17,Oracle Corporation
16:21:11,726 INFO [ServerInfo] OS-System: Windows 7 6.1,amd64
16:21:19,067 INFO [AbstractServerConfig] JBoss Web Services - Stack CXF Server 3.4.1.GA
16:21:19,981 INFO [JSFImplManagementDeployer] Initialized 3 JSF configurations: [Mojarra-1.2, MyFaces-2.0, Mojarra-2.0]
【问题讨论】:
标签: ajax jakarta-ee jsf-2