2
votes

I have a simple page where a I use <ui:repeat> and it gets the value from a backing bean.

The initial request will give it an empty list. The postback then will invoke an action that will change the model behind the <ui:repeat> but it is not rendered?!

I debugged through it and I saw that the <ui:repeat> evaluates the value at restore view phase but thats it. When it reaches render response it does not use the latest value from my bean. Is that the expected behavior?

How can I make that work? Do I have to write my own repeat tag?

1
This should work fine, please include minimal xhtml to demonstrate this behaviour.mrembisz
@mrembisz I can't reproduce that error somehow. It's really strage, this only happens when the session is new? I'm on IBM... I will try it but could you suggest me anything?Christian Beikov
ui:repeat may act strange when it is nested two or more times. It comes with its own state management and I think it's not entirely reliable for more complex applications. When it is not nested it should work predictably.mrembisz
@mrembisz I can't even give you a full example because the test app i made now does not work on glassfish as soon as i add myfaces as jsf implementation. The real application runs on WAS8 with myfaces 2.1.3. The same myfaces implementation behaves different on glassfish 3.1.2-b4Christian Beikov
Really amazing, myfaces jsf impl + codi on glassfish 3.1.2-b4 destroys CDI functionallity within JSF... hard to reproduce that error, but i can't imagine that what the problem could be. the repeat tag is NOT nested!Christian Beikov

1 Answers

0
votes

I can't really tell what could be the problem without some of your code, but these are the basics:

Backing 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 page:

    ...
<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>
...