Mark M
Mark M

Reputation: 1600

JSF values not being updated in bean

In JSF 1.1, I am having a lot of trouble with passing values. I pass values from bean to a JSF page, but they are not being passed back, causing a NullPointerException. declareFinishList in bean is populated by an initializing method to display on the page, but when I submit I get a nullpointer exception at for (DeclareFinish df : declareFinishList) showing that it is not being passed back. The map declaredFinishMap also comes out as null. I've done this before so I don't understand why this particular one is having trouble while my other similar tables are working fine.

EDIT: I've managed to pass declareFinishList by placing it in session scope, but I still can't seem to pass declaredFinishMap.

To note, the bean is defined by rsaleController in faces-config.xml. Entire page is wrapped in h:form that I didn't include.

Bean:

public class RetailSaleController extends BaseBean {
    private List<DeclareFinish>     declareFinishList;
    private Map<DeclareFinish, Boolean> declaredFinishMap = new LinkedHashMap<DeclareFinish, Boolean>();

    public void saveDeclareFinishList(ActionEvent event) {
    List<DeclareFinish> list = new ArrayList<DeclareFinish>();
        for (DeclareFinish df : declareFinishList) {
            if(declaredFinishMap.get(df)) {
                list.add(df);
            }
        }   
    }
}

Page:

<h:panelGroup id="declareFinishListPanel">
    <rich:dataTable id="declareFinishItemTable" border="1"
        value="#{rsaleController.declareFinishList}" var="item"
        <rich:column width="16">
            <f:facet name="header">
                <rich:spacer height="24px;" />
            </f:facet>
            <h:outputText value="#{rowNo+1}" />
        </rich:column>

        <rich:column style="text-align:center;">
            <f:facet name="header">
                <h:outputText value="Locked" />
            </f:facet>
            <h:selectBooleanCheckbox id="reset"
                value="#{rsaleController.declaredFinishMap[item]}" />
        </rich:column>

        <rich:column sortBy="#{item.dealerId}" sortIcon="none;" width="110">
            <f:facet name="header">
                <h:outputText value="#{labels.crmsFldLabDealer}" />
            </f:facet>
            <h:outputText value="#{item.dealerId}" />
        </rich:column>

    </rich:dataTable>
</h:panelGroup>

<a4j:commandLink reRender="declareFinishItemTable"
    actionListener="#{rsaleController.saveDeclareFinishList}">
    <h:graphicImage value="/images/save.gif" title="Save changes"
        style="height:16;width:16;border-style:none;vertical-align:middle" />
</a4j:commandLink>

Upvotes: 0

Views: 565

Answers (1)

Boris Remus
Boris Remus

Reputation: 191

Just looking at the code snippit, declareFinishList is not getting initialized anywhere, unless that's elsewhere in the code.

Upvotes: 1

Related Questions