JSF UIRepeat and PostBack



我有一个简单的页面,其中我使用<ui:repeat>,它从支持bean获取值。

初始请求将给它一个空列表。然后回发将调用一个操作,该操作将更改<ui:repeat>后面的模型,但它不会呈现?!

我通过它调试,我看到<ui:repeat>在恢复视图阶段评估值,但就是这样。当它到达渲染响应时,它不使用来自我的bean的最新值。这是预期行为吗?

我怎样才能使它工作?我必须自己编写重复标签吗?

如果没有你的一些代码,我真的不知道是什么问题,但这些是基本的:

支持bean:

public class ObjectService{
private DataModel objectDataModel;
private List<Object> objectList;
private Pagination paginationHelper;
private ObjectDao objectDao = new ObjectDao();
private String queryOption;
public void setQueryOption(String queryOption){
    this.queryOption = queryOption;
}
public String getQueryOption(){
    return this.queryOption;
}
public <E> PaginationHelper getPagination(final List<E> list) {
    pagination = new PaginationHelper(10) {
        @Override
        public int getItemsCount() {
            return list.size();
        }
        @Override
        public DataModel createPageDataModel() {
            return new ListDataModel(list);
        }
    };
    return pagination;
}
public void setPagination(PaginationHelper pagination) {
    this.pagination = pagination;
}
public List<Object> getObjectList(){
    this.objectList = objectDao.readObjectsWhere(queryOption);
    return this.objectList;
}
public void setObjectList(List<Object> objectList){
    this.objectList = objectList;
}
public DataModel getObjectDataModel(){
     if (objectDataModel == null) {
        objectDataModel = getPagination(getObjectList()).createPageDataModel();
    }
    return objectDataModel;
}
public void setObjectDataModel(DataModel objectDataModel){
    this.objectDataModel = objectDataModel
}
public String changeModel(){
    objectDataModel = null;     
    return null;
}
}

XHTML页面:

    ...
<h:form>

    <fieldset>                   
        <label>
        <span>Option:</span>
        <h:inputText value="#{objectService.queryOption}" />
        </label>
        <h:commandButton action="#{objectService.changeModel}" value="request data" />
    </fieldset>
    <ui:repeat value="#{objectService.objectDataModel}" var="objectVar">
        <h:outputLabel value="#{objectVar.property1}" />
        <h:outputLabel value="#{objectVar.property2}" />
        <h:outputLabel value="#{objectVar.property3}" />
    </ui:repeat>
</h:form>
...

相关内容

  • 没有找到相关文章

最新更新