Giuseppe Marra
Giuseppe Marra

Reputation: 121

Resetting jsf inputText value inside a dataTable when valueChangeListener fires

I'm using Icefaces 1.8.2 and, unfortunately, I can't change it. I have a:

<ice:selectOneMenu  value="#{myBean.selectedValue}" partialSubmit="true" 
       valueChangeListener="#{myBean.reloadTable}">
...

Then I have a dataTable:

<ice:dataTable  value="#{myBean.items}" var="item">
    <ice:column>
        <ice:outputText value="#{item.key}" />
    </ice:column>
    <ice:column>
        <h:inputText value="#{item.value}" />
    </ice:column>
</ice:dataTable>

In the bean:

private List<KeyValueEntry> items;

public String reloadTable(ValueChangeEvent event) {


    items=getNewItems(); //returns a list with all values set to null

    UIViewRoot view = FacesContext.getCurrentInstance().getViewRoot();
    return view.getViewId() + "?faces-redirect=true";
 }

Now the problem is the following: items=getNewItems() does not empty the input boxes if called from the reloadTable(ValueChangeEvent event). If I write a reset method called by a commandButton it works fine.

Upvotes: 0

Views: 419

Answers (1)

Spielername
Spielername

Reputation: 106

The commandButton performs a Submit and redirects to the page/view you configured.

As far as I know the valueChangeListener does not by default. So you need to perform the redirect within your bean with something like:

FacesContext.getCurrentInstance().getExternalContext().redirect(..)

Maybe items=getNewItems() empty your inputs but the view is not rendered again when using the Listener?

Upvotes: 1

Related Questions