f:ajax不更新ui:repeat

时间:2012-09-19 09:14:28

标签: ajax jsf-2 uirepeat

我的JSF页面是这样的,<f:ajax>部分现在可以正常工作。

<h:selectOneListbox value="#{category.categoryId}">
    <f:selectItems value="#{category.allSubCategories}" var="c" itemLabel="#{c.title}" itemValue="#{c.categoryId}" />
    <f:ajax execute="@form" render="projects" />
</h:selectOneListbox>

<h:panelGroup id="projects">
    <ul>
        <ui:repeat items="#{category.allItems}" var="o" id="itemTable">
            <li><h:graphicImage value="#{o.imageUrl}" id="itemImage" /></li>
            <li><h:outputText value="#{o.title}" /></li>
            <li><label>Price: $ </label><h:outputText value="#{o.price}" /></li>
        </ui:repeat>
    </ul>       
</h:panelGroup>

我的豆是:

@ManagedBean(name = "category")
@SessionScoped
public class CategoryServiceBean extends BaseService implements Serializable {

    private static final long serialVersionUID = -12082902292711980L;    
    private Integer categoryId;
    private Integer parentCategoryId;
    private Integer locationId;

    @ManagedProperty(value="#{categorySupport}")
    private CategorySupport categorySupport;

    public List<RestCategory> getAllSubCategories() {
        return getCategorySupport().getCategoriesByParent(locationId, parentCategoryId);            
    }

    public List<RestItem> getAllItems() {
        return response = getCategorySupport().getCategoryItems( locationId, categoryId);               
    }

    // ...
}

我的问题是<f:ajax execute="@form" render="projects" />没有将值填充到<h:panelGroup id="projects">。这是怎么造成的,我该如何解决?如果我使用<h:dataTable>代替<ui:repeat>,那么它可以正常工作。

1 个答案:

答案 0 :(得分:1)

<ui:repeat items="#{category.allItems}" var="o" id="itemTable">

<ui:repeat>中不存在items属性。你显然把它与<c:forEach>混淆了。使用value属性。

<ui:repeat value="#{category.allItems}" var="o" id="itemTable">
相关问题