tags:

views:

24

answers:

1

I am not able to figure out what I am doing wrong. Request your inputs. Please.

I have a request scoped managed bean , which has a List of which I render as a datatable in my JSF 1.2 Apache my faces application. When I submit the form , and since there are some server side validations that fails, I add a FacesMessage and show the same JSF page.

In this request-response cycle , In the INVOKE-APPLICATION Phase , I am able to see the values of the List of but the when the page is rendered with the FacesMessage, the datatable is empty.

The other bean-properties and their values are retained in this request-response cycle except for this List / Datatable.

This is how the datatable is constructed in the action method - initial request

    if(getInputXMLString() != null 
            && getInputXMLString().length() >0)
    {
    List<NodeDetailsVO> nodes = Utility.inputXMLStringNodeDetailsVO(getInputXMLString());
        setSelectedNodes(nodes);
    }

When I try the same as above in the postback request (inside the other action method),It works okay.When I add my business Logic inside a private method, and If I call it above this code or after this, It doesn't work.I am only using the getter of the List in the private method. And in the getter method - I only have sysouts inside if and else.

This is how the datatable is rendered in the xhtml page:

<h:dataTable width="80%" cellspacing="0" border="1" 
            id="nodes_datatable" cellpadding="2" 
            style="border-collapse:collapse;"
            value="#{createBean.selectedNodes}"
            binding="#{createBean.selectedNodesHTMLDataTable}"
            var="aResult"
            columnClasses="columnAlignRight,columnAlignLeft"
            >
+1  A: 

This is not the normal case. I do see only two possible causes:

  1. The datamodel (the List as you calls it) is been reset somehow. Probably the getter method is doing more than only returning the datamodel and has reloaded it, but some requestbased parameter/condition is missing.

  2. The datatable or one of its parent components has a rendered attribute which evaluated false.

BalusC
Thanks BalusC. 2 is not true.I am just printing the size and values of the Objects in the List (DataModel) in the getter. Can you please explain more about the request based parameter/condition missing? Are there any others ways to retain the datatable values between requests in a request-scoped Bean?
gurupriyan.e
This question makes me think that the list isn't preserved at all. Can you elaborate what exactly you meant with *"In the INVOKE-APPLICATION Phase , I am able to see the values of the List"* in your original question? How did you determine that?
BalusC
In the action method that is called, I printed the values of the List using its getter, Also I am using a PhaseListener,So I knew what happens in which phase. To rephrase - how to retain datatable values between requests in a request-scoped bean?
gurupriyan.e
Load it the same way as for the "initial" request. Isn't the getter doing more than only returning data?
BalusC
The getters just return and do nothing else.
gurupriyan.e
It's shooting in the dark without a concrete self containing code example which reproduces the problem (i.e. we would just need to copypaste and run the code into a blank environment to see the same problem as you have). Please update your question to include one.
BalusC
Okay. I have added.
gurupriyan.e
Sorry, those snippets are not very helpful. Too much noise and the business logic is unclear. I more mean the *smallest possible* but **complete** JSF file and managed bean code which still exhibits the problem. Remove all noise (for example CSS is completely irrelevant to the problem) and replace the data with some stub. At least, I would run a debugger and track the variable `selectedNodes` to see what all happens with it.
BalusC