<ice:commandButton binding="#{season}"/>
The binding attribute must be bound to a bean property of type UIComponent. It is used where you want the framework to give you a reference to the component in a backing bean or to provide an instance from the backing bean). See section 3.1.5 of the JSF 1.2 spec for more details.
<ice:commandButton id="#{season.id}"
partialSubmit="true"
style="background-color: #FFFFFF"
value="#{season.value}"
actionListener="#{Phase1EventBean.updateSeasons}"/>
The id
attribute cannot be dynamic - JSF will take care of ensuring its uniqueness on the client using the clientId (read this for more detail).
EDIT:
However, on the UI, every button appears to be toggled when I click just the one button.
I am guessing that ice:panelSeries
does not store the component state of every row as some repeating controls do (e.g. dataTable). Remember, there is only one button instance, even if it is encoded/decoded once per "row".
I've never used ICEfaces, but I suggest binding to beans similar to this:
public class Bean {
private final List<SelectionBean> seasonsList = Arrays.asList(
new SelectionBean("Spring"), new SelectionBean("Summer"),
new SelectionBean("Autumn"), new SelectionBean("Winter"));
public List<SelectionBean> getSeasonsList() { return seasonsList; }
public static class SelectionBean {
private String season;
private boolean selected;
public SelectionBean() {}
public SelectionBean(String season) { this.season = season; }
public String getSeason() { return season; }
public void setSeason(String season) { this.season = season; }
public String toggle() {
System.out.println("toggle " + season);
selected = !selected;
return null;
}
public String getStyle() {
return selected ? "background-color: yellow" : "background-color: blue";
}
}
}
I've pared the logic down to the bare minimum, but hopefully you get how to modify the logic to put the hibernate support back in. Your component would then become something like this:
<ice:panelSeries value="#{bean.seasonsList}" var="item">
<ice:commandButton partialSubmit="true"
style="#{item.style}"
value="#{item.season}"
action="#{item.toggle}"/>
</ice:panelSeries>
So, for each item in your list, all the binding goes back to the one piece of state (a SelectionBean instance) and you don't try to store any non-declarative state on the component itself.
I try to use action
over actionListener
when I can - it keeps JSF stuff out of the POJOs.