Hard hard thing to do - table of dependant select items that you can add new rows to. (backing bean driven)
(When you add a new row it keeps values from the previous row)
In my search for the answer I made an forEach act like a table - by using the f:attribute to pass through the current row - crazy but I hopw this helps someone sometime.
Stuff I learned
<af:selectOneChoice label="#{labelBundle['choice_lbl']}"
id="soc1" value="#{row.choiceId}"
valueChangeListener="#{pageFlowScope.testBean.choiceValueChange}"
required="true"
autoSubmit="true" unselectedLabel="Choose...">
<f:attribute name="currentRow" value="#{row}"/>
<f:selectItems id="isItem" value="#{row.choiceList}"/>
</af:selectOneChoice>
Notice the f:attribute - this can pass any value to the backing bean in this case the row. - very bad for performance though.
Refresh on the component you need on value change:
in your value change listener : refreshDependantComponent("soc 2", valueChangeEvent.getComponent());
private void refreshDependantComponent(String idMatch, UIComponent uiComponent) {
UIComponent parent = uiComponent.getParent();
Iterator
while (iter.hasNext()) {
UIComponent iterItem = iter.next();
if (iterItem.getId() != null && iterItem.getId().startsWith(idMatch)) {
AdfFacesContext.getCurrentInstance().addPartialTarget(iterItem);
}
}
}
Real solutions: : http://itnewscast.com/applications/how-populate-different-select-list-content-table-row
Or dont use immediate="true"
Thanks Jeromy for sending this to me and thanks Frank for the post.
Comments
Post a Comment