[
https://issues.apache.org/jira/browse/MYFACES-4425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17461482#comment-17461482
]
Thomas Andraschko commented on MYFACES-4425:
--------------------------------------------
i found that when i modify #saveState of UIRepeat like this, it works fine:
{code:java}
@Override
public Object saveState(FacesContext context)
{
if (context.getViewRoot() != null)
{
if
(context.getViewRoot().getAttributes().get(ViewPoolProcessor.RESET_SAVE_STATE_MODE_KEY)
== ViewPoolProcessor.RESET_MODE_SOFT)
{
_dataModelMap.clear();
_isValidChilds = true;
}
else if
(context.getViewRoot().getAttributes().get(ViewPoolProcessor.RESET_SAVE_STATE_MODE_KEY)
== ViewPoolProcessor.RESET_MODE_HARD)
{
_dataModelMap.clear();
_isValidChilds = true;
_rowStates.clear();
}
}
Object values[] = new Object[3];
values[0] = super.saveState(context);
values[1] = null;
values[2] = UIComponentBase.saveAttachedState(context, _rowStates);
return values;
}
{code}
> Input value not saved/restored in state when inside UIRepeat
> ------------------------------------------------------------
>
> Key: MYFACES-4425
> URL: https://issues.apache.org/jira/browse/MYFACES-4425
> Project: MyFaces Core
> Issue Type: Bug
> Reporter: Thomas Andraschko
> Priority: Major
>
> https://github.com/eclipse-ee4j/mojarra/issues/4957
> reproducer:
> click "1", message should say "null -> 1"
> click "3", message should say "null -> 3"
> click "2", message should say "1 -> 2", but MyFaces said "null -> 2"
> click "4", message should say "3 -> 4", but MyFaces said "null -> 4"
> {code:html}
> <h:form id="form">
> <ui:repeat value="#{issue3833Bean.lists}" var="list">
> <h:selectOneListbox valueChangeListener="#{issue3833Bean.listener}"
> size="2">
> <f:selectItems value="#{list}" />
> <f:ajax render="form:message" />
> </h:selectOneListbox>
> </ui:repeat>
> <h:panelGroup id="message" layout="block">
> <h:outputText value="#{issue3833Bean.message}" />
> </h:panelGroup>
> </h:form>
> {code}
> {code:java}
> @Named
> @RequestScoped
> public class Issue3833Bean {
> private static List<String> list1 = Arrays.asList("1", "2");
> private static List<String> list2 = Arrays.asList("3", "4");
> private static List<List<String>> lists = Arrays.asList(list1, list2);
> private String message;
> public void listener(ValueChangeEvent e) {
> message = (e.getOldValue() + " -> " + e.getNewValue());
> }
> public List<List<String>> getLists() {
> return lists;
> }
> public String getMessage() {
> return message;
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)