Jsf h:selectOneMenu所选字段为';空';使用@Named和@products?
为什么这行不通?下拉列表填充为OK,但提交表单时,selectedCatId字段为null。为什么?请帮忙 豆子:Jsf h:selectOneMenu所选字段为';空';使用@Named和@products?,jsf,cdi,Jsf,Cdi,为什么这行不通?下拉列表填充为OK,但提交表单时,selectedCatId字段为null。为什么?请帮忙 豆子: @Model public class MyBean { @Named @Produces private Long selectedCatId; @Named @Produces private List<Category> cats; } @模型 公共类MyBean{ @命名 @产生 私人长选择CATID; @命名 @产生 私人名单猫; } 页面:
@Model
public class MyBean {
@Named
@Produces
private Long selectedCatId;
@Named
@Produces
private List<Category> cats;
}
@模型
公共类MyBean{
@命名
@产生
私人长选择CATID;
@命名
@产生
私人名单猫;
}
页面:
<h:selectOneMenu value="#{selectedCatId}">
<f:selectItems value="#{cats}" var="cat"
itemValue="#{cat.id}" itemLabel="#{cat.name}" />
</h:selectOneMenu>
不能分配给bean,只能分配给bean属性 只需从您的成员中删除
@Named@products
,将@Named
添加到MyBean
并分别替换{selectedCatId}
和{cats}
{MyBean.selectedCatId}和{MyBean.cats}
(这假设
cats
在某个地方被初始化。)不能分配给bean,只能分配给bean属性
只需从您的成员中删除@Named@products
,将@Named
添加到MyBean
并分别替换{selectedCatId}
和{cats}
{MyBean.selectedCatId}和{MyBean.cats}
(这假设
cats
在某个地方被初始化。)谢谢。对,我不知道@是如何产生功的,它只能产生一个对象,不能接收。这就像是一个能手,而不是二传手。谢谢。对,我不知道@是如何产生功的,它只能产生一个对象,不能接收。这就像一个接球手,而不是二传手。